Repository navigation
Conversation
…r that runs CFG One request with CFG on, stopped after its first step, per run; its negative cond goes to every training sample that has none. --dmd2-teacher-guidance-scale > 1 could not run before: the student samples unguided, and the engine returns a negative cond only for a request that runs CFG.
…function A --custom-generate-function-path run fetched it and then dropped it, since only generate_microgroup attached it. The tests now also drive the fetch from generate_rollout_async and check that the run's negative prompt and size reach the request: both parts could be removed without a test failing.
Without a negative prompt the engine runs no CFG, and the run went on through a rollout and the critic's first steps before the trainer raised. The trainer's check names no cause again: a custom rollout function or a saved batch reaches it too.
…ould own a stored copy The comment said the store deletes it with the first rollout; nothing would delete it.
3 tasks done
zhihengy
changed the base branch from
main
to
fix/qwen-image21-cfg-branch-tails
November 24, 2026 00:07
…uard is checked Without the scale in its argv the assertion held with or without the guard.
…d args are set It sat with the defaults of unset flags, so the tests that pin what those defaults write had to carry it.
…t worth a request field The reply's negative cond does not depend on it.
… validation rules out The student never runs CFG under dmd2, so only an engine that always returns a negative cond keeps its own.
zhihengy
marked this pull request as ready for review
November 24, 2026 03:12
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
--dmd2-teacher-guidance-scaleabove 1 could not run: the student's rollouts are unguided, and the engine returns a negative cond only for a request that runs CFG, so the teacher's CFG forward stopped at "needs the rollout's negative cond". With this PR the rollout fetches it once per run and no engine change is needed.Draft: it is an alternative to sgl-project/sglang#45523 (a request field that makes every unguided sample return its negative cond), opened to compare the two. Stacked on #420, the Qwen-Image 2.1 CFG fix the e2e below needs.
What
fetch_neg_condinsglang_diffusion_rollout.py: onePOST /rollout/generatewith the run's sampling params, CFG on at the teacher's scale, stopped after step 0, tensors inline. It raises when the reply has no negative cond.generate_rollout_asynccalls it before the first rollout and keeps the result onGenerateState.generate_and_rm_microgroupattaches it to every training sample whosedenoising_envhas no negative cond, after the built-in or a custom generate function. A sample that has its own keeps it.args.rollout_neg_cond_guidance_scale, derived inmiles_validate_args:--dmd2-teacher-guidance-scaleunderdmd2when that is above 1, elseNone. The rollout reads only this value.supports_cfg_training=False, i.e. LTX and H3) now rejects a teacher scale above 1 at argument validation: its forward drops the negative branch, so the teacher would score unguided.Why
sglang-milesworks as it is. sglang#45523 needs each pipeline to produce the negative cond without CFG and sets its declaration on 6 pipeline classes; Qwen-Image 2.1 is not among them.Limits
true_cfg_scale=None, and that config rescales to the cond norm only under a true-CFG scale, while the engine and diffusers always rescale. This path could not run before; whether the teacher should rescale is a numerics decision this PR does not take.--diffusion-height/width.--diffusion-negative-prompt; without it the fetch raises.Tests
test_rollout_neg_cond.py: the fetch sends the run's params (negative prompt and size among them) with CFG at the scale, stop index 0 and no output store, leaves the run's params unchanged and returns the reply's negative cond; a reply without one raises;generate_rollout_asyncfetches before the first rollout only; after the built-in and after a custom generate function, a training sample without a negative cond gets the fetched one and a sample with its own keeps it. Each of these fails when its part of the code is removed.test_loss_type_recipes_parse.py: a DMD2 teacher scale of 4.5 sets the fetch scale, 1.0 leaves it unset and so does another loss type that carries the flag; a model that trains unguided rejects 4.5.Validation
pytest tests/fastin the CI CPU environment at 9e15397: 839 passed, 20 failed;maine6129d0 in the same environment: 830 passed and the same 20 failed (output-store tests).sglang-miles0d5ab02 (without sglang#45523), 512², 4 steps, 2 rollouts of 4 samples, 2 critic steps.--dmd2-teacher-guidance-scale 4.0 --diffusion-negative-prompt blurryat 9e15397: the job succeeds in 302 s. The engine serves 9/rollout/generaterequests, against 8 for the same run at scale 1.0.perf/*and device memory are bitwise equal across the four runs.dmd2_grad_abs_mean0.681 vs 0.0195,dmd2_teacher_dist_abs_mean0.819 vs 0.351 at its first step).--diffusion-negative-promptat 8735c42: the job fails at the fetch, after one request and before any rollout sample, with "returned no negative cond".run-ci-*label yet).Checklist
black,isortandruffat the pinned versions pass on the changed files--dmd2-teacher-guidance-scalein the CLI reference says where the negative cond comes from