Repository navigation
feat(cloud-tpu): wire branchless VREG IQ4_XS/IQ4_NL select-tree LUT into StableHLO, ggml-cloudtpu & FreeTile (#43) - #57
Open
saariuslystoned wants to merge 1 commit into
Conversation
…nto StableHLO MUL_MAT, ggml-cloudtpu & FreeTile codebook_dequant (#43)
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.
Addresses #43 (
Refs #43— does not close#43; live Cloud TPUv5e/v6esilicon timing and bare-metal/dev/vfio/0proof remain human-gated and open on#43).Context
Phase 1 (#46) landed the standalone host select-tree LUT math, standalone
@mainStableHLO snippet emitter, and TileIR codebook planning guard. This PR delivers Phase 2, wiring the branchless 4-bit VREG select-tree LUT (15stablehlo.selectops,0stablehlo.gather) into the full Cloud TPUMUL_MAT+GET_ROWSStableHLO pipeline,ggml-cloudtpu.cppGGUFIQ4_XS/IQ4_NLingestion/readback, portable FreeTilecodebook_dequantsemantic op, and a reproducible Cloud TPU Gates 1–4 benchmark script.Summary
IQ4_XS_LUT&IQ4_NL_LUTlowering (llama-cpp-cloudtpu/stablehlo_emitter.{hpp,cpp}):TensorStorageKind::IQ4_XS_LUTandTensorStorageKind::IQ4_NL_LUTintoemit_stablehlo_program()forMUL_MAT,GET_ROWS, andCPY, supporting nativeU4and packedU8bitcast-to-U4K-major N-minor HBM storage,BF16MXU +mm_pad_mdecode padding,FP8MXU (tpu7x), and SPMDSHARD_N/SHARD_K.precision = [HIGHEST, HIGHEST]on F32IQ4_XS_LUT/IQ4_NL_LUTdot_generalso TPU hardware does not silently round F32 operands to BF16.GGML_TYPE_IQ4_XS&GGML_TYPE_IQ4_NLruntime ingestion (llama-cpp-cloudtpu/ggml-cloudtpu.cpp):block_iq4_xs(split nibbles + 6-bit signed sub-scalesls - 32+kvalues_iq4nl) and 18-byte/32-weightblock_iq4_nl, lossless readback via 8-byte header metadata, HBM allocation sizing, and consistent slot type/shape tracking across partial/view-staged and reused slots.codebook_dequantsemantic op & codebook extensibility (freetile/):CodebookDequantOp/plan_codebook_dequant_op()acrossIQ4_XS,IQ4_NL,NF4,FP4targeting Cloud TPU (stablehlo.select_treewithv5e16 MiB VMEM cliff characterization<= 5.31Mvs>= 9.44Melements), ARM SME2 (sme2.luti4), Qualcomm HVX (hvx.vlut), and PowerVR Volcanic (volcanic.select_tree).emit_stablehlo_select_tree_lut()(3/7/15selects,0gather — composable scalar primitive for future grid-codebook sub-lookups) and packed 18-byte/32-weightBlockCodebook4(NF4/FP4_E2M1/IQ4_NL) dequantizers.tools/select_tree_lut.py,tools/test_select_tree_lut.py,proof/cloud-tpu-iq4xs-select-tree/PROOF.md):--emit-jax-benchgenerates a clean-room Cloud TPU script covering canonical 136-byteIQ4_XSparity (including an independent scalar row-0 decoder),512^2..6144^2VMEM-cliff sweep, XLA gather footguns (mode="promise_in_bounds",int32, flat 1D), andlax.fori_loopBF16parity withjax.lax.optimization_barrier+ lowered/compiled IR checks.Verification (Head
dc9ec44755283a5b42dee675f38cf5e87d76438c)make -C freetile test+ ASan/UBSan (-fsanitize=address,undefined -fno-sanitize-recover=all -Wall -Wextra -Wpedantic -Werror): PASS (0.0bit-exact diff across2304^2 / 3072^2 / 4096^2 / 6144^2, packedNF4/FP4/IQ4_NL, 2/3-bit 3/7-select IR, 4 portablecodebook_dequantbackends, Mosaic refusal guard)llama-cpp-cloudtpuHost Mock PJRT (test_cloudtpu_host,pjrt_runtime_guards_test) + ASan/UBSan: PASS (IQ4_XS_LUT15selects /0gather across2304..6144xM=1,64,128,HIGHESTF32 dot precision, IEEE bit-exactMUL_MAT&GET_ROWSonM=4, K=256, N=16forIQ4_XS_LUTU4/U8-bitcast andIQ4_NL_LUTU4,BF16M=1pad8NMSE < 5e-4)0violations)codex exec -m gpt-6.2-astra, 3 rounds): caught and fixedHIGHESTdot precision on F32 IQ4 matmuls, partial/view/reused-slot SPMD &scale_dtypemismatches, alignment-safe byte-offset IQ4 codecs, TileIRIQ2_XXS/IQ3_XXSover-claiming, and JAX bench canonical 136 B parity +optimization_barrierIR checks.proof/cloud-tpu-iq4xs-select-tree/PROOF.mdRemaining Human-Gated Silicon Follow-Up
v5e/v6everification (CLOUDTPU_MOCK=0 ./build-cloudtpu/test_cloudtpu_host,python3 tools/select_tree_lut.py --emit-jax-bench, GGMLtest-backend-ops -b CLOUDTPU -o MUL_MAT) and bare-metal/dev/vfio/0(MAPS_LIBTPU=0) proof were not run in this PR and remain human-gated on#43.