refactor(diffusion): centralize sampling and replay loops - #29
Draft
leviking98z-rgb wants to merge 2 commits into
Draft
refactor(diffusion): centralize sampling and replay loops#29leviking98z-rgb wants to merge 2 commits into
leviking98z-rgb wants to merge 2 commits into
Conversation
2 tasks
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
DiffusionRunnerandVideoDiffusionRunnerimplementations for schedule validation, initial-latent handling, sparse trajectory capture, sampling, replay, autocast/precision policy, single-step prediction, and the default trainable surfaceunirl/models/diffusion/, while retaining the pre-existingunirl.models.types.diffusionandunirl.models.types.replay_resultpaths as compatibility facadesThe layer is a net reduction of 1,667 lines against
refactor/model-plugin-sdkwhile retaining concrete stage dotpaths and public stage methods.Related Issue
Related to Tencent-Hunyuan#285.
Test Plan
SKIP=no-commit-to-branch pre-commit run --all-files --show-diff-on-failurepython lint/check_framework_contracts.pypython lint/check_architecture_boundaries.pypython lint/check_experimental_boundaries.pypython lint/check_recipe_targets.pypython -m compileall -q unirl lint experimental/refl/models/types.pyunirl.models.diffusionexports and the two retainedunirl.models.typescompatibility facades resolve to the same classesNoiseRecipe, Boogu CFG-range/RoPE cache, and Flux replay mode restoration passedFlowSDEStrategyharness: serial and one-forward batched replay produced identical log-probs and previous-sample meansexamples/**/*.yamlrecipes composed and resolvedCompatibility / Risk
_target_path, checkpoint, dataset, request, orLatentSegmentformat changes.diffuse,replay,predict_noise_at_step, andtrainable_modulesurface from the runner. HI3 additionally accepts the common optionalinitial_latentsargument.unirl.models.types.diffusionandunirl.models.types.replay_resultremain valid. The temporaryunirl.models.types.diffusion_runnerpath existed only inside this unmerged Draft stack and is replaced by the canonicalunirl.models.diffusionpackage.bundle.device; this preserves existing SD3/Z-Image/Boogu dedicated-engine behavior and makes the same CPU-returned trajectory path available to the other ordinary stages.modality=VIDEOfactory. BAGEL and LTX2 retain their specialized runners.refactor/model-plugin-sdk; review commits317d698and747f112for this layer.Reviewer Notes
unirl/models/diffusion/contracts.py,unirl/models/diffusion/runner.py, one image hook set, one video hook set, HI3, thenlint/check_framework_contracts.py.models/diffusionlocation is intentionally scoped to model-facing contracts and shared model execution. Sampling parameters remain underunirl/types, SDE math remains underunirl/sde, and training orchestration remains outside the model layer._replay_batchedis the integration seam, and a future rebase must retain the Qwen/Z/Flux fast paths from perf(diffusion): extend batched-step replay to qwen_image, z_image, flux2_klein Tencent-Hunyuan/UniRL#156. Upstream fix(fastvideo): use UniRL canonical UniPC strategy Tencent-Hunyuan/UniRL#251 touches WAN 2.1 timestep/FastVideo behavior and must likewise be preserved when rebasing. No open upstream PR provides a generic sampling/replay runner.tests/replacement tree.Checklist