Skip to content

trtllm diffusion: dual guidance (guidance_scale_2 / boundary_ratio) for Wan 2.2#25

Draft
Johan-de-R wants to merge 3 commits into
deep-main-v1.1.1-videogenfrom
johan/wan22-t2v-visualgen
Draft

trtllm diffusion: dual guidance (guidance_scale_2 / boundary_ratio) for Wan 2.2#25
Johan-de-R wants to merge 3 commits into
deep-main-v1.1.1-videogenfrom
johan/wan22-t2v-visualgen

Conversation

@Johan-de-R

@Johan-de-R Johan-de-R commented Jul 23, 2026

Copy link
Copy Markdown

What

Two changes to the TRT-LLM diffusion (VisualGen) backend so deepinfra can serve Wan-AI/Wan2.2-T2V-A14B:

  1. Dual guidance — so Wan 2.2 A14B can run its two-expert MoE guidance (e.g. 4.0 / 3.0 at boundary 0.875). The worker previously exposed only a single --default-guidance-scale; guidance_scale_2 / boundary_ratio (Wan extra_param_specs) defaulted to None → single guidance.
  2. Default the video response to inline b64_json — the video handler defaulted response_format to "url" (upload to media_output_fs_url, return a file reference). deepinfra's deepapi reads the clip from data[0].b64_json and never sends response_format, so it got no video (ERR_MODEL "No video data"). Now defaults to b64_json; callers can still pass response_format="url" explicitly.

Changes

  • configs/diffusion_config.py + backend_args.py: default_guidance_scale_2 / default_boundary_ratio fields + --default-guidance-scale-2 / --default-boundary-ratio flags (both default None).
  • engines/diffusion_engine.py: generate() injects them into req.params.extra_params before the spec-default merge, so they override the None spec default.
  • request_handlers/diffusion/video_handler.py: forwards the guidance config defaults (config-only — the /v1/videos nvext doesn't carry them); and defaults response_format to b64_json.

Both guidance defaults are None, so Flux and single-guidance Wan are unaffected. The b64_json default only changes behavior when a caller omits response_format (deepinfra's case).

Why

deepinfra is serving Wan-AI/Wan2.2-T2V-A14B on this backend; goff (4.0/3.0) tested more coherent than single guidance. Paired backend PRs: deepinfra/backend#3759 (infra plumbing) + ai-dynamo#3717 (deepapi cutover).

Validation

py_compile clean. Correction to an earlier claim: the b64 default did break test_default_response_format_is_url (it asserted upload_to_fs was called and data[0].url was set) — rewrote it to test_default_response_format_is_b64_json, and added test_guidance_defaults_forwarded_to_engine (the guidance forwarding had no coverage). The dynamo suite runs in CI (pytest 8.0); it isn't runnable in the backend's di-main env, so these are py_compile-verified + correct-by-construction (mirror the existing handler tests). End-to-end serving smoke to be re-run after the worker image is rebuilt with these changes.

🤖 Generated with Claude Code

…onfig

Wan 2.2 A14B is a two-expert MoE that needs dual guidance (e.g. 4.0/3.0 with a
0.875 timestep boundary). The diffusion worker only exposed a single
--default-guidance-scale; guidance_scale_2 / boundary_ratio (Wan extra_param_specs)
defaulted to None => single guidance. Add:

- DiffusionConfig.default_guidance_scale_2 / default_boundary_ratio + the CLI flags
  --default-guidance-scale-2 / --default-boundary-ratio (backend_args).
- DiffusionEngine.generate() injects them into req.params.extra_params BEFORE the
  spec-default merge so they take effect.
- video_handler forwards the config defaults (config-only; the /v1/videos nvext
  doesn't carry them).

Both default to None, so existing models (Flux, Wan single-guidance) are unaffected.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Johan-de-R
Johan-de-R deployed to external_collaborator July 23, 2026 16:29 — with GitHub Actions Active
The video handler defaulted response_format to "url", which uploads the clip to
media_output_fs_url and returns a file reference. deepinfra's deepapi reads the
video from data[0].b64_json and never sends response_format, so it received no
video (ERR_MODEL "No video data"). Default to b64_json so the clip is returned
inline; callers can still pass response_format="url" explicitly.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Johan-de-R
Johan-de-R had a problem deploying to external_collaborator July 24, 2026 21:46 — with GitHub Actions Failure
…ver guidance forwarding

The b64_json default change flipped VideoGenerationHandler's default from "url"
to "b64_json", which broke test_default_response_format_is_url (it asserted
upload_to_fs was called and data[0].url was set). Rewrote it to
test_default_response_format_is_b64_json (no upload; data[0].b64_json set) so the
new default is pinned.

Also added test_guidance_defaults_forwarded_to_engine: the handler must forward
config.default_guidance_scale_2 / default_boundary_ratio to engine.generate()
(dual guidance isn't carried in the /v1/videos nvext) -- the core of this PR had
no test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Johan-de-R
Johan-de-R had a problem deploying to external_collaborator July 25, 2026 03:57 — with GitHub Actions Failure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant