Skip to content

FP8: keep rowwise _scaled_mm for float32 where cuBLAS supports it (torch < 2.14) - #16393

Merged
danielhanchen merged 4 commits into
mainfrom
fix/fp8-float32-scaled-mm-probe
Nov 3, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
fix/fp8-float32-scaled-mm-probe

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #15927.

Before torch 2.14, the rowwise torch._scaled_mm float32 restriction belongs to the CUTLASS fallback. Hopper with CUDA/cuBLAS 12.9+ can use cuBLAS with float32 output, so the blanket fallback unnecessarily dequantizes the full weight on that configuration.

This change probes float32 rowwise output support once per device and keeps the existing dequant fallback when unsupported. Shape and row-count eligibility are checked first, so decode-sized and unaligned calls do not run an irrelevant capability probe.

Validation:

  • Focused local suites: 36 passed, 2 CUDA-only skips.
  • Three dequant-only regression cases fail on the submitted PR and pass after the eligibility-order fix; differential result: 3 FIXED, 25 UNCHANGED, no head failures.
  • Real Colab L4, torch 2.11/cu130: eight fresh-process comparisons confirm one probe on the first decode call in each fresh process before the fix and zero afterward, with identical outputs. No timing speedup is claimed from these runs.
  • Scoped staging tests: 28 passed each on Linux, macOS, and Windows.
  • The 864-cell routing matrix changes only the two intended supported-float32 cells, with no narrowed routes.
  • Current-head switchboard: NO_REGRESSION (40 SAME, 2 DOM_ONLY_DIFF with no visible pixel changes). Remote L4 regression smoke: 0 regressions, 0 metric moves, 0 missing cases; 66 passed, 13 xpass, 24 skipped per arm. Standard SFT and inference comparisons also report NO_REGRESSION, with identical SFT losses and gradient norms.
  • Additional exclusive Colab G4 torch 2.11 check: all eight fresh-process arms match the torch reference; the first-call probe count drops from one to zero. No steady-state speedup is claimed.

Native Hopper execution and its performance benefit were not measured. The runtime capability distinction is supported by PyTorch's dispatch source and rowwise tests.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 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-11-03T07:29:41.746918Z 6526c8e 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.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 9187518d46

ℹ️ 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 added a commit that referenced this pull request Nov 1, 2026
…nearity checks (#16426)

## Summary


`tests/test_web_fetch_extraction.py::test_deeply_nested_tags_stay_linear`
failed on #16393, an FP8 kernel PR that does not touch Studio:

```
FAILED tests/test_web_fetch_extraction.py::test_deeply_nested_tags_stay_linear - AssertionError: [0.03737169100008941, 0.4800274350000109]
```

The test times one `html_to_markdown` call at 1000 and at 4000 nested
headers, and fails if the second takes more than 12x the first. Linear
work gives about 4x and quadratic about 16x. Both arms were a single
call, so one descheduled call on a shared runner reads as 13x growth. On
this host, five back-to-back trials gave 3.5x to 4.6x.

`test_deeply_nested_headers_do_not_blow_up_quadratically` in the same
file has the same single-sample shape.
`test_stray_end_tags_in_a_skipped_menu_stay_linear` already takes the
best of five runs for exactly this reason.

## Change

Both single-sample tests now take the minimum of five calls per size,
the same as `test_stray_end_tags_in_a_skipped_menu_stay_linear`.
Thresholds and inputs are unchanged.

## Testing

- The two tests, `--count 5`: 10 passed.
- Sabotage: an autouse fixture wraps `html_to_markdown` with a busy-wait
quadratic in the input length. Both tests fail, so best of five still
catches real quadratic growth.
@danielhanchen danielhanchen self-assigned this Nov 2, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 6526c8ed22

ℹ️ 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 3d99bf6 into main Nov 3, 2026
@danielhanchen
danielhanchen deleted the fix/fp8-float32-scaled-mm-probe branch November 3, 2026 07:48
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