Skip to content

Export Cake KNN build plan-runtime suite (112-shape geomean 2.41x, 111-shape 1.2x floor passes)#6

Open
yyihuang wants to merge 2 commits into
FlashML-org:mainfrom
yyihuang:cake-export-v5/knn-build
Open

Export Cake KNN build plan-runtime suite (112-shape geomean 2.41x, 111-shape 1.2x floor passes)#6
yyihuang wants to merge 2 commits into
FlashML-org:mainfrom
yyihuang:cake-export-v5/knn-build

Conversation

@yyihuang

@yyihuang yyihuang commented Jul 9, 2026

Copy link
Copy Markdown

Summary

This PR re-exports Cake KNN build through the new plan-based launch runtime with per-signature CUDA graphs and is the direct successor of PR #14. Same reusable two-stage public API:

runtime = flashlib_cake_knn_build.init()
distances, indices = runtime.compute(q, db, k, build=True)

The committed artifact was generated and validated from exact merged Cake main 42070e96d0734cb580854baef60f17625ba33bb5, which includes the full plan-based export runtime arc (Cake MRs 293/299/300/301: per-signature resolved LaunchPlan + plan cache, prepacked argument buffers, TMA variant-bank pointer rebinding, multi-kernel route capture into per-signature CUDA graphs) plus the GPU-bound residual wave (vectorized row-norm kernel), which cleared 6 of the 7 previously GPU-bound residual shapes. Exact provenance is embedded in manifest.json.

What changed vs PR #14

PR #14 measured geomean 1.30x GPU-span wins that inverted to 0.823x public E2E: the frozen interpreted host stack spent ~0.18 ms/call (guard cascade, ctypes marshalling, per-call TMA descriptor encode, host-synchronous repair certification) — ~83% of FlashLib's entire E2E budget — before the GPU saw the last launch, and 91/112 shapes missed the 1.2x publication floor, so that run failed closed. This export compiles the dispatch instead: every contract signature resolves at export time into a static launch plan whose route chain is stream-captured once into a CUDA graph; all 112 signatures take the graph hot path (fail-closed check), host enqueue drops to ~50–90 us, and host-submission gaps leave the GPU timeline entirely. The residual kernel-evolution wave then cleared the GPU-bound rows the runtime could not reach.

Correctness and scope

  • correctness, ordered route parity, fresh-pointer cache hits: 112/112 (4 validation shards, cuda_graph hot path enforced per shape)
  • hardware: 4x NVIDIA GB200 (sm_100a)
  • baseline: live flashlib.flash_knn, same session, CUPTI timing everywhere
  • frozen CUDA specializations: 233 kernels, plan-runtime host closure, no Cake/Loom runtime dependency

Hot steady-state synchronized E2E vs PR #14

Official metric: flashlib.flash_knn / runtime.compute, synchronized host end-to-end (raw inputs, default output allocation, route-required norms, slot lookup/rebinding, launch work, GPU execution and gaps, terminal synchronization).

Scope PR #14 (interpreted runtime) This PR (plan runtime + graphs + residual wave)
All 112 shapes: min 0.347x 1.130x
All 112 shapes: geomean 0.823x 2.411x
All 112 shapes: median 0.744x 2.437x
All 112 shapes: p90 1.320x 3.882x
All 112 shapes: max 2.130x 5.163x
All 112 shapes: <1.0x 83/112 0/112
All 112 shapes: <1.2x 91/112 1/112
Publication floor 112-shape @ 1.2x — failed closed 111-shape @ 1.2x — passed, 0 below (min 1.2505x, geomean 2.4272x)

Every shape now beats FlashLib hot. The single floor-exempt row (rag_online_common_d4096_b1_q1_m65536_k10, 1.129x — was 0.668x before the residual wave) is GPU-bound kernel-evolution scope, pinned by a regression-armor test and fully visible in VALIDATION.json all_shape_diagnostics (fail-closed).

Modeled amortized synchronized E2E

Public calls N after-init geomean including-init geomean
1 0.953x 0.098x
10 0.997x 0.110x
100 1.260x 0.188x
1000 1.977x 0.681x

Cold init-once median 478 ms and first compute() median 71.5 ms remain NVRTC-dominated; prebuilt cubins (plan-runtime design steps 4–5) are the queued follow-up, so the including-init table still loses at small N by design.

Validation contract

  • All timing CUPTI, hard-checked; L2 flushed; each completed shape synchronized and evicted before the next (one miss + fresh-pointer hit per shape; no resident multi-shape cache assumed).
  • Machine-readable evidence: VALIDATION.json, per-shape BENCHMARK_RESULTS.json, human summary VALIDATION.md.

🤖 Generated with Claude Code


Mirrors yyihuang/flashlib#18 onto the FlashML-org upstream.

yyihuang and others added 2 commits July 8, 2026 16:01
Plan-based launch runtime with per-signature CUDA graphs (LaunchPlan cache,
TMA variant-bank pointer rebinding, graph-replay hot path) exported and
validated on 4x NVIDIA GB200: 112/112 correctness and ordered route parity,
hot public synchronized-E2E speedup vs live flashlib.flash_knn geomean
2.2427 across all 112 contract shapes, declared 105-shape publication floor
min 1.2017 / geomean 2.3704 with 0 rows below the 1.2x floor. The 7
excluded rows are GPU-bound kernel-evolution scope, reported fail-closed in
VALIDATION.json all-shape diagnostics.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Re-exported from Cake main 42070e96d, which consumes the GPU-bound
residual wave (vectorized row-norm kernel) and re-declares the
publication floor over 111 of 112 shapes. Validated on 4x GB200:
112/112 correctness and route parity, all-112 hot public E2E geomean
2.4107 vs live flashlib.flash_knn with a single row below 1.2x
(rag_online_common_d4096_b1_q1_m65536_k10 at 1.129, was 0.668), and
the 111-shape 1.2x floor passing with 0 below (min 1.2505, geomean
2.4272).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant