Skip to content

MoE: keep the fitted dW tile for float32 activations in the heuristic configs - #15928

Merged
danielhanchen merged 5 commits into
mainfrom
moe-wide-dw-16bit-only
Nov 1, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
moe-wide-dw-16bit-only

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #15505.

#15505 widens the heuristic backward dW tile to 64 x 128 x 64 at 3 stages when K leaves BLOCK_SIZE_K 64 (gpt-oss gate_up). The condition does not look at the activation dtype. On a B200 the wide tile is slower for float32 activations, though it is faster for bf16:

dW N x K, float32 X / dY / dW tokens before #15505 (ms) main (ms) change
1024 x 960 128 0.0906 0.1026 13.2% slower
1024 x 960 4096 0.6449 0.7412 14.9% slower
5760 x 2880 (gpt-oss gate_up) 128 1.4518 1.6368 12.7% slower
5760 x 2880 (gpt-oss gate_up) 4096 10.709 12.309 14.9% slower

These are B200 numbers from a recheck reviewer: torch 2.14.1, Triton 3.8, interleaved, A/A spread under 0.14%, and bitwise equal outputs. The same runs reproduced the bf16 gain of 1.35x - 1.50x.

float32 reaches this path with float32 expert weights, UNSLOTH_FORCE_FLOAT32=1, or UNSLOTH_MOE_TRITON_FP32=1. These heuristic configs are used under UNSLOTH_MOE_DISABLE_AUTOTUNE=1. The autotuned default and the autotune-failure fallback are unchanged.

Change

Widening now skips float32 activations on compute capability 10.x (B200 / sm100), the only architecture where the wide tile was measured slower for float32. bf16 / fp16, callers that pass no dtype, and float32 on every other architecture keep the wide tile.

Tests

  • New test_heuristic_dw_widens_only_16bit_activations[bf16, fp16, fp32] checks gpt-oss gate_up and N 1024 x K 960. The fp32 case fails on main and passes here.
  • tests/test_moe*.py: 337 passed, 46 skipped (CUDA only), CPU torch 2.14.1.

Other architectures

On L4 (sm89) and RTX PRO 6000 Blackwell (sm120) the wide tile is faster for float32 too, so the float32 exclusion is limited to sm100. fp32 dW kernel time with the 64-wide tile vs main's 128-wide tile (CUDA graphs, interleaved A / A / B over 9 rounds, medians, torch 2.11.0+cu130, Triton 3.6.0; outputs bitwise equal):

cell (fp32), dW kernel L4: 64-wide vs main RTX PRO 6000: 64-wide vs main
1024 x 960, T 128, legacy -5.3% +9.5%
1024 x 960, T 2048, legacy +7.4% +22.5%
1024 x 960, T 2048, auto +17.9% +21.5%
1024 x 960, T 8192, legacy +17.2% +39.4%
5760 x 2880, T 2048, legacy +22.5% +32.5%
5760 x 2880, T 4096, legacy +26.2% +43.4%

With this change both cards pick main's tile for float32 (fix vs main within the A / A band in every cell). test_heuristic_dw_widens_all_dtypes_on_sm89[bf16, fp16, fp32] pins it; the fp32 case fails on the previous head. B200 itself was not re-measured here, and A100 / H100 were not measured.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 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-01T08:59:15.742500Z dbeec0c 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 added a commit that referenced this pull request Oct 29, 2026
…15946)

## Summary

`Repo tests (CPU, studio)` is red on main since #15919, and on every PR
based after it (seen on staging for #15928, #15931 and #15934). Three
tests in `tests/studio/test_desktop_reliability_frontend_contract.py`
fail:

- `test_audio_page_matches_the_image_rail_header_and_action_footer`
- `test_images_header_tracks_preview_and_preserves_titlebar_controls`
- `test_media_page_headers_out_stack_the_mac_drag_region`

#15919 rebuilt the Images, Video and Audio headers on purpose: Create /
Train is centred in a `minmax(0,1fr)_auto_minmax(max-content,1fr)` row,
and the API / Library / sibling links moved into the new
`MediaHeaderActions` component, which steps down (pill off centre,
compact, then hidden) as space runs short. The product is right and the
tests pinned the old class strings, so the tests are what changes here.

## What changed

- A shared `_assert_media_header_row` check for the Images and Audio
headers: the new row columns, the pill centred in column 2
(`data-media-header-centre ... col-start-2 justify-self-center`), and
the links rendered inside `<MediaHeaderActions>` (the Library and
sibling links are now asserted to sit inside it, not just somewhere in
the header).
- `MediaHeaderActions` itself is pinned to what the old inline markup
guaranteed: its slot stays `pointer-events-none col-start-3 row-start-1`
(so gaps in the band still drag the macOS window) and only the links'
group is `pointer-events-auto`.
- The macOS drag-region test counts the clickable group drawn by
`MediaHeaderActions` when a page renders it, since that group no longer
appears in the page source.

## Verification

- Base (main at `862098ed4a`): 3 failed, 41 passed. Bisected to #15919:
its parent passes all 44.
- Head: 44 passed.
- Each guard still fails when the property it protects breaks (source
edited, test run, reverted):
  - slot made `pointer-events-auto`: Images and Audio header tests fail
  - links group no longer `pointer-events-auto`: all three fail
- Images sibling link moved out of `MediaHeaderActions`: Images header
test fails
  - Audio pill set to `justify-self-end`: Audio header test fails

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
danielhanchen and others added 3 commits October 31, 2026 00:59
…ed faster

On L4 (sm89) the 128-wide dW tile is 6-18% faster for float32 activations, so
the float32 exclusion now applies only to compute capability 10.x (B200).
Other architectures keep main's choice.

[skip ci]
@danielhanchen
danielhanchen merged commit d011e08 into main Nov 1, 2026
@danielhanchen
danielhanchen deleted the moe-wide-dw-16bit-only branch November 1, 2026 09:21
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: dbeec0cb24

ℹ️ 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

Copy link
Copy Markdown
Member Author

pre-commit.ci run

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