Skip to content

Export Cake KNN search plan-runtime suite (full-198 geomean 3.11x, 0 rows below 1.0x)#5

Open
yyihuang wants to merge 1 commit into
FlashML-org:mainfrom
yyihuang:cake-export-v5/knn-search
Open

Export Cake KNN search plan-runtime suite (full-198 geomean 3.11x, 0 rows below 1.0x)#5
yyihuang wants to merge 1 commit into
FlashML-org:mainfrom
yyihuang:cake-export-v5/knn-search

Conversation

@yyihuang

@yyihuang yyihuang commented Jul 9, 2026

Copy link
Copy Markdown

Summary

This PR re-exports Cake KNN search through the new plan-based launch runtime and is the direct successor of PR #16. Same reusable two-stage public API:

runtime = flashlib_cake_knn_search.init()      # once per process/device/operator runtime
distances, indices = runtime.compute(q, db, k) # repeat; data and shape may change

The artifact was generated and validated from exact merged Cake main 0b4375909f78358fd1eb3d1d3a804e31353a18b9, which includes the full plan-based export runtime arc (per-signature resolved LaunchPlan + plan cache, prepacked argument buffers, TMA variant-bank pointer rebinding — Cake MRs 293/299/300/301). Exact provenance is embedded in manifest.json.

What changed vs PR #16

PR #16 froze the evolve-time interpreted host stack (guard cascade, per-argument ctypes marshalling, per-call TMA descriptor encode) into the shipped hot path; the kernels won but ~0.1–0.2 ms/call of Python host work ate the wins. This export resolves every one of the 198 contract signatures into a static launch plan at export time: a hot call is signature lookup → pointer patch → submit. The generic dispatcher remains only as the slow-path plan constructor, and route parity against expected_routes.json stays a hard gate.

Correctness and inventory

  • generated GPU suite: 206 passed on 4x NVIDIA GB200 (sm_100a), 4 validation shards
  • marked correctness shapes: 198/198; ordered route parity 198/198
  • public synchronized-E2E/CUPTI benchmark shapes: 198/198
  • frozen CUDA specializations: 592
  • baseline: live flashlib.flash_knn, same session, CUPTI timing everywhere (no wall-clock or event timing)

Hot steady-state synchronized E2E vs PR #16

The official metric is flashlib.flash_knn / runtime.compute synchronized host end-to-end latency (raw inputs, default output allocation, slot lookup, launch work, GPU execution and gaps, terminal synchronization).

Scope PR #16 (interpreted runtime) This PR (plan runtime)
Full 198-shape: min 0.0105x 1.5043x
Full 198-shape: geomean 1.0556x 3.1134x
Full 198-shape: median 1.5706x 3.0106x
Full 198-shape: p90 2.0658x 5.1272x
Full 198-shape: max 4.1821x 7.2984x
Full 198-shape: <1.0x 53/198 0/198
Declared 11-shape floor: min 1.4046x 2.0693x
Declared 11-shape floor: geomean 1.6893x 2.9272x

Every one of the 198 diagnostic shapes now beats FlashLib hot; PR #16 lost on 53 of them. The declared 11-shape publication floor (1.0x) passes fail-closed with below_floor_count: 0.

Modeled amortized synchronized E2E

after-init(N) = (F + (N-1) x H) / N, including-init(N) = (I + F + (N-1) x H) / N, evaluated per shape from measured init I, first-call F, and hot-median H.

Public calls N after-init geomean including-init geomean
1 0.978x 0.079x
10 1.098x 0.097x
100 1.490x 0.198x
1000 2.434x 0.836x

Cold init-once synchronized E2E median 423.8 ms and first compute() median 52.3 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 (timing_backend: "cupti", hard-checked per lane); L2 flushed; each completed shape synchronized and evicted before the next (one miss + fresh-pointer hit per shape; no pre-populated resident cache assumed).
  • Full machine-readable evidence: VALIDATION.json, per-shape BENCHMARK_RESULTS.json, human summary VALIDATION.md.
  • The exported package has no Cake/Loom runtime dependency (Apache TVM FFI adapter optional).

🤖 Generated with Claude Code


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

Plan-based launch runtime (per-signature LaunchPlan cache, TMA variant-bank
hot path) exported and validated on 4x NVIDIA GB200: 198/198 correctness,
198/198 ordered route parity, hot public synchronized-E2E speedup vs live
flashlib.flash_knn min 1.5043 / geomean 3.1134 across the full 198-shape
denominator, 0 rows below 1.0x, declared 11-shape publication floor min
2.0693 / geomean 2.9272 at the 1.0x floor.

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