Repository navigation
Conversation
zhihengy
added this pull request to stack #332
October 19, 2026 20:42
zhihengy
marked this pull request as ready for review
October 19, 2026 23:01
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.
Third of the DMD2 stacked series, on top of #330. A step strategy can now stop the engine at step
i, so one rollout returns the student's inputx_{σ_i}and its x0 predictionx̂0_i: the data that DMD2's backward simulation trains on.What
(sde, ret, stop).stopis sent asrollout_stop_step_index. The three built-ins returnstop=None, so their requests are unchanged. A custom strategy must now return the third element;Nonekeeps the old behavior.stop_at_random_step. It drawsi ~ U{0..N-1}from the request seed and returnsret=[i, i+1],stop=iand no SDE filter. The engine runs steps0..iand sends stepistraight to σ=0. The trajectory then holdsx_{σ_i}followed byx̂0_ias its final latent. With--diffusion-sde-type cps --diffusion-noise-level 1.0, every earlier step re-noises its x0 prediction with fresh noise, which is the DMD2 multi-step sampler.customization.mdandcli-reference.md, and the new built-in.Nothing consumes this yet. The critic and actor PRs (4/7, 5/7) read
i = latent_step_indices[0]andσ_i = sigmas[i]from the trajectory.Why
i, on an input the student produced itself (backward simulation). The firstisteps are a no-grad rollout, so they belong in the engine. This is the same split as Flow-GRPO, whose selected SDE steps are picked miles-side by--diffusion-step-strategy-path.x̂0_i, and the generator recomputes it fromx_{σ_i}, so the rollout has to return both. Truncating the schedule makesx̂0_ithe final latent. That needs no new response field, and the engine runsi+1DiT forwards instead ofN.cpstransition atnoise_level=1:x_next = (1-σ') x̂0 + σ' ε. At σ'=0 it returnsx̂0exactly; so doesode.sglang side
sgl-project/sglang#45230 is one commit on
sglang-milesbff3f6ae7 (+94 lines, 34 of them non-test). Merge it and bump the image before this PR: an engine without it drops the unknown field and silently runs every step.RolloutRequest/SamplingParamsget a newrollout_stop_step_indexfield.set_timesteps,TimestepPreparationStagetruncates the schedule totimesteps[:i+1]andsigmas[:i+1] + terminal. It rejectsioutside the schedule.Validation
Engine A/B on FLUX.2-klein-base-4B (1×B200, 512², 4 steps,
cps/ noise 1.0, guidance 1, debug tensors on). SD3.5-M was not run because its weights are gated and unavailable on this devbox. FLUX.2 also tests a resolution-dependentmushift. Requests come fromstop_at_random_stepand are parsed byapply_rollout_image_response. Each one is compared with a full 4-step rollout that uses the same seed:ilatent_step_indicesx_{σ_i}vs full runx_i - σ_i·v_i(bf16)sglang-milesbff3f6ae7 on a full rollout: latents, sigmas, model outputs and the decoded image.test_scheduler_rollout_unit.pyandtest_rollout_api.py. The new case checks that a stopped rollout replays the full run's prefix bit for bit and ends on the x0 prediction. It fails if the terminal sigma isn't re-appended.Tests
tests/fast/rollout/test_step_strategy_hub.py: the new strategy returns[i, i+1]andstop=i, and it draws every step over seeds. The built-ins returnstop=None.Checklist
pre-commithooks pass on the changed files (both repos)pytest tests/fastis green (518 passed, 6 skipped)python3 train_diffusion.py --helpstill parses (no flag added; the--diffusion-step-strategy-pathcontract changed)cli-reference.mdandcustomization.md)Stack
DMD2: distill a flow-matching teacher into a few-step student with distribution matching. Merge in order:
external_data--loss-type dmd2on the actor