[Fix] Skip grid-based stage fallback for OTHER/MEMORY kernels to prevent small scheduling ops from misclassifying decode layers as prefill - #4
Merged
Conversation
…ent small scheduling ops from misclassifying decode layers as prefill
yichiche
added a commit
that referenced
this pull request
Jul 6, 2026
…ent small scheduling ops from misclassifying decode layers as prefill (#4) profile/trace_analyzer.py — two changes: Added kernel_type parameter to classify_stage() and skipped the grid-based fallback for OTHER and MEMORY kernel types, since these utility ops have small grids regardless of execution phase. Reordered the call site to classify kernel type before stage, so the type can be passed in. The fix is minimal (6 lines changed in the classifier) and preserves the grid fallback for compute-relevant kernels (attention, quantization, linear, MoE) where grid size is a meaningful prefill/decode signal.
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.
Summary: Grid-Based Stage Fallback Misclassification Fix
Problem
The 0303 profiling trace had severely degraded evaluation scores compared to the 0302 baseline:
┌──────────────────────┬─────────┬───────────────────┬──────────────────┐
│ Metric │ 0302 │ 0303 (before fix) │ 0303 (after fix) │
├──────────────────────┼─────────┼───────────────────┼──────────────────┤
│ S3 Round Consistency │ 100 (A) │ 44.4 (F) │ 100 (A) │
├──────────────────────┼─────────┼───────────────────┼──────────────────┤
│ S4 Type Sequence │ 100 (A) │ 57.3 (F) │ 100 (A) │
├──────────────────────┼─────────┼───────────────────┼──────────────────┤
│ Overall │ 100 (A) │ 75.4 (B) │ 100 (A) │
├──────────────────────┼─────────┼───────────────────┼──────────────────┤
│ Prefill layers │ 525 │ 1,157 │ 521 │
├──────────────────────┼─────────┼───────────────────┼──────────────────┤
│ Decode rounds │ 400 │ 798 │ 400 │
└──────────────────────┴─────────┴───────────────────┴──────────────────┘
Root Cause
Small scheduling/utility kernels (index_elementwise_kernel, CUDAFunctorOnSelf, arange) were being misclassified as PREFILL by the grid-based fallback rule (grid[0] < 200 → PREFILL). These kernels always have tiny grid dimensions regardless of whether
they run during prefill or decode.
In a typical decode layer, stage voting is razor-thin: 1 DECODE vote (from mla_a8w8_qh16_qseqlen1) vs 25 UNKNOWN. When 1-3 of these small kernels appeared as extras in a decode layer, their false PREFILL votes (via grid fallback) outnumbered the single
DECODE vote, flipping the layer to PREFILL. This broke decode rounds into fragments, cascading through stage propagation to corrupt adjacent tie-breaking layers.
Fix
profile/trace_analyzer.py — two changes:
The fix is minimal (6 lines changed in the classifier) and preserves the grid fallback for compute-relevant kernels (attention, quantization, linear, MoE) where grid size is a meaningful prefill/decode signal.
Also Included