Repository navigation
Studio: stop the first Wan2.2-A14B render from waiting for the second expert's pin - #15906
Merged
Merged
Conversation
A returning load pins both experts and the text encoder from disk in parallel, and the first render waited for all of them (47.8 s on an A100 at 16 GiB). The low-noise expert first runs after the high-noise steps, so it now pins after the other pinners finish and the render waits only for those; its group onloads still wait for their own pins. UNSLOTH_VIDEO_LATE_EXPERT_PIN=0 restores the old wait.
…bound On a G4 the three pinners finish in 4.3 s; chaining the second expert behind the others and overlapping it with the render moved its register cost into the encode (+1.1 s on the first clip). The late pinner now joins the others once their combined rate passes 3 GiB/s, and the render then waits for it.
The group-granular count kept a fast host's late expert idle for about a second (G4: +0.25 s pre-render wait). Count bytes as each registered copy completes and decide after 0.2 s.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This was referenced Oct 29, 2026
danielhanchen
added a commit
that referenced
this pull request
Oct 29, 2026
… a fresh process (#15912) The `(Python 3.13, a-f)` shard on #15906's staging run failed one test the PR does not touch: ``` tests/test_diffusion_comfy_block.py:979: in test_int8_fp8_dequant_is_checked_for_its_float32_peak assert seen and max(seen) >= 0.9 * growth, (seen, growth) E AssertionError: ([201326592], 237703168) ``` The test passes on main and on #15906's head when run on its own. ## Cause This is the flake #14579 already fixed for `test_block_dequant_is_checked_for_its_peak_intermediates`. RssAnon is process-wide, and in a long-lived xdist worker it carries whatever earlier tests left behind. #14579 moved that test into a fresh process, with a `malloc_trim` baseline and the best of three. Two siblings in the same file kept measuring in the worker: `test_int8_fp8_dequant_is_checked_for_its_float32_peak` and the peak half of `test_swap_nibbles_is_bit_identical_and_checked_for_its_peak`. The CI reading shows how far off a worker reading can be. Measured on its own, the int8 ConvRot dequant grows by about two thirds of what it charges. The worker saw 237.7 MB against the 201.3 MB charge. ## Fix Both now run through the same kind of fresh-process probe as #14579 (`_HOST_PEAK_PROBE`, driven by `_host_peak_in_a_fresh_process`). The assertion is unchanged: the charge must cover at least 90% of the measured peak. The bit-identity half of the nibble-swap test still runs in process. `_rss_anon_now`, now unused, is removed. ## Verification Charge over measured growth in the fresh process, three runs each: | op | charge / growth | |---|---| | int8 ConvRot dequant | 1.50, 1.50, 1.50 | | fp8 dequant | 1.031, 1.035, 1.048 | | nibble swap | 1.179, 1.027, 1.097 | Each case stays above the 0.9 the test requires. - `test_diffusion_comfy_block.py`: 55 passed, 5 skipped (CUDA-only), serially and under `-n 8`. - Sabotage: undercharging `_dequant` (`codes.numel() * 4` instead of the float32 intermediates) fails both `float32_peak` cases in the fresh process.
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.
Studio: stop the first Wan2.2-A14B render from waiting for the second expert's pin
Problem
When a user comes back to Studio and loads Wan2.2-T2V-A14B again, the load itself is quick (about 22 s on an A100). The first render then sits for 47.7 s before encoding starts (
pre_s) and logsvideo.generate: waited 47.6 s for the host weights to finish pinning.On this path the streamed weights are pinned in the background after the load returns. Three pinners start together, all copying from the prequant cache files on disk:
transformer(13.2 GiB)transformer_2(13.2 GiB)VideoBackend.generatethen callsfinish_background_pinsand waits for all three. A cold Colab A100 disk delivers about 0.74 GiB/s in total, so both experts finish at 48 s. The low-noise expert is not used until the high-noise steps are done, so nothing needs it that early.ComfyUI does not pin up front at all. Each expert is loaded and pinned when its own sampler first runs. On the same A100 its first clip takes 107 s, against 124.4 s for Studio.
Change
defer_late_expert_pinsmarks thetransformer_2pinner of a two-expert (is_moe) family as late. The late pinner starts only after the encoder and first-expert pinners finish, so those two get the disk to themselves.finish_background_pins(..., include_late=False)) waits only for those two pinners. The second expert pins during the encode and the high-noise steps. Each of its offload groups still waits for its own pin before it onloads, through the existinginstall_group_pin_waithook, so no group ever streams from a host copy that is being swapped.UNSLOTH_VIDEO_LATE_EXPERT_PIN=0restores the old behaviour, where all pinners run in parallel and the render waits for every one.Results
Wan2.2-T2V-A14B, 832x480, 33 frames, 10 steps, CFG 3.5, int8 denoiser, fp8 text encoder.
Setup:
cf80abd639(main). Head is this branch.A100-SXM4-80GB, Colab high-RAM, final code:
RTX PRO 6000 Blackwell (G4), Colab:
Both are fixed by the per-tensor probe here.
Accuracy:
Engagement:
diffusion.memory: 1 late expert(s) (13.2 GiB) pin after the other 2 pinner(s) (22.3 GiB); the first render waits for those only.onloads waited 0.0 s.host weights pin at N GiB/s; WanTransformer3DModel pins beside the others.pre_sgoes back to 47.6 s.Tests
studio/backend/tests/test_video_late_expert_pin.py. It covers:test_group_offload_background_pin,test_video_fast_pin,test_video_encoder_exact_pin,test_h3_background_block_pinandtest_video_native_cache_background.Not covered
is_moepath but was not run.