[diffusion, trainer, worker, data, cfg, tests] feat: add Qwen Image DMD and DMD2 - #9
Open
NancyFyong wants to merge 8 commits into
Open
[diffusion, trainer, worker, data, cfg, tests] feat: add Qwen Image DMD and DMD2#9NancyFyong wants to merge 8 commits into
NancyFyong wants to merge 8 commits into
Conversation
This was referenced Sep 4, 2026
NancyFyong
force-pushed
the
distillation-pr2-runtime
branch
from
September 5, 2026 05:16
5e7ced5 to
80d7b92
Compare
NancyFyong
force-pushed
the
distillation-pr3-qwen-image
branch
from
September 5, 2026 05:16
0a7384a to
5826854
Compare
NancyFyong
force-pushed
the
distillation-pr2-runtime
branch
from
September 6, 2026 03:15
80d7b92 to
ddbcd4e
Compare
NancyFyong
force-pushed
the
distillation-pr3-qwen-image
branch
from
September 6, 2026 03:15
0d72ab5 to
3c6c416
Compare
7 tasks
…MD and DMD2 Add the first architecture implementation for the generic distribution- matching runtime. Qwen-Image now supports differentiable one-step and few-step student rollout, guided teacher scoring, fake-score training, original-DMD regression, EMA export, and matched vLLM inference schedules. Include validated configuration, regression-pair data loading, runnable and smoke recipes, CPU coverage, and real FSDP1/FSDP2 adapter/export tests. Refs verl-project#519 Refs verl-project#543 AI assistance (OpenAI Codex) was used for this change. Co-authored-by: OpenAI Codex <noreply@openai.com> Signed-off-by: NancyFyong <2742092809@qq.com>
…preserve prompt templates Broadcast stochastic rollout exits across the training group so FSDP collectives and gradient exits agree. Apply the native Qwen template before removing its fixed text prefix, and sample continuous score sigmas uniformly inside their bounds rather than clamping full-range samples. Use descriptive flat helpers, reuse Qwen token-ID encoding without a nested pipeline class, and extend smoke coverage to repeated multi-rank updates and user-only prompts. Document Pick-a-Pic preparation and the prompt-only DMD2 versus paired original-DMD boundary. Validation: 1363 L1 CPU tests and all pre-commit hooks passed. Eight-rank FSDP1/FSDP2 tests passed. Eight-rank production FSDP2 completed three cycles with checkpoints; resuming step 1 replayed all 19 non-performance metrics for steps 2 and 3 within 1e-7 relative tolerance. Refs verl-project#543 AI assistance (OpenAI via pi) was used for this change. Co-authored-by: OpenAI <noreply@openai.com> Signed-off-by: NancyFyong <2742092809@qq.com>
Reuse worker accumulation for same-resolution physical batches and native vLLM-Omni scheduling for request batches. Preserve repeated-phase metrics and distinguish durations/counts from losses/ratios so throughput reports reflect the actual workload rather than overwritten or stale values. Add CPU and multi-rank GPU regression coverage, trace annotations, and usage guidance without changing default performance settings or mixing in the separate checkpoint-layout draft. Refs: verl-project#519, verl-project#543 Validation: 1,408 L1 CPU tests, changed-file pre-commit, eight-rank DMD/DMD2 FSDP1/FSDP2 batch tests, native request-batch/FA3 tests, and independent real-Qwen DMD2 short runs. AI assistance (Pi) was used for this change. Co-authored-by: Pi Signed-off-by: NancyFyong <2742092809@qq.com>
Update the Qwen phase runner and profiling tests for the reviewed controller and utility module names. Use the public fake-executor failure setting in the metrics regressions. AI assistance (OpenAI via pi) was used for this change. Co-authored-by: OpenAI <noreply@openai.com> Signed-off-by: NancyFyong <2742092809@qq.com>
…ing adapter Rename qwen_image_distillation/phase_runner.py by folding its DMD phase computation (QwenImageDMDPhaseRunner, QwenImageConditionProvider, build_qwen_dmd_sigmas) into diffusers_training_adapter.py, so the package matches the repository pipeline convention of one diffusers_training_adapter plus one vllm_omni_rollout_adapter, identical to qwen_image_flow_grpo / qwen_image_dpo / qwen_image_diffusion_nft. The architecture-neutral DistillationPhaseRunner protocol and worker-side phase_runner state are unchanged. Validated in the required environment: full L1 CPU suite 1422 passed; targeted Qwen adapter/request-batch/runtime suites 83 passed; ruff, mypy, generated-config verification and all staged pre-commit hooks pass. Co-authored-by: Claude Signed-off-by: NancyFyong <2742092809@qq.com>
Follow the PR 2 rename of the architecture-owned computation object: QwenImageDMDPhaseRunner -> QwenImageDMDComputer build_distillation_phase_runner -> build_distribution_matching_computer The class implements the renamed DistributionMatchingComputer protocol; test doubles and helpers follow (ToyPhaseRunner -> ToyDMComputer, worker.phase_runner -> worker.dm_computer). The compute_phase method and the PhaseRequest/PhaseResult contracts are unchanged. Validated in the required environment: full L1 CPU suite 1422 passed; targeted Qwen adapter/request-batch/runtime suites 83 passed; ruff, mypy, generated-config verification and all staged pre-commit hooks pass. Co-authored-by: OpenAI Codex Signed-off-by: NancyFyong <2742092809@qq.com>
NancyFyong
force-pushed
the
distillation-pr3-qwen-image
branch
from
September 6, 2026 04:59
693e649 to
e7ee047
Compare
Drop inactive nullable regression targets before collation so valid rows do not become conflicting worker inputs. Register the example with the documentation and carry the lower-stack reduction fixes. Validation: 571 targeted CPU tests passed; applicable pre-commit hooks, config regeneration, and diff checks passed. AI assistance (pi coding agent) was used for this change. Co-authored-by: pi coding agent Signed-off-by: NancyFyong <2742092809@qq.com>
Merge distillation-pr2-runtime without rewriting published history. Keep the existing Qwen timing/count policy and test helpers. The resulting tree is identical to the CPU-tested repair snapshot. AI assistance (pi coding agent) was used for this change. Co-authored-by: pi coding agent Signed-off-by: NancyFyong <2742092809@qq.com>
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.
Summary
Implements the Qwen-Image architecture stage of the distribution-matching RFC as a stacked change on PR fork #8:
dmdanddmd2noise - x0velocity convention, and fp32 scheduler/objective arithmeticThe DMD2 adversarial classifier profile remains intentionally out of scope and fails closed; it is the next dedicated stage in RFC #519.
Review update — 2026-09-07
Current validated head:
a0610326de063e5c180e74d6235996023b52de8c, stacked on runtime1a0edbb. Parent fixes were merged without rewriting history; the final code tree matches the tested repair snapshot.teacher_target_latents/teacher_target_pixelscolumns before collation, so valid None/NaN cells do not become conflicting worker inputs.Stack
Why this is not duplicate work
Before opening this PR, I checked:
The pre-creation search found no competing Qwen-Image DMD/DMD2 architecture adapter PR. PR fork #8 is the required architecture-neutral runtime underneath this stacked change; existing OPD, DPO, and DiffusionNFT implementations use different optimization and data-flow contracts.
The follow-up search for
543 in:bodyandQwen DMDfound no competing upstream implementation; upstream #546 is the required parent runtime, not another Qwen adapter. This update extends this existing PR rather than creating another one.Algorithm and boundary details
3.0:[1.0, 0.9, 0.75, 0.5, 0.0].[0.02, 0.98]clamping.negative + scale * (positive - negative)and configurablenone,layer_norm, orscalarnormalization.epsilon - x_gconstruction.studentorstudent_emais exportable; teacher and fake-score state remains training-only.Batching and profiling follow-up
Validation
Current-head CPU and sanity verification
The dependent PR 5 stack passed 1,521 full L1 CPU tests. Current CPU verification used Python 3.11 / PyTorch 2.13.0+cu129 and repository-matching verl/vLLM-Omni pins. No new GPU or real multi-rank denominator validation was run for this repair. Historical GPU evidence below is retained separately, not relabeled as current-head validation.
This stacked PR targets
distillation-pr2-runtime, which is outside the CPU workflow'smain/v0.*base filter. The CPU/GPU evidence here is local validation, not remote CPU CI coverage.GPU evidence carried forward from the profiling worktree
These historical GPU runs preceded the previous branch-only fast-forward and were not repeated for it or for the current review fixes:
# QWEN_IMAGE_MODEL_PATH points to a prepared tiny Qwen-Image checkpoint. PYTHONPATH=. python -m torch.distributed.run --standalone --nproc_per_node=8 \ --module pytest -q tests/workers/test_distillation_fsdp_roles.py \ -k qwen_image_distillation CUDA_VISIBLE_DEVICES=0 PYTHONPATH=. python -m pytest -q \ tests/pipelines/test_qwen_image_dmd_request_batch.pyenrich_config()andstep_streaming()APIs.Exploratory performance, not a quality or isolated-speedup claim
Eight H20 GPUs, 1024×1024, four denoising steps and two fake updates. Means exclude the first two of six cycles; other GPU workloads remained running.
Physical batching and accumulation sampled different mean rollout exit depths. Sampling seeds were fixed, but fresh adapter initialization was not guaranteed identical. Combinations, statistical quality gains and isolated latency were not established. Original-DMD real-model throughput is not claimed. The installed vLLM-Omni Git revision matches
.github/vllm_omni_pin.txt; the alternative rc1 wheel was not independently validated.API and Usage Example
At eight data-parallel ranks, compare the existing accumulation path against physical batching at fixed effective batch 16:
Use micro-batch size 1 for the accumulation comparison. Inference request batching is separate from offline differentiable student rollout; start with a small request limit and measure memory.
Scope notes
AI assistance (OpenAI via pi) was used for implementation, review, and test construction. The human submitter confirmed reviewing every changed line, personally running relevant tests, and accepting responsibility for explaining and defending the implementation.
Review follow-up: naming propagation
Rebased onto the PR 1/PR 2 naming cleanup: stale
distillation.equations/distillation.control_planeimports andtrainer.control_planeaccessors were converted todistillation.utils/distillation.controllerandtrainer.controller; the fake-executor test field_fail_onbecame publicfail_on. Newly introduced state uses descriptive snake_case names; framework overrides and protocol dunders are unchanged.