Repository navigation
feat: expose cache_dit threshold / max-continuous / Wan 2.2 low-noise budget - #56
Merged
Johan-de-R merged 2 commits intoOct 22, 2026
Merged
Conversation
…2.2 low-noise budget Adds --cache-dit-residual-diff-threshold, --cache-dit-max-continuous-cached-steps and --cache-dit-low-noise-max-cached-steps (env DYN_TRTLLM_CACHE_DIT_*). Unset keeps VisualGen's defaults (CacheDiTConfig() unchanged). On Wan2.2-T2V-A14B the low-noise expert reuses exactly 20 of its 34 steps in production: VisualGen's hard-coded budget (_WAN22_LOW_NOISE_MAX_CACHED_STEPS = 20), not the similarity test, decides the last ~4 full computes. With the compile-in-place image, budget 24 + threshold 0.32 measured 188.8 s vs 229 s per clip on 1xB200 (6 prompts), LPIPS 0.066 vs the uncapped output and 0.165 vs the full 50-step output (uncapped: 0.160). With max-continuous 4 and budget 26: 168.6 s, 0.088 / 0.177. The low-noise budget is applied by setting VisualGen's module constant before the pipeline loads; a TensorRT-LLM without that constant raises instead of silently ignoring the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Johan-de-R
had a problem deploying
to
external_collaborator
October 21, 2026 23:15 — with
GitHub Actions
Failure
Review feedback on #55: '720*1280' or '720x1280x81' raised a bare 'too many values to unpack' at worker start. Both warmup parsers now raise a ValueError that names the flag and shows the expected format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Johan-de-R
had a problem deploying
to
external_collaborator
October 22, 2026 02:22 — with
GitHub Actions
Failure
Johan-de-R
changed the base branch from
johan/wan22-compile-inplace-warmup-shapes
to
deep-main-v1.1.1-videogen
October 22, 2026 02:23
temirulan
approved these changes
Oct 22, 2026
temirulan
left a comment
There was a problem hiding this comment.
Approving. I checked the change against upstream TRT-LLM v1.3.0rc14 source, and it does what the description says.
What I verified
- The low-noise budget override takes effect.
_WAN22_LOW_NOISE_MAX_CACHED_STEPSis a plain module global incache/cache_dit_enablers.py.enable_cache_dit_for_wan()reads it when it is called, in the secondParamsModifier. It is not bound as a default argument or imported by name elsewhere._build_diffusion_args()sets it beforePipelineLoaderrunspost_load_weights(), so the dual-expertBlockAdapterpicks up the new value. Thehasattrguard means a TRT-LLM that renames the constant fails loudly instead of silently ignoring the flag. - The threshold and max-continuous flags map to real
CacheDiTConfigfields. These areresidual_diff_threshold(ge=0, default 0.24) andmax_continuous_cached_steps(ge=-1, default 3). Pydantic still validates both. They feed the sharedDBCacheConfig, so they apply to both experts. - Unset flags keep today's behaviour. Each override is dropped when it is
None, so the default path is stillCacheDiTConfig()with no kwargs, and the module constant stays at 20. - The #55 nit is fixed. Malformed warmup shapes now raise an error that names the flag, and a trailing comma (
81,) is rejected too.
Non-blocking nits
--cache-dit-low-noise-max-cached-stepsis only applied inside thecache_backend == "cache_dit"branch. It is also only read by the Wan 2.2 dual-transformer enabler. Setting it with another backend, or on Wan 2.1, FLUX or LTX2, is silently ignored. A warning would keep a misconfigured model-CD arg from going unnoticed.- Unlike the other two flags, the budget has no range check:
-1means unlimited in cache_dit, and other negative values pass through as they are. A>= -1check would matchCacheDiTConfig's convention.
On quality: an LPIPS of 0.066 against #55 output is inside the ~0.08 run-to-run noise you measured, and the 12-clip review at budget 24 backs that up. The rollout values look reasonable.
I couldn't run the tests locally because they need the dynamo.llm Rust extension. I'm relying on your 38/38 result from the #55 image.
This branch had an error being 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.
Follows #55 (merged). Also carries #55 review nit 1: a malformed
--warmup-resolutions/--warmup-num-framesnow raises an error naming the flag (925595e).What
Three optional flags, unset = today's behaviour (
CacheDiTConfig()with VisualGen defaults):--cache-dit-residual-diff-threshold(envDYN_TRTLLM_CACHE_DIT_RESIDUAL_DIFF_THRESHOLD)--cache-dit-max-continuous-cached-steps(envDYN_TRTLLM_CACHE_DIT_MAX_CONTINUOUS_CACHED_STEPS)--cache-dit-low-noise-max-cached-steps(envDYN_TRTLLM_CACHE_DIT_LOW_NOISE_MAX_CACHED_STEPS): Wan 2.2's low-noise expert budget, hard-coded to 20 in VisualGen. Set on VisualGen's module constant before load; a TRT-LLM without it raises.Why
In production the low-noise expert reuses exactly 20 of its 34 steps: the budget, not the similarity test, forces the last ~4 full computes. Measured on 1x B200 with the #55 image (6 prompts, fixed seeds):
Two identical runs with separate compile caches differ by ~0.08 LPIPS. 12-prompt side-by-side review on the shipped image: budget 24 = 185.6 s/clip, LPIPS 0.018 vs production (11/12 clips <= 0.02); Johan saw one neutral difference. Rolling out to Wan2.2-T2V-A14B with
--cache-dit-low-noise-max-cached-steps=24 --cache-dit-residual-diff-threshold=0.32(image...-swenc-abe8c4ee, built from abe8c4e).Tests
TestCacheDitOverrides: unset flags callCacheDiTConfig()with no kwargs and leave the budget at 20; set flags reachCacheDiTConfigand the module constant; unknown TRT-LLM raises. 38/38 non-handler tests pass in the #55 image (handler tests needpytest_asyncio, absent from the runtime image).🤖 Generated with Claude Code