Repository navigation
MoE per-expert dW: count pipelined shared memory, fit tiles that overflow the card - #15070
Merged
Merged
Conversation
…flow the card The per-expert dW kernel software pipelines its M loop when the operands are not permuted, so the heuristic 64x64x256 tile at 4 stages needs 106,496 B on sm_80-class cards (L4 limit 101,376) while the estimate assumed one buffer. Unpermuted launches now drop stages until the tile fits. A launch that still raises OutOfResources (an explicit tile sized for a bigger card, e.g. on a 64 KiB T4, where the legacy kernel overflows too) retries once with a tile fitted to the card. The dims tests no longer depend on the card's smem fit.
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
added a commit
that referenced
this pull request
Oct 24, 2026
#15070 landed three files that the repo's pre-commit `ruff format` hook (ruff 0.6.9 plus the kwarg spacing pass in `scripts/run_ruff_format.py`) rewrites: - `tests/test_moe_dw_explicit_tile_smem.py`: blank line after a function-local import - `unsloth/kernels/moe/autotune_cache.py`: a comparison wrapped onto two lines that fits on one - `unsloth/kernels/moe/grouped_gemm/interface.py`: two signatures over the line length pre-commit.ci checks the files a PR touches, so any later PR editing one of these goes red on lines it did not write. This is the hook's own output and nothing else. `tests/test_moe_dw_explicit_tile_smem.py` still passes (15 passed, 2 skipped on a CPU-only run).
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.
The per-expert MoE dW kernel (the default since #14550) can raise
OutOfResourceson cards with less shared memory than an H100. #14723 added a fallback to the legacy kernel for oversized tiles, but its shared memory estimate is wrong in one case: when neither operand is gathered (permute_x = Falseandpermute_y = False).Cause
Shared memory was checked with offline
triton.compileruns (Triton 3.6 and 3.8, sm75 / 80 / 89 / 90), readingmetadata.shared.num_stages, which is what_estimate_smem("dW")models.(stages - 1) * X tile + one dY tile.stages * (X tile + dY tile).grouped_gemm/grouped_gemm_dWon L4 raisedOutOfResources(106496, 101376)for the heuristic tile.Change
_estimate_smemtakespipelined_dWand adds the measured per-stage cost for unpermuted per-expert launches.num_stagesuntil the tile fits. The tile stays the same, so the result is bit-identical.OutOfResources, it retries once with a tile fitted to that card. Triton raises before the kernel runs, sodWis untouched. A tile that already launches is never changed.test_moe_fallback_tile_dims.pyexpected the heuristic dX tile to keep 4 stages on L4. That tile needs 122880 B there, over the 101376 B limit, so the 3 stages the smem fit picks is correct. The test now turns the smem fit off, since the smem tests already cover it.Tests
Colab, failing test IDs, main vs this PR, on torch 2.10.0 and 2.14.1 (same IDs on both versions):
test_explicit_tile_launches_on_this_gpu,test_per_expert_fp32_activations_bf16_weight[False]/[True]failtest_moe_fallback_tile_dimscases fail (stale stage count)test_unpermuted_heuristic_tile_launches_on_this_gpu. On L4 it raisesOutOfResources(106496 > 101376).test_fp8_ragged_block_dequantcases andtest_fp8_dequant_save_policy[False];L4 timing. bf16, heuristic dW config, no permute, median over 3 alternating runs:
Not covered