Skip to content

feat(freetile): add multi-gen Cloud TPU serving planner, SparseCore ragged gathers, and 4-bit codebook parity (#44) - #48

Closed
saariuslystoned wants to merge 3 commits into
mainfrom
feat/44-multigen-sparsecore-serving
Closed

saariuslystoned wants to merge 3 commits into
mainfrom
feat/44-multigen-sparsecore-serving

Conversation

@saariuslystoned

Copy link
Copy Markdown
Collaborator

Addresses #44 (host-verified clean-room C++ multi-generation Cloud TPU serving planner for v5e, v5p, v6e Trillium, and tpu7x Ironwood, SparseCore paged-KV & MoE ragged gather reference gated off on v5e, 0.0 ULP 4-bit codebook_dequant, and multi-chip prefix router).

Summary

  • Multi-gen capability & roofline planner (freetile/include/freetile/serving_planner.hpp, freetile/src/serving_planner.cpp, docs/cloud-tpu/multigen-serving-sparsecore.md):
    • Generation descriptors and roofline knees (MXU/VPU/HBM, VMEM offload boundaries) for v5e, v5p, v6e, and tpu7x.
    • SparseCore paged-KV pack/gather/scatter and MoE top-k routing/dedup reference parity on v5p, v6e, and tpu7x, cleanly gated off on v5e (AUTO falls back to VPU with matching numerics; forced SparseCore dispatch fails closed).
    • Unified 4-bit codebook_dequant parity (IQ4_XS, NF4, BOF4, FP4/MXFP4) at 0.0 ULP across VREG select-tree, VPERM, and native-FP4 lowering strategies.
    • Multi-chip prefix-affinity router (1x1, 2x2, 2x4, tpu7x dual-chiplet), length bucketing, and draft/target verify budgets.
  • Tests & build wiring (freetile/tests/test_serving_planner.cpp, freetile/CMakeLists.txt, freetile/Makefile, freetile/README.md, README.md): registered freetile_serving_planner_tests in CTest and Makefile.

Verification

  • make -C freetile test & CMake ctest (5/5): PASS
  • libopenbuenos CTest (3/3) + make -C libopenbuenos verify-header-host host test (27/27): PASS
  • llama-cpp-cloudtpu CTest (1/1) + libopentpu host tests + llama.cpp CLOUDTPU_MOCK=1 overlay (ADD 153/153, RMS_NORM 61/61, SCALE 12/12): PASS
  • git diff --check: clean

…n, fuzz stress

- saturate mxus_per_chip product, overflow-safe slice_device_count
- paged KV pack/gather: 64-bit offsets, full plan-consistency validation
- MoE: route-table and workspace size caps, plan validation
- reject invalid codebook format/path enums, validate d2d buddy packages
- fix shift >=64 UB in build_op640 (freetile + libopenbuenos)
- add deterministic fuzz/property stress test wiring into make/ctest
@saariuslystoned

Copy link
Copy Markdown
Collaborator Author

Adversarial Hardening & Public-Roads Audit Receipt (2a775bb5)

  • Prior PR head: dace3e42 → Hardened head: 2a775bb5
  • Fixes landed: 7 bug classes fixed (overflow, OOB, UB, enum validation, allocation bounds, serving-plan validation) + wired fuzz suite.
  • Verification: ASan+UBSan 6/6 PASS, TSan 4/4 PASS, CTest 6/6 PASS, make test green, Python 79/79 PASS, public-roads diff scan clean.

@saariuslystoned

Copy link
Copy Markdown
Collaborator Author

Closing as submitted (audited head 97711c28); keeping #44 open.

freetile/src/serving_planner.cpp (1,397 lines + host tests) implements a standalone host-side cost model and CPU reference without wiring into TileKernel, Mosaic/StableHLO lowering, PJRT/VFIO, or router/:

  • codebook_lowering() returns a report enum only (VPERM/VREG_SELECT_TREE/NATIVE_FP4) with no emitted TPU lowering, and dequant_codebook() uses a separate caller-scale / sequential-nibble layout rather than canonical GGML IQ4_XS 136-byte superblocks (covered in feat(cloud-tpu): branchless VREG 4-bit IQ4_XS select-tree LUT kernel + parity tests (#43) #46).
  • SparseCore paged-KV and MoE reference paths run host memcpy and expert_id + 1 CPU loops regardless of offload decision, and speculative verification accounts caller-supplied draft_accepted without device execution or ICI collectives.

The two narrow shift-UB guards in build_op640 (n_c32 >= 64u) are tracked separately: libopenbuenos/src/ob_gemm_emitter.cpp:742 is already covered in #45, and freetile/src/buenos_emitter.cpp:678 can land as a standalone 1-line fix.

@saariuslystoned
saariuslystoned deleted the feat/44-multigen-sparsecore-serving branch December 1, 2026 16:37
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