Skip to content

Studio: keep MiniMax-H3's streamed top-level group on the card between denoise steps - #15796

Merged
danielhanchen merged 5 commits into
mainfrom
studio-h3-stream-step
Oct 28, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
studio-h3-stream-step

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

On a 12 GB card MiniMax-H3 streams its whole int8 denoiser, including the 0.8 GB top-level group (embeddings, norm_out, proj_out). That group runs from the first block to the last, so it was offloaded at the end of every forward and uploaded again at the start of the next. The compute stream then waited for the whole copy, about 65 ms per step on an A100, plus another 26 ms for block 0, which could not be prefetched while the top-level group filled the window.

H3's modular pipeline has no callback_on_step_end, so the cross-forward carry (#15108) never armed for it. This PR:

  • drives the carry from the scheduler.step wrapper H3 already uses for progress (_scheduler_step_carry, gated by _h3_carry_by_scheduler), and disarms and drops anything carried at decoder entry as a backstop;
  • adds keep_first to the H3 prefetcher. When the group that opens the recorded order also closes the forward, it stays on the card into the next forward, which starts with it anyway. Everything else (window, decode drop, interleave and capture checks) is the existing carry logic.

On its own, the carry did nothing for H3. When the top-level group is offloaded, the forward's compute is already finished, so its re-upload still sat on the critical path. That measured 4.868 / 4.871 s/step against 4.868 / 4.869 for base. Keeping the group on the card is what removes the wait.

Kill switch: UNSLOTH_H3_STREAM_CARRY=0 (turns off both the carry and the keep).

Profile (main 85744ff385, Colab A100-SXM4-40GB, PCIe gen4 x16, 960x544x124, 20 steps)

Measured with CUDA events around each prefetch wait and copy, torch.cuda.set_sync_debug_mode("warn"), and a torch.profiler trace of one warm forward:

16 GiB 12 GiB
resident / streamed groups top + 8 blocks / 42 0-1 / 50 + top
H2D per forward 16.3 GB, 1.33 s at 12.3 GB/s (pinned) 20.3 GB, 1.64 s
copy overlapped with compute 98% 94%
compute stall on copies per warm forward 0.1 ms 92 ms (top group 65 ms + block 0 26 ms)
compute-stream idle per forward (trace) 18 ms 29 ms
host syncs inside a warm forward 0 0
empty_cache / allocator segment frees per warm forward 0 / 0 0 / 0

There is one forward per step. At 16 GiB, streaming is free once the blocks are pinned: 4.776-4.793 s/step against 4.789 fully resident on the same card. With pinning off (UNSLOTH_DIFFUSION_GROUP_OFFLOAD_PIN=0, which reproduces the log lines of a host with 0 MiB pinnable), the same cell runs at 4.936 s/step (+3.3%). That matches the +3% the Oct 27 benchmark measured at 16 GB on a host whose pin budget was 0, which #15642 addresses.

Results (same VM, interleaved base / head processes, 12 GiB ballast + total cap)

arm warm s/step (2 renders) warm end-to-end (render 2 / 3)
base (3 processes) 4.868 4.869, 4.874 4.868, 4.877 4.872 108.6 103.2, 107.1 103.1, 108.7 103.2 s
head (3 processes) 4.805 4.794, 4.804 4.798, 4.817 4.802 106.9 101.1, 104.7 101.8, 107.9 101.9 s
head, UNSLOTH_H3_STREAM_CARRY=0 4.872 4.870 108.3 102.3 s
  • Warm s/step: base 4.871 vs head 4.803 (-1.4%). The A/A spread of the base process means is 0.006 s, the head spread 0.010 s, and the delta is 0.068 s.
  • On the head, the 12 GiB cell's per-step time is within 0.3% of the fully resident one (4.78-4.79).
  • Compute stall per warm forward goes from 92 ms to 21 ms (profiled head arm). H2D per forward goes from 20.25 to 19.45 GB.
  • 16 GiB (top-level group resident, nothing to keep): base 4.788, head 4.793 s/step. Frames are identical.
  • Warm renders are bit-identical, head vs base, in 6 of 6 pairs, plus the 16 GiB pair and the kill-switch arm. The first (cold) render of a process alternates between two outputs on main itself: base vs base differs at 38.2 dB, and head vs base pairs either match exactly or show the same 38 dB variant.
  • Peak VRAM per render is unchanged (NVML over base: 11339-11341 / 10981 MiB on both). Inside a forward, max_memory_allocated is 7311 MiB on both: the kept group is what the next forward starts with.
  • Peak host RAM is unchanged (62.9-63.3 GB cell peak on both).
  • 0 OOM, 0 Recompiling function lines (TORCH_LOGS=recompiles) in every arm.
  • Engagement: every head render logs video.h3_stream_carry: 34 carried copies read across forwards. The kill-switch arm logs none.

Tests

  • New tests/test_h3_stream_carry.py (18 tests). They cover H3's loop shape (20 forwards, 19 scheduler.step calls), one call per step, too few calls (dropped at decode), cancel, the gate (family, streamed, step callback, env), the kill switch, the top-level group kept and uploaded once per render while blocks still stream, and release on an aborted render. With the scheduler-driven step, the decode drop or the keep reverted, 2, 1 and 1 of them fail.
  • Prefetch, cross-forward, H3 stream and residency tests (21 files): base 1200 passed / 3 failed, head 1218 passed / 3 failed. The same 3 test_diffusion_multigpu.py IDs fail on both.

Not covered

  • Only an A100 (PCIe gen4) was measured. The RTX 6000 Ada and the RTX 3090 (PCIe 3.0 x4) from the benchmark were not available, so the 3090 streaming gap is not measured here.
  • This PR does not show that the benchmark host now pins. Studio diffusion: the pin budget credits clean mapped page cache inside a capped cgroup #15642 targets that, and Colab has no capped cgroup to reproduce it.
  • Block 0 still waits about 21 ms per forward at 12 GiB. Its copy can only start once the last block is done without raising the window above the forward-start footprint.
  • The render after a residency re-fit (1 block resident, then 0) still runs its first forward without prefetch: 48 misses, about 1.2 s once. This PR does not change that.

H3's modular pipeline has no step callback, so the cross-forward carry
never armed and every forward of a fully streamed denoiser (12 GB cards)
waited on its 0.8 GB top-level group and its first block. Drive the carry
from the scheduler.step wrapper H3 already uses for progress, and drop
anything carried at decode entry. UNSLOTH_H3_STREAM_CARRY=0 turns it off.
…n denoise steps

The top-level group runs for the whole forward, so a carry issued at its
offload still waited for the forward to finish: every 12 GB step paid its
0.8 GB upload (65 ms on an A100). The H3 prefetcher now keeps that group
into the next forward, which starts with it anyway, and drops it with the
rest of the carry.
@danielhanchen danielhanchen self-assigned this Oct 28, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T15:00:28.743452Z 71fd65a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 71fd65acaf

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@danielhanchen
danielhanchen merged commit c4c785c into main Oct 28, 2026
39 of 43 checks passed
@danielhanchen
danielhanchen deleted the studio-h3-stream-step branch October 28, 2026 17:12
danielhanchen added a commit that referenced this pull request Oct 28, 2026
## Summary

UI jobs fail on unrelated PRs when a llama.cpp, whisper.cpp or audio.cpp
release is published mid-run. The prebuilt the job just installed
becomes one behind, and Studio shows its update card in the bottom-right
overlay rail, over the controls the scripts click:

- **Windows UI lane** (the `Chat UI Tests` staging run for #15796, on
current main `56278f5f65`): `FAIL in step "turn 3: 'Reply with exactly:
world'"`, `Locator.click` on `button[aria-label="Send message"]` times
out because the card's button row (`components/llama-update-banner.tsx`)
intercepts the click.
- **UI parity null control** (`Merge base vs itself, the null` on #15798
/ #15799): one cell times out the same way.

`UNSLOTH_DISABLE_UPDATE_CHECK=1` already keeps the card down: with it
set, `get_update_status` never reports an update
(`utils/update_status.update_checks_disabled`), and
`test_studiobench_ci_update_checks_off.py` already requires it, but only
for two named workflows (`studiobench-ci.yml`, `studio-ui-smoke.yml`).
The Windows and Mac UI smokes, the parity arms, inline images, composer
compatibility and the frontend browser jobs never set it.

#15805 muted the notifications in studiobench's browser seed; this
covers every browser lane at the backend, including the Playwright
scripts that seed nothing.

## Change

- `UNSLOTH_DISABLE_UPDATE_CHECK: '1'` at job level in every job that
installs Playwright's browsers or runs studiobench:
`studio-windows-ui-smoke` / `studio-mac-ui-smoke` `ui-smoke`,
`studio-ui-smoke` `ui-indicator`, `studiobench-ui-parity` `arms` /
`verdict`, `studiobench-ci` `selftests`, `studio-inline-images`
`images`, `studio-composer-compatibility` `composer`,
`studio-frontend-ci` `build` / `windows`. Jobs without a real Studio
backend are unaffected by it.
- `tests/studio/test_studiobench_ci_update_checks_off.py` now discovers
those jobs across all workflows (installs Playwright browsers, runs
studiobench, or boots Studio for Playwright) instead of checking two
named files, so a new UI lane cannot ship without the switch. A `KNOWN`
set of five lanes fails the guard if discovery stops recognising them.
The step-level override check and the backend-name check are unchanged.

No update-flow lane is touched: `studio-update-smoke` /
`studio-windows-update-smoke` do not drive a browser, and
`playwright_update_banner_layout.py` (Mac UI smoke) stubs
`/api/llama/update-status` and `/api/studio/update-status` with
`context.route`, so it does not depend on the backend's check.

## Testing

- The guard: 14 passed with this change; against main's workflows it
fails for all 10 uncovered jobs, the Windows UI lane and parity arms
included.
- All 124 test files that read `.github/workflows`: main and this branch
fail the same single test
(`test_cached_paths_hold_no_credentials.py::test_model_cache_variables_are_not_treated_as_credential_homes`,
pre-existing on this host); 6058 passed on main, 6069 here (the new
parametrized cases).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant