Repository navigation
Studio: quantise an offloaded native int8 denoiser on the card, one linear at a time - #15936
Merged
Merged
Conversation
…ar at a time A fresh-home Wan2.2-A14B load at a 16 GiB budget staged only part of each expert on the card and quantised the rest on the host (66 s of host ConvRot and int8 packing, plus 17 s of block staging). Under offload every host-resident Linear is now uploaded through a pinned buffer, built with the same kernels a staged layer uses, and downloaded again. Kill switch: UNSLOTH_NATIVE_QUANT_ON_DEVICE=0.
[skip ci]
Member
Author
|
@codex review |
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. |
|
Codex Review: Didn't find any major issues. Hooray! 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". |
danielhanchen
marked this pull request as ready for review
October 29, 2026 10:23
danielhanchen
added a commit
that referenced
this pull request
Oct 29, 2026
…Grouper CUDA test on a real card (#15948) ## Summary Two more checks are red on main itself, so every PR based on it today inherits them (seen on staging for #15859 and #15936, neither of which touches these files): 1. `tests/security/test_lint_risky_loaders.py::test_the_tree_matches_the_baseline` (workflow-trigger lint): ``` 1 risky loader call site(s) not in the baseline: unsloth/import_fixes.py:1040 [dynamic-import] import_module ``` #15850 added a fourth `importlib.import_module(module_name)` in `unsloth/import_fixes.py` (the torchao import-time probe). The baseline keys a call on its source text, so the existing entry for that text (count 3) now sees 4 and reports the overflow at the first site. The new call iterates the fixed `_TORCHAO_IMPORT_TIME_MODULES` tuple, so it is the same trusted shape as the other three. The product is fine; the baseline needed the count and the reason updated. 2. `tests/python/test_accelerator_skip_guards.py::test_no_skip_guard_reads_a_spoofable_accelerator_probe` (Repo tests, CPU): ``` test_prefix_grouper_layout.py:199: torch.cuda.is_available() ``` #15835 added `test_cuda_layout_reads_the_device_once_and_copies_once` gated on `torch.cuda.is_available()`, which `tests/_zoo_aggressive_cuda_spoof.py` patches to `True` process-wide, so on a CPU runner sharing a session with the compat suites the test un-skips and calls `.cuda()`. Here the guard is right and the new test was wrong: it now gates on `has_real_cuda()` like the other CUDA-only tests. ## What changed - `scripts/risky_loaders_baseline.json`: the `59e72c01edb14c86` entry goes from count 3 to 4 (regenerated with `scripts/lint_risky_loaders.py --update`, only that line moved), and its reason names `_TORCHAO_IMPORT_TIME_MODULES` beside the other fixed tables. - `tests/test_prefix_grouper_layout.py`: `skipif(not has_real_cuda(), ...)` instead of `skipif(not torch.cuda.is_available(), ...)`. ## Verification - Base (main at `a4aee21490`): both tests fail as above. - Head: `test_lint_risky_loaders.py`, `test_accelerator_skip_guards.py` and `test_prefix_grouper_layout.py` give 75 passed, 1 skipped on a CPU-only run. - On a real GPU (torch 2.13 + CUDA 13.0) all 6 PrefixGrouper tests run, including the CUDA one, so the new gate does not skip it on real hardware. - Each guard still fails without its fix: putting `torch.cuda.is_available()` back makes the skip-guard test fail, and putting the baseline count back to 3 makes the loader lint fail.
danielhanchen
added a commit
to unslothai/unsloth-zoo
that referenced
this pull request
Oct 29, 2026
…nch (#2245) ## Summary `tests/test_triton_fp_fusion.py::test_every_launch_states_fp_fusion` fails on main since #2236: ``` AssertionError: ['gpt_oss_decode_fused.py:364:_rope_decode_kernel expected True'] ``` It is also what turns the unsloth `Core zoo` jobs red on every unsloth PR that installs zoo main (seen on staging for unslothai/unsloth#15936). #2236 launches the new `_rope_decode_kernel` with `**_NO_FMA` (`enable_fp_fusion=False`) on purpose: the kernel replaces the compiled `apply_rotary_pos_emb` region and `tests/test_gpt_oss_rope_decode.py` checks it against that region bit for bit, which needs each multiply rounded before the add, the same reason `_add_rms_norm_kernel` and `_sink_scale_kernel` in the same module already disable contraction. The product is right; the guard just did not know this launch is one of the deliberate ones. ## What changed `gpt_oss_decode_fused.py:_rope_decode_kernel` joins `_DELIBERATE_FALSE`, with the reason beside it. ## Verification - Base (main at `8c8b40eb`): 1 failed (`_rope_decode_kernel expected True`). - Head: 1 passed, 2 skipped (the 2 skips need a GPU). - The guard still bites on this launch: - launch changed to `enable_fp_fusion = True`: fails with `_rope_decode_kernel expected False` - `**_NO_FMA` removed from the launch: fails with `Triton launches without enable_fp_fusion: [..._rope_decode_kernel]`
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: quantise an offloaded native int8 denoiser on the card, one linear at a time
Problem
The first Wan2.2-T2V-A14B load in a new Studio home, with the DiT offloaded (16 / 12 GiB budget), builds the int8 experts from the dense Wan-AI shards. On a Colab A100-80 high-RAM VM that load takes 268-273 s, and the first clip takes 362-367 s.
About 86 s of that load is the int8 build:
_stage_denoiser_for_quantmoves whole blocks onto the card until the staging budget is used up. At 16 GiB that is 13.2 of the 28.6 GB per expert, and at 12 GiB it is 8.3 GB.apply_native_weight_quantthen runs on every Linear wherever it sits, so the remaining blocks go through the ConvRot rotation and int8 packing on the host CPU. In a py-spy profile that is 66 s of host work: the fp32 rotation matmul, amax, divide / round, and thefloat()cast.On a smaller budget less fits, so the host share and the load time both grow: 282.8 s at 12 GiB.
Change
video.pyskips the block staging. It runs the quant insidequantise_host_linears_on(device).apply_native_weight_quantbuilds each host-resident Linear on the card, one at a time:NativeWeightOnlyLinearis built on the card with the same kernels a staged layer uses;diffusion.transformer_quant: built 403 host linear(s) on cuda one at a time (28.5 GB in 9.4 s).UNSLOTH_NATIVE_QUANT_ON_DEVICE=0restores the staged plus host build.Results
Setup:
9258bfc732(main). Arms were interleaved S F F S S F.built 403 host linear(s) on cuda one at a timetwice;quantising on cuda with 13.2 of 28.6 GB of the DiT staged thereinstead.Accuracy
The quant algorithm is not changed. Only the device that runs it changes for the layers main did not stage. These checks compare the native prequant cache entries (per-tensor sha256 and an element diff) and the rendered frames:
Tests
studio/backend/tests/test_video_native_quant_on_device.py(14 tests). It covers:test_diffusion_native_quant.py::test_unpinned_torchao_host_copy_is_a_distinct_wrapper_over_the_same_data;test_diffusion_native_quant.py::test_eager_w8a8_chunks_long_inputs_without_changing_the_result.Not covered