Repository navigation
Support compact SD and complete video diffusion workflows - #538
Conversation
Performance Comparison
|
🏗️ Architecture Diff
t5 (seq2seq) / encoder — 14 change(s)Op summary: 71 → 81 nodes --- base
+++ head
@@ -32,6 +32,16 @@
Gather
Transpose
Unsqueeze
+CastLike
+Constant
+CastLike
+Sub
+Constant
+CastLike
+Mul
+Constant
+Unsqueeze
+Add
RMSNormalization
Transpose
MatMulAdded nodes:
Connectivity changes:
Legend: ⚪ No change · 🔵 Minor (attrs/inits) · 🟡 Moderate (nodes added/removed) · 🔴 Major (interface changed) |
There was a problem hiding this comment.
Pull request overview
This PR adds compact UNet support, encoder-only T5 export, and typed image/video diffusion workflows.
Changes:
- Supports UNets without mid-blocks and registers T5 encoder exports.
- Adds typed DDIM, casting, clamping, CFG, layout, caching, and recurrence components.
- Extends Diffusers configuration/building and nested artifact paths.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Review findings |
|---|---|
src/mobius/tasks/_t5_text_encoder.py |
Defines the T5 encoder task contract. No final comments. |
src/mobius/tasks/__init__.py |
Registers the T5 task. No final comments. |
src/mobius/models/unet.py |
Nit (2 votes): Add graph-build/parity coverage for mid_block=None. |
src/mobius/models/t5.py |
Moderate (3 votes): Apply attention_mask semantics. Nit (2 votes): Export and import T5EncoderModel. |
src/mobius/integrations/onnx_genai/workflow_metadata.py |
Critical (2 votes): Add rank-5 video dispatch and scheduler arguments. Critical (2 votes): Match history initializer dtype to timestep dtype. Critical (2 votes): Thread latent/VAE dtype through all video helpers. Nit (3 votes): Add runtime coverage for video CFG. |
src/mobius/integrations/diffusers/_configs.py |
Adds T5 and compact-UNet configuration support. No final comments. |
src/mobius/integrations/diffusers/_configs_test.py |
Configuration coverage. No final comments. |
src/mobius/integrations/diffusers/_builder.py |
Registers Diffusers components. No final comments. |
src/mobius/integrations/diffusers/_builder_test.py |
Builder registration coverage. No final comments. |
src/mobius/generation/_policy_components.py |
Nit (2 votes): Add runtime coverage for prediction_type="sample" with nontrivial alpha. |
src/mobius/generation/_policy_components_test.py |
Policy behavior coverage. No final comments. |
src/mobius/generation/__init__.py |
Exports policy components. No final comments. |
Suppressed comments (7)
src/mobius/generation/_policy_components.py:2062
- The
samplebranch computes epsilon by dividing bysqrt(1 - alpha). The video workflow's default DDIM schedule starts withalpha == 1.0, so its first sample-prediction step produces0/0and contaminates the latent. Handle the endpoint explicitly or reject schedules that make this conversion undefined, with a regression test for the default schedule.
pred_epsilon = op.Div(
op.Sub(sample, op.Mul(alpha_sqrt, pred_original)), beta_sqrt
src/mobius/integrations/onnx_genai/workflow_metadata.py:3739
- When
solver="ddim"and no schedule is supplied, this workflow falls back to[1, ..., 0]. The DDIM component interprets the schedule as cumulative alphas in denoising order, so the current alpha starts at 1 andalpha_prevdecreases, reversing the trajectory (the runtime tests use an increasing[0.4, 0.9, 1.0]schedule). Require explicit DDIM alpha/timestep schedules or materialize a valid increasing alpha schedule instead of using the generic fallback.
prediction_type: str = "epsilon",
guidance_scale: float | None = None,
src/mobius/integrations/onnx_genai/workflow_metadata.py:3837
- The new video CFG path checks only that a text encoder exists; it does not create the conditioning cast adapter that the image path uses. If the T5 output dtype differs from the denoiser's
encoder_hidden_statesdtype, both the negative and conditional invocations later in the loop receive an incompatible tensor contract. Mirror the image workflow's raw-conditioning plus cast component here, or reject mixed dtypes explicitly.
if guidance_scale is not None and (text_encoder is None or conditioning_output is None):
raise ValueError("video classifier-free guidance requires a text encoder")
src/mobius/integrations/onnx_genai/workflow_metadata.py:3739
prediction_typeis only passed to the DDIM component; Euler still consumes the raw denoiser output as an epsilon/derivative. Thussolver="euler"silently acceptssampleorv_predictionand integrates the wrong quantity (and even skips DDIM's value validation). Reject non-epsilonmodes for Euler or convert them using the scheduler before the Euler step.
prediction_type: str = "epsilon",
guidance_scale: float | None = None,
src/mobius/integrations/onnx_genai/workflow_metadata.py:3906
- This local is assigned but never read. It will trigger the repository's unused-variable lint rule and is not needed by the video workflow; remove it or use it for the intended request contract.
row_float = {"dtype": "float32", "rank": 1, "shape": [batch]}
src/mobius/integrations/onnx_genai/workflow_metadata.py:3708
- This parameter is honored by the direct image-edit writer, but the public
write_onnx_genai_config()image-edit branch does not forwardartifact_pathsfromkwargs; because that entry point accepts**kwargs, the option is silently ignored. Pass it through in the public branch and add an end-to-end metadata-path assertion.
artifact_paths: dict[str, str] | None = None,
src/mobius/tasks/_t5_text_encoder.py:38
- The task now requires
attention_mask, butT5Encoder.forward()ignores that argument and passes only the relative-position bias to every block. With padded prompt tokens, self-attention can read the padding and the encoder output diverges from the Hugging Face T5 encoder; wire the mask into the encoder attention bias (and add a padded-input parity test) before exporting this contract.
hidden_states = module(
builder.op,
input_ids=input_ids,
attention_mask=attention_mask,
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
Final catalogue validation: 9bdf315 makes image-edit output clamping cast BF16 decoder output to FP32 before Clip, avoiding ORT BF16 Less/Clip kernel assignment failure. Targeted policy/workflow tests: 77 passed. Real Qwen-Image-Edit-2509 generic workflow then passed end to end on CUDA. |
|
Review cleanup is complete at All 8 substantive review threads are resolved. Local targeted validation: 169 passed, 1 skipped; Ruff 0.16.2 format/lint and |
|
Rubber-duck blockers are fixed at
Regressions cover omitted image/video guidance, CLI forwarding, and FP16/BF16 output contracts. Targeted tests: 106 passed. Ruff 0.16.2 format/lint and |
|
Final pinned-revision blocker is fixed at
Validation: targeted auto-export/inference-metadata/ComfyUI/CLI suites: |
|
Final
Validation: targeted CLI/ComfyUI/auto-export tests |
|
Latest Conflict resolution preserved both sides: generalized arbitrary-rank typed output clamping (including float32 image-edit clamp output), main’s default rank-4 clamp API, explicit image/video guidance, canonical image value ranges, complete pinned revision propagation including Validation: focused CLI/ComfyUI/auto-export/inference/workflow/policy/value-range set |
Honor diffusers pipelines that explicitly omit the UNet mid block, as used by BK-SDM Small. Add an encoder-only T5 component and task so CogVideoX packages include their real prompt encoder without exporting an unused decoder. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Add typed DDIM prediction modes, video classifier-free guidance, tensor cast/clamp adapters, and shape-correct recurrence metadata so real Stable Diffusion and CogVideoX packages execute through ONNX GenAI. Tests: 76 policy and workflow metadata tests passed. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Declare a clamped image range for generic image APIs and allow canonical metadata to preserve existing nested ONNX artifact paths without moving or re-uploading large external-data weights. Tests: 76 policy and workflow metadata tests passed. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Cast configurable diffusion outputs to float32 before applying Clip so ONNX Runtime can execute BF16-decoder workflows such as Qwen Image Edit. Preserve the default same-dtype behavior and cover the BF16 graph load path. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Regenerate the canonical diffusion, guided diffusion, and video metadata fixtures after the output range and complete runtime contract updates. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Unify the tensor-cast policy added independently by main and the diffusion work, update image-edit expectations for the explicit output clamp, and apply current Ruff formatting to files introduced by the main merge. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Make CogVideoX workflow export structural and model-agnostic, materialize faithful DDIM schedules, and carry typed layout, cache, CFG, and VAE adapters through mixed-precision pipelines. Harden scheduler validation and DDIM sample prediction semantics. Also preserve image-edit artifacts, apply T5 padding masks, cover optional UNet mid blocks, export the T5 encoder publicly, and remove dead GGUF code. Add graph, metadata, and runtime tests for the corrected contracts. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Reject omitted guidance for image-edit and video exports instead of silently selecting unguided behavior, expose and forward the guidance scale through the build CLI, and retain explicit negative-conditioning CFG wiring. Publish image-edit output contracts from the float32 clamp output rather than the reduced-precision VAE decoder output. Add omission, CLI forwarding, FP16, and BF16 regressions. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Thread the requested Hugging Face revision through image-edit and ComfyUI scheduler resolution and through video and generic diffusion VAE scaling-factor reads. Extend the VAE config loader to pin Hub downloads and add regressions for each semantic lookup plus CLI forwarding. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Expose --revision on mobius convert-comfyui and pass the exact pinned revision into scheduler metadata conversion. Add a CLI-level regression that exercises argument parsing and verifies the conversion call. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
Preserve explicit integer and boolean output metadata for generated policy components after rebasing the diffusion workflow branch onto current main. This keeps generated ONNX GenAI fixtures semantically stable and formats the conflict-resolved files. Co-authored-by: Copilot <[email protected]> Copilot-Session: 39ff6824-d35f-4d3b-8f5f-043a7119a100 Signed-off-by: Justin Chu <[email protected]>
d57234e to
789bd76
Compare
Preserve the force-pushed head as backup/catalogue-diffusion-builds-789bd76c, then merge origin/main at c047f77 without rebasing. This restores current MTP and metadata changes while retaining the approved diffusion guidance, clamp dtype, revision propagation, and canonical workflow behavior. Replace the stale GGUF CLI rejection regression with the current supported ort-genai dispatch contract; that contradictory test caused all six Python unit matrix failures after the branch rewrite. Co-authored-by: Copilot <[email protected]> Signed-off-by: justinchuby <[email protected]>
|
Branch restoration is pushed at Root cause evidence: GitHub recorded a Restoration: merged current Validation: GGUF suites |
|
CI update for |
Summary
Validation