Repository navigation
feat(cloudtpu): M4C decode lift — K-major tile-aligned quants, split-X Q4 dot, KV donation, BF16 MXU - #25
Open
saariuslystoned wants to merge 8 commits into
Open
feat(cloudtpu): M4C decode lift — K-major tile-aligned quants, split-X Q4 dot, KV donation, BF16 MXU#25saariuslystoned wants to merge 8 commits into
saariuslystoned wants to merge 8 commits into
Conversation
…T runtime & host mock tests (#16)
…equant, GCC13, MAPS_LIBPYTHON=0)
…permute lowering for GGUF inference
…& SubgraphPlanCache (4.9x v5e-1 decode)
… 11 + multi-chip single-device assignment
…X Q4 dot, KV donation, BF16 MXU, ROPE fix
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.
Stacked on #19 (
feat/ggml-cloudtpu-m4) for Issue #16 (Track 1:ggml-cloudtpu).Summary
Six TPU-native decode & kernel upgrades with zero Python at runtime (
MAPS_LIBPYTHON=0,LDD_LIBPYTHON=0):[B3, B2, NB, 16/32, N]+[B3, B2, NB, N]): Aligns quantized weights and scales directly with TPU(8, 128)HBM tiles (0%minor-dim padding vs4x/8xbloat on[N, NB, 32/16]), eliminates runtime weight reshapes/transposes, broadcasts scales along axis3without HBM materialization, and gathers selected rows directly on the last axis inGET_ROWS.CLOUDTPU_Q4_SPLIT_DOT=1): Replaces weightstablehlo.concatenatewithdot(x_lo, w_lo) + dot(x_hi, w_hi)on[NB, 16, N]nibble halves (+78%onLlama-3.1-8B Q4_K_Mdecode vs single concatenated dot:69.56vs39.34 tok/s).SET_ROWSdynamic_update_slice+ in-place KV buffer donation (CLOUDTPU_DONATE_KV=1): Emits{tf.aliasing_output = idx : i32}+ExecutableBuildOptionsProto.alias_passthrough_paramswith runtime exclusive-ownership donation checks (non_donatable_input_indicesfallback when aliased).ROPEn_dims == 0probe fix: Keepsrope_freqs.weightresident in TPU HBM duringllama-model-loaderbuffer placement, eliminating the 65 CPU/TPU graph splits per token on Llama-3.1-8B.CLOUDTPU_MATMUL_BF16=1): Keeps affineq * d + mdequantization in F32 VPU precision and casts once toBF16for native MXU contraction (dense F32 weights stay F32).CLOUDTPU_ASYNC_COLLECTIVES=1): Encodes all 7 XLA TPU async collective flags intoDebugOptions.xla_backend_extra_options+ monotoniclaunch_idonP > 1, plus axis-aware SPMD sharding for K-major quantized weights andCLOUDTPU_MAX_FUSE_OPS=512(CLOUDTPU_FUSE_ATTN=0/1).Live
$0Colabv5e-1Verification (libtpu.so,MAPS_LIBPYTHON=0)Op & Host Parity
PASSEDacross all 100 tracked files (0forbidden paths/binaries).test_cloudtpu_host:PASSED(0failures) on Host Mock AND livev5e-1(CLOUDTPU_MOCK=0), includingdynamic_update_slice+{tf.aliasing_output},alias_passthrough_params,DebugOptions.xla_backend_extra_options, and both Q4 split-dot / single-dot modes.v5e-1test-backend-ops -b CLOUDTPU(CLOUDTPU_MOCK=0):SET_ROWS:65/65|ROPE:287/287|GET_ROWS:56/56MUL_MAT q4_K:114/114(split=1&split=0) |q6_K:63/63|q8_0:102/102|q4_0:102/102CLOUDTPU_MOCK_DEVICES=4):MUL_MAT q4_K&q8_0passed.End-to-End GGUF Throughput (
llama-bench -ngl 99 -fa 1 -p 512 -n 64 -r 3)pp512pp512tg64tg64(FUSE_ATTN=0/1)tg64LiftQwen2.5-1.5B-InstructQ4_K_M28,132.2722,220.93192.06190.19/209.88Qwen2.5-1.5B-InstructQ8_028,371.3029,662.17202.96206.00/210.63Meta-Llama-3.1-8B-InstructQ4_K_M4,726.566,524.2638.7469.56/70.24Meta-Llama-3.1-8B-InstructQ8_04,237.416,963.3153.0660.33/57.66llama-cli):17 * 23 = 391verified on livev5e-1.MAPS_CHECKED=1 MAPS_LIBPYTHON=0,LDD_LIBPYTHON=0.0active Colab sessions ($0GCP spend).