Repository navigation
Studio int8: let an OOM in the native W8A8 CUTLASS GEMM propagate - #18575
Merged
Merged
Conversation
An OOM from native_gemm (its fp16 output allocation) was caught by the generic kernel-fault handler, which cleared every _NATIVE_PLAN entry on every device and retried with torch._int_mm, whose int32 accumulator is larger than the allocation that just failed. Treat it as an OOM, as the activation-codes step already does: re-raise, keep the plans. Other kernel failures keep the plan reset and the stock maths fallback.
Codex Review Summary: ✅ CompletedThis 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 |
1 similar comment
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! 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 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.
#18441 routed T4 fp16 native W8A8 linears through the raced CUTLASS GEMM. Building the activation codes already lets a CUDA OOM propagate, but an OOM from
native_gemmitself (its fp16 output is allocated inside the call) was caught by the genericexcept Exceptionhandler. That handler cleared every_NATIVE_PLANentry, for every device and shape, and then rantorch._int_mm, whose int32 accumulator is larger than the fp16 output that just failed to allocate. So an OOM at the GEMM turned into a second, bigger allocation on a card that was already full, and later forwards on unrelated layers and cards lost their tile plans. The eager_int_mm_from_qpath (#17486) had the same handler.Change
Both
native_gemmcall sites indiffusion_native_quant.pyre-raisetorch.cuda.OutOfMemoryErrorbefore the generic handler, matching the codes step. Every other kernel failure keeps the existing behaviour (plan reset, stock_int_mmmaths).Tests
Added to
tests/test_diffusion_native_quant_cutlass16.py, CPU only, withnative_gemmstubbed:test_cutlass16_gemm_oom_propagates_and_keeps_plans: an OOM from the GEMM reaches the caller,torch._int_mmis never called, and both plan entries (this layer, plus another device and shape) are untouched. Fails on main (OOM swallowed,_int_mmretried, plans cleared), passes here.test_eager_native_gemm_oom_propagates_and_keeps_plans: the same for the eager_int_mm_from_qpath. Fails on main, passes here.test_cutlass16_gemm_fault_still_falls_back: a non-OOM GEMM failure still clears the plans and returns the_int_mmresult. Passes on main and here.Suite (
tests/test_diffusion_native_quant*.py,tests/test_diffusion_int8*.py,tests/test_diffusion_native_w8a8*.py): 1001 passed, 343 skipped, 4 failed on both main and this branch, with the same failing IDs (test_diffusion_int8_attention_toggle.py::test_request_models_carry_the_field_and_old_clients_send_nothingand threetest_diffusion_int8_fused.py::test_fused_flux_single_*). These failures were already there before this change.Not proven here
No GPU run. The tests stub the GEMM, so they don't show a real OOM on a T4. That would take FLUX.3 klein INT8 on a T4 with
gpu_ballast.pyholding memory so the CUTLASS output allocation fails: on main the step should either hit a second OOM in_int_mmor recover with_NATIVE_PLANempty, and here the OOM should surface once with_NATIVE_PLANunchanged.