unsloth/scripts/benchmarks/results/stats
Daniel Han cc033fee19 flex: test FA4 prefill + Inductor autotune replay (both regress)
Wired up two suggestions from the FlashAttention-4 blog + attention-gym:

1. `--fa4_prefill` flag: `BLOCK_SIZE=(256, 128)` + `BACKEND="FLASH"` on the
   prefill create_block_mask, pad to 256-row Q tile. Confirmed FA4 kernel
   fires on Blackwell (torch 2.11 + flash-attn CuTeDSL). Output is coherent
   but 4617 tok/s vs 5744 baseline at batch 64 + LoRA.

   Root cause: our prefill mask is document_causal, which evaluates
   `docs[q_idx] == docs[kv_idx]`. The FA4 CuTe kernel's known limitation
   (documented in attention-gym/examples/flex_flash_attention.py) is that
   "Indexing by kv_idx is a large perf hit". The doc mask hits that
   slow path directly. To benefit from FA4 on prefill we would need to
   refactor the mask so the per-kv lookup goes away, which is non-trivial
   given the document-boundary + causal combo.

2. flex_autotune_replay.py: new script that drives the pattern from
   attention-gym/examples/flex_autotune_replay.py -- sets
   `TORCHINDUCTOR_FLEX_ATTENTION_LOGGING_FILE` + runs with
   `mode="max-autotune-no-cudagraphs"`, parses the JSON log (handling
   symbolic dims like `s40`), picks the decode-shape entry (Q_LEN=1),
   and writes best fwd_* kernel options as JSON.

   Inductor's best for the decode shape: `fwd_num_warps=4, fwd_num_stages=3,
   fwd_BLOCK_M=64, fwd_BLOCK_N=64, fwd_USE_TMA=False`. Applied end-to-end:
   4827 tok/s vs 5744 manual baseline. The per-call time-minimum Inductor
   uses doesn't track the cumulative register-spill / L1 effects across
   the 36-layer stack.

Kept `--fa4_prefill` and flex_autotune_replay.py in-tree -- they are
useful scaffolding for anyone who wants to push further (refactor the mask,
run the 144-config exhaustive fwd sweep from attention-gym/examples/flex_grid_sweep.py,
etc.). Default config is unchanged.

Also documented the run-to-run variance: over 10 rounds at batch 64 + LoRA,
median 4192 and best 5660 tok/s; the spread is GPU clock throttling +
variable prompt-length distributions. The 5744 "baseline" we report is
best-of-N, matching the prior harness, but steady-state median is closer
to 75 % of that.

Writeup update in scripts/benchmarks/results/flex_vs_vllm.md.
2026-04-21 00:25:11 +00:00
..
cb_sync_smoke.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
flex_8_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_16_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_32_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_32x512_cudagraph.json Breakthrough: flex_attention + paged KV + CUDA graphs = 35-48% of vLLM 2026-04-20 15:57:41 +00:00
flex_32x512_eager.json Breakthrough: flex_attention + paged KV + CUDA graphs = 35-48% of vLLM 2026-04-20 15:57:41 +00:00
flex_32x512_lora_cudagraph.json Flex+CUDA-graph closes gap to vLLM across batch sizes 2026-04-20 16:09:47 +00:00
flex_32x512_mauto_nocg.json Batch-size sweep: flex@256 vs vLLM@256 + max-autotune check 2026-04-20 16:17:19 +00:00
flex_64_lora_autotune.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_autotune_tma.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_fa4prefill.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_pinned_blocks.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_torch211_10rounds.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_torch211_baseline.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_torch211_repeat.json flex: test FA4 prefill + Inductor autotune replay (both regress) 2026-04-21 00:25:11 +00:00
flex_64_lora_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_64_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_64x512_lora_cudagraph.json Flex+CUDA-graph closes gap to vLLM across batch sizes 2026-04-20 16:09:47 +00:00
flex_128_tuned.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
flex_128x512_cudagraph.json Flex+CUDA-graph closes gap to vLLM across batch sizes 2026-04-20 16:09:47 +00:00
flex_256x512.json Batch-size sweep: flex@256 vs vLLM@256 + max-autotune check 2026-04-20 16:17:19 +00:00
grpo_cb_paged_10.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_cb_paged_10.summary.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_cb_paged_30.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
grpo_cb_paged_30.summary.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
grpo_fi_false_30.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
grpo_fi_false_30.summary.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
grpo_unsloth_fi_false_10.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_unsloth_fi_false_10.summary.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_vllm_10.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_vllm_10.summary.json Phase 2 vibe (10-step): vllm vs unsloth_fi_false vs cb_paged + Phase 3 fixes 2026-04-20 14:23:51 +00:00
grpo_vllm_30.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
grpo_vllm_30.summary.json Phase 2: 30-step equivalence + pairwise diffs vs vLLM 2026-04-20 15:03:32 +00:00
lora_cb_paged_fa4_gen.json Phase 1+3: LoRA rollout benchmarks + CB sync driver + Phase 4 scaffold 2026-04-20 14:01:16 +00:00
lora_cb_sdpa_paged_gen.json Phase 1+3: LoRA rollout benchmarks + CB sync driver + Phase 4 scaffold 2026-04-20 14:01:16 +00:00
lora_unsloth_fi_false_gen.json Phase 1+3: LoRA rollout benchmarks + CB sync driver + Phase 4 scaffold 2026-04-20 14:01:16 +00:00
lora_vllm_gen.json Phase 1+3: LoRA rollout benchmarks + CB sync driver + Phase 4 scaffold 2026-04-20 14:01:16 +00:00
notebook_ref_10.json Add Phase 0+1 GRPO backend comparison scaffolding 2026-04-20 13:54:06 +00:00
vllm_8.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
vllm_16.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
vllm_32.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
vllm_64.json FlexKernelOptions sweep: flex reaches 72% of vLLM at batch 64 + LoRA 2026-04-20 23:30:05 +00:00
vllm_64x512_lora.json Flex+CUDA-graph closes gap to vLLM across batch sizes 2026-04-20 16:09:47 +00:00
vllm_128x512.json Flex+CUDA-graph closes gap to vLLM across batch sizes 2026-04-20 16:09:47 +00:00
vllm_256x512.json Batch-size sweep: flex@256 vs vLLM@256 + max-autotune check 2026-04-20 16:17:19 +00:00