Subit prefill#2
Open
tomasruizt wants to merge 16 commits intomainfrom
Open
Conversation
Split inlined FLA Triton kernels into fla_prefill_code.py (1763 lines) and keep competition entry points in prefill_kernel.py. Fixes COMPILE_ERROR on eval server where fla is not installed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows targeting specific workloads (e.g. idx=53 for B=64) to compare kernel performance across batch sizes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CUPTI measurements across all 54 decode workloads show fla-recurrent wins at B<=4 (1.30x at B=1) but loses at B>=16 (1.43x slower at B=64). Crossover at B=8. This explains the 0.96x competition result. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
NCU at B=64 shows fla-recurrent executes 2.2x more instructions than fi-baseline (13.4M vs 6M) due to BV=8 creating 16 V-tiles per head, each redundantly loading q/k/gates. Batch-adaptive BV is the fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Autotune sweep on B200 (CUPTI) found BV=8 always wins, but warp count is the key lever: fewer warps reduce contention at high occupancy. B=64 improved 18.18 -> 15.01 us (17%), crossover moved from B=8 to B=16. Also fix pre-existing ruff E402/E731 lint issues in kernel.py. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BV=128 (18.18 us) and fla-tma (34.88 us) both worse than BV=8 with adaptive warps (15.01 us) at B=64. Remaining 1.18x gap to fi-baseline is from 2.2x instruction count difference due to redundant q/k loads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The prefill wrapper was computing gates (exp, softplus, sigmoid) as separate PyTorch ops, launching ~8 elementwise kernels before the cumsum. The new fused_gate_cumsum_kernel computes g and beta from raw a, b, dt_bias, A_log inputs and applies cumsum in one pass. Workload 0 (seq_len=6): 1742 -> 1201 us median (31% faster, RTX 3090). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
93% of prefill wall time is GPU idle (launch overhead), not compute. Main bottleneck: 51 kernel launches per forward pass with 82-150 us gaps before each Triton kernel. Remaining opportunities: caching prepare_chunk_indices and CUDA graphs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SOLUTION env var on run_modal.py loads a pre-existing solution JSON from the dataset instead of packing from source. New targets: make modal-official-prefill # our solution on B200 make modal-official-prefill-baseline # FlashInfer baseline on B200 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Set TRITON_CACHE_DIR to /data/cache/triton on the persistent Modal volume so compiled kernels and autotune configs survive container restarts. Applied to all Modal remote functions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wraps flashinfer.gdn_prefill.chunk_gated_delta_rule (SM90+ only) as a prefill-fi-baseline algo for comparing against our prefill-fla-chunk on Modal B200 via: make prefill-fi-timing-modal Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prefill CUPTI on B200: fi-baseline 185 us vs fla-chunk 1536 us (8.3x gap from launch overhead). Added Makefile targets and Modal notes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…aphs B200 CUPTI: fi-baseline 185 us vs fla-chunk 1536 us (8.3x gap). Next steps: (1) cache prepare_chunk_indices (~260 us), (2) CUDA graph capture (~1100 us), (3) kernel fusion (longer-term). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42b9fda to
43ed859
Compare
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.
No description provided.