fix(gemm): restore capture-safe K6 small-M dispatch - #136
Conversation
|
Warning Review limit reached
Next review available in: 52 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe W4A16 kernel combines Trellis low-bit tile selection conditions and adds a specialized dense K6 MCG path for small FP16-compatible workloads. ChangesW4A16 kernel execution
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant DenseExecutionBranch
participant FP16Buffers
participant run_k6_mcg
DenseExecutionBranch->>FP16Buffers: Prepare or reuse FP16 buffers
DenseExecutionBranch->>run_k6_mcg: Pass reshaped Trellis payload
run_k6_mcg-->>DenseExecutionBranch: Return K6 MCG results
DenseExecutionBranch->>FP16Buffers: Convert non-FP16 outputs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@b12x/moe/_shared/kernels/w4a16/kernel.py`:
- Around line 11329-11336: Update the use_k6_mcg_small predicate near run_k6_mcg
to require the current device’s supported sm_120 capability before selecting
this path. When that capability is absent, the predicate must be false so
execution falls back to the generic scheduler instead of invoking run_k6_mcg.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: e0cc5b93-83f9-4443-b963-1f6c56336dba
📒 Files selected for processing (1)
b12x/moe/_shared/kernels/w4a16/kernel.py
R7 encoders choose K independently per (expert, projection). The mixed path tiers per expert -- one trellis_bits per tier for FC1 and FC2, a single-row descriptor -- so an expert that is K3-gate/K4-down cannot be expressed. - descriptor_map becomes int32[3 * stride], rows gate/up/down, same (tier << 8) | local encoding. Dispatch resolves the row per projection: FC2 at compile time, FC1 by N-half from output_n_tile, which trellis3_t256_proj keeps projection-aligned. - FC1 and FC2 expert counts may differ per tier. The FC2 count is derived from the W2 payload extent and carried through bounds, W2/global-scale logical layouts, compile arguments, and launches, so both phases keep real bounds and truthful CuTe extents. ABI_VERSION 6 -> 7. - build_tiered_maps() keeps its signature and repeats its single row three times, so existing per-expert mixed checkpoints resolve bit-identically. - New validated public builder build_projection_tiered_maps(); slot arity, range, disjointness and per-tier capacity are enforced. Based on the canonical r33 composition (master 9bbae67 + local-inference-lab#125, local-inference-lab#126, local-inference-lab#133, local-inference-lab#135, local-inference-lab#136, local-inference-lab#137), verified byte-identical to the r33 image kernel tree before these changes. CPU contract tests added; suite parity confirmed against the unmodified base (same 9 pre-existing GPU-dependent failures, 8 additional tests passing). Ruff clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Summary
M <= 128.Root cause
masterat9bbae67removed the K6/MCG small-M dispatch while retaining its implementation and CUDA-graph regression test. vLLM intentionally provisions only a one-element generic scratch placeholder for this qualified small-M path. Falling through to the generic scheduler therefore fails during graph capture withW4A16 GEMM scratch is not initialized for CUDA graph capture.The fix restores the original ownership contract rather than increasing persistent scratch or disabling CUDA graphs.
Validation
master:test_k6_small_m_cuda_graph_replay_is_stablefails during capture.git diff --check: pass.Summary by CodeRabbit