[PR #3806] [Engine] Gyro-L: TQP5/TQP6/TQP7 (ggml 147-149) pack, CPU, CUDA and MMQ prompt path #4789

Open
opened 2026-11-07 15:39:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/3806
Author: @unverbraucht
Created: 10/23/2026
Status: 🔄 Open

Base: main ← Head: stock-tqp


📝 Commits (3)

  • bbd666b Gyro-L: TQP5/TQP6/TQP7 (ggml 147-149) pack, CPU and GPU support on 0.1.47
  • 9f0ed96 Gyro-L: TQP5/6/TQP7 in the trellis MMQ overlay (builds on the pinned upstream llama.cpp)
  • 5406ddd Gyro-L: the perf fixes, the pinned-build test tooling, and the docs

📊 Changes

14 files changed (+471 additions, -33 deletions)

View changed files

📝 CMakeLists.txt (+5 -1)
📝 cmake/strata_ggml_tq_overlay.cmake (+10 -7)
📝 docs/GYRO.md (+10 -3)
📝 include/strata/artifact/gguf_reader.hpp (+19 -0)
📝 include/strata/kernels/cpu/tq_cpu.hpp (+10 -1)
📝 src/kernels/cpu/tq_avx2.cpp (+71 -0)
📝 src/kernels/cpu/tq_cpu.cpp (+66 -4)
📝 src/kernels/cpu/tq_states.hpp (+20 -0)
📝 src/kernels/cuda/iq_kernels.cu (+131 -7)
📝 src/kernels/native_expert_parity.cpp (+27 -0)
📝 src/prefill/moe_mmq.cu (+11 -3)
📝 third_party/ggml-tq/tq.cuh (+67 -7)
📝 third_party/ggml/ggml-common-tq.h (+20 -0)
📝 tools/gguf_reader.py (+4 -0)

📄 Description

Problem and result

Gyro-L (agentionai's 50 GiB file, 2026-10-12) is the one Gyro file the engine refuses today: docs/GYRO.md says
"not supported: it uses another trellis family (types 147-149) that the engine does not have" (issue #3473).
Before: the load check and iq_pack reject per_layer_token_embd/expert tensors of types 147-149, and the prompt
and decode kernels have no instance for them. After: the published file packs, loads and serves like Gyro-S/M —
on the CMP 170HX (all 24,576 experts in VRAM, 262144 context, int8 KV, MTP): 32K prompt 1955.5 tok/s, decode
71.2 tok/s, coherent answers.

Issue #3473 ("Hope to have Gyro-L support soon"). This is a new expert type family, so it needs the scope agreed; it
changes no default and no existing file's answers.

Approach

The pair trellis is the same 128-value block and 8-lane × 16-value geometry as TQ2_T/TQK6/TQK7, but with 64 steps of
two weights: step t's 16-bit state (stream bit (63 - t)*K, circular) picks the first pair of the TQ2_T
codebook entry the same hash selects. So it reuses the existing infrastructure: the state tables, the int8 codebook,
the grouped-expert kernels, the MMQ tile loader (routed as IQ2_XS, the same Q8_0_16 layout) and the overlay.

  • tools/gguf_reader.py, include/strata/artifact/gguf_reader.hpp: type names and geometry (42/50/58 B).
  • include/strata/kernels/cpu/tq_cpu.hpp: tq_block_bytes for the pair layout (2 + 8K, not 2 + 4K).
  • src/kernels/cpu/tq_states.hpp, tq_cpu.cpp: tq_state_tqp/tq_states_tqp, the scalar pair row kernel, the
    147-149 routing, and tq_rows_avx2_tqp (8 states per YMM of 16 int16 weights, one VPMADDWD sum per 32-value
    group; bitwise equal to the scalar kernel).
  • src/kernels/cuda/iq_kernels.cu: TqInfo<147..149>, tqp_states8, tq_load_tqp, vec_dot_tqp_q8_1,
    Fmt<147..149>, dq_tqp/tqp_pair, dq_dispatch, iq_row_bytes, is_iq, the STRATA_*_FMTS lists and the
    decode-once SplitTqp/kSplit.
  • MMQ: src/prefill/moe_mmq.cu cases and, in cmake/strata_ggml_tq_overlay.cmake + third_party/ggml-tq/tq.cuh,
    the enumerators, traits, tqp_states8, the tq_lane_to_q8 pair branch, the mmq.cuh routing and the three
    instances. A build with -DSTRATA_GGML_DIR=<the agention llama.cpp> uses that tree's own instances instead.
  • On a pinned (upstream) ggml the trellis ids sit above GGML_TYPE_COUNT: native_expert_parity names tqp5/6/7 and
    skips the synthetic check with a message when ggml has no traits for them, and moe_mmq.cu's
    is_tq/type_bytes/type_label cover 147-149 (without that the pinned build asked ggml_blck_size about an
    unknown type at startup and died with SIGFPE).
  • docs/GYRO.md: how Gyro-L runs and what it measures.

Validation

Passed:

  • native_expert_parity --load-check <pack> <the Gyro-L GGUF> — revision 5406dddd, CMP 170HX sm_80, CUDA 13.3:
    0 failures (48 layers tqp6/tqp6, 45.12 GiB, hadamard block 128, 48 layers folded, PLE Q8_0 320,001,536 rows).
  • native_expert_parity --synthetic-hadamard tqp6/tqp6 tqp7/tqp7 tqp5/tqp5 on a build with
    -DSTRATA_GGML_DIR=<the agention llama.cpp>: 0 failures — GPU dequant bit-identical to ggml's to_float
    (0 of 4,915,200 values differ in any bit), AVX2 bitwise equal to the scalar kernel, decode-once vs per-entry
    bitwise equal.
  • end to end, this branch, pinned llama.cpp + the overlay (build-overlay/strata), the same 32K prompt used for the
    Gyro-S/M numbers: prompt 1955.5 tok/s, decode 71.2 tok/s, coherent answer. The port before the decode fixes
    measured 1806.8 / 61.3 on the same box.
  • both variants build: with the pinned llama.cpp (overlay) and with -DSTRATA_GGML_DIR=<the agention llama.cpp>.

Failed: none observed.

Not run:

  • Metal, SYCL and HIP (ROCm) kernels for TQP are not in this PR — not built, not tested; CUDA and CPU only. On a
    Mac/Intel Arc/HIP build the file loads (the CPU path) but the prompt falls back to the FP16 path.
  • 4K and 128K end-to-end on this branch (only 32K was measured); the fork's older tree measured 1144/70.0 and
    1864/70.3 with the same pack.
  • Gyro-L on a card that cannot hold all experts (this box keeps all 24,576 in VRAM, --mmap-experts).

Limits

  • The MMQ instances exist only where the ggml has the trellis types (the overlay, or the agention llama.cpp); any
    other ggml gets the FP16 prompt path, exactly as the other trellis types do.
  • The n-gram table is read from the model file as for the other Gyro files; an FP8 table
    (tools/ple_fp8_pack.py) is picked up with --ple-gguf and is already format-generic.
  • Format cross-check: halo-box/strix-llama.cpp#195 implements the same types independently; its tqp_state and
    block layout are the same reading as this one.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/3806 **Author:** [@unverbraucht](https://github.com/unverbraucht) **Created:** 10/23/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `stock-tqp` --- ### 📝 Commits (3) - [`bbd666b`](https://github.com/Niko1221/Strata/commit/bbd666bf6b61c05d39fe3327fb6bab672d452f55) Gyro-L: TQP5/TQP6/TQP7 (ggml 147-149) pack, CPU and GPU support on 0.1.47 - [`9f0ed96`](https://github.com/Niko1221/Strata/commit/9f0ed96f3966b8a30079fcdaa0bf08f0dbfa6f0f) Gyro-L: TQP5/6/TQP7 in the trellis MMQ overlay (builds on the pinned upstream llama.cpp) - [`5406ddd`](https://github.com/Niko1221/Strata/commit/5406ddddf18e4e1855a393ab64e858038e1629fe) Gyro-L: the perf fixes, the pinned-build test tooling, and the docs ### 📊 Changes **14 files changed** (+471 additions, -33 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+5 -1) 📝 `cmake/strata_ggml_tq_overlay.cmake` (+10 -7) 📝 `docs/GYRO.md` (+10 -3) 📝 `include/strata/artifact/gguf_reader.hpp` (+19 -0) 📝 `include/strata/kernels/cpu/tq_cpu.hpp` (+10 -1) 📝 `src/kernels/cpu/tq_avx2.cpp` (+71 -0) 📝 `src/kernels/cpu/tq_cpu.cpp` (+66 -4) 📝 `src/kernels/cpu/tq_states.hpp` (+20 -0) 📝 `src/kernels/cuda/iq_kernels.cu` (+131 -7) 📝 `src/kernels/native_expert_parity.cpp` (+27 -0) 📝 `src/prefill/moe_mmq.cu` (+11 -3) 📝 `third_party/ggml-tq/tq.cuh` (+67 -7) 📝 `third_party/ggml/ggml-common-tq.h` (+20 -0) 📝 `tools/gguf_reader.py` (+4 -0) </details> ### 📄 Description ## Problem and result Gyro-L (agentionai's 50 GiB file, 2026-10-12) is the one Gyro file the engine refuses today: `docs/GYRO.md` says "not supported: it uses another trellis family (types 147-149) that the engine does not have" (issue #3473). **Before:** the load check and `iq_pack` reject `per_layer_token_embd`/expert tensors of types 147-149, and the prompt and decode kernels have no instance for them. **After:** the published file packs, loads and serves like Gyro-S/M — on the CMP 170HX (all 24,576 experts in VRAM, 262144 context, int8 KV, MTP): 32K prompt **1955.5 tok/s**, decode **71.2 tok/s**, coherent answers. ## Related discussion Issue #3473 ("Hope to have Gyro-L support soon"). This is a new expert type family, so it needs the scope agreed; it changes no default and no existing file's answers. ## Approach The pair trellis is the same 128-value block and 8-lane × 16-value geometry as TQ2_T/TQK6/TQK7, but with 64 steps of **two** weights: step t's 16-bit state (stream bit `(63 - t)*K`, circular) picks the **first pair** of the TQ2_T codebook entry the same hash selects. So it reuses the existing infrastructure: the state tables, the int8 codebook, the grouped-expert kernels, the MMQ tile loader (routed as IQ2_XS, the same Q8_0_16 layout) and the overlay. - `tools/gguf_reader.py`, `include/strata/artifact/gguf_reader.hpp`: type names and geometry (42/50/58 B). - `include/strata/kernels/cpu/tq_cpu.hpp`: `tq_block_bytes` for the pair layout (`2 + 8K`, not `2 + 4K`). - `src/kernels/cpu/tq_states.hpp`, `tq_cpu.cpp`: `tq_state_tqp`/`tq_states_tqp`, the scalar pair row kernel, the 147-149 routing, and `tq_rows_avx2_tqp` (8 states per YMM of 16 int16 weights, one VPMADDWD sum per 32-value group; bitwise equal to the scalar kernel). - `src/kernels/cuda/iq_kernels.cu`: `TqInfo<147..149>`, `tqp_states8`, `tq_load_tqp`, `vec_dot_tqp_q8_1`, `Fmt<147..149>`, `dq_tqp`/`tqp_pair`, `dq_dispatch`, `iq_row_bytes`, `is_iq`, the `STRATA_*_FMTS` lists and the decode-once `SplitTqp`/`kSplit`. - MMQ: `src/prefill/moe_mmq.cu` cases and, in `cmake/strata_ggml_tq_overlay.cmake` + `third_party/ggml-tq/tq.cuh`, the enumerators, traits, `tqp_states8`, the `tq_lane_to_q8` pair branch, the `mmq.cuh` routing and the three instances. A build with `-DSTRATA_GGML_DIR=<the agention llama.cpp>` uses that tree's own instances instead. - On a pinned (upstream) ggml the trellis ids sit above `GGML_TYPE_COUNT`: `native_expert_parity` names tqp5/6/7 and skips the synthetic check with a message when ggml has no traits for them, and `moe_mmq.cu`'s `is_tq`/`type_bytes`/`type_label` cover 147-149 (without that the pinned build asked `ggml_blck_size` about an unknown type at startup and died with SIGFPE). - `docs/GYRO.md`: how Gyro-L runs and what it measures. ## Validation **Passed:** - `native_expert_parity --load-check <pack> <the Gyro-L GGUF>` — revision 5406dddd, CMP 170HX sm_80, CUDA 13.3: `0 failures` (48 layers tqp6/tqp6, 45.12 GiB, `hadamard block 128, 48 layers folded`, PLE Q8_0 320,001,536 rows). - `native_expert_parity --synthetic-hadamard tqp6/tqp6 tqp7/tqp7 tqp5/tqp5` on a build with `-DSTRATA_GGML_DIR=<the agention llama.cpp>`: `0 failures` — GPU dequant bit-identical to ggml's `to_float` (0 of 4,915,200 values differ in any bit), AVX2 bitwise equal to the scalar kernel, decode-once vs per-entry bitwise equal. - end to end, this branch, pinned llama.cpp + the overlay (`build-overlay/strata`), the same 32K prompt used for the Gyro-S/M numbers: prompt 1955.5 tok/s, decode 71.2 tok/s, coherent answer. The port before the decode fixes measured 1806.8 / 61.3 on the same box. - both variants build: with the pinned llama.cpp (overlay) and with `-DSTRATA_GGML_DIR=<the agention llama.cpp>`. **Failed:** none observed. **Not run:** - Metal, SYCL and HIP (ROCm) kernels for TQP are not in this PR — not built, not tested; CUDA and CPU only. On a Mac/Intel Arc/HIP build the file loads (the CPU path) but the prompt falls back to the FP16 path. - 4K and 128K end-to-end on this branch (only 32K was measured); the fork's older tree measured 1144/70.0 and 1864/70.3 with the same pack. - Gyro-L on a card that cannot hold all experts (this box keeps all 24,576 in VRAM, `--mmap-experts`). ## Limits - The MMQ instances exist only where the ggml has the trellis types (the overlay, or the agention llama.cpp); any other ggml gets the FP16 prompt path, exactly as the other trellis types do. - The n-gram table is read from the model file as for the other Gyro files; an FP8 table (`tools/ple_fp8_pack.py`) is picked up with `--ple-gguf` and is already format-generic. - Format cross-check: `halo-box/strix-llama.cpp#195` implements the same types independently; its `tqp_state` and block layout are the same reading as this one. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4789
No description provided.