Skip to content

Studio int8: let an OOM in the native W8A8 CUTLASS GEMM propagate - #18575

Merged
danielhanchen merged 1 commit into
mainfrom
fix-recheck-w8a8-oom
Nov 20, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix-recheck-w8a8-oom

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

#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_gemm itself (its fp16 output is allocated inside the call) was caught by the generic except Exception handler. That handler cleared every _NATIVE_PLAN entry, for every device and shape, and then ran torch._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_q path (#17486) had the same handler.

Change

Both native_gemm call sites in diffusion_native_quant.py re-raise torch.cuda.OutOfMemoryError before the generic handler, matching the codes step. Every other kernel failure keeps the existing behaviour (plan reset, stock _int_mm maths).

Tests

Added to tests/test_diffusion_native_quant_cutlass16.py, CPU only, with native_gemm stubbed:

  • test_cutlass16_gemm_oom_propagates_and_keeps_plans: an OOM from the GEMM reaches the caller, torch._int_mm is never called, and both plan entries (this layer, plus another device and shape) are untouched. Fails on main (OOM swallowed, _int_mm retried, plans cleared), passes here.
  • test_eager_native_gemm_oom_propagates_and_keeps_plans: the same for the eager _int_mm_from_q path. 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_mm result. 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_nothing and three test_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.py holding memory so the CUTLASS output allocation fails: on main the step should either hit a second OOM in _int_mm or recover with _NATIVE_PLAN empty, and here the OOM should surface once with _NATIVE_PLAN unchanged.

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T05:41:12.843572Z a703216 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

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: a70321636d

ℹ️ 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 d1cf359 into main Nov 20, 2026
@danielhanchen
danielhanchen deleted the fix-recheck-w8a8-oom branch November 20, 2026 07:59
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