APR port, stage 4: trellis decode and Hadamard rotation on the GPU paths

- third_party/ggml/ggml-common-tq.h: the fork's TQ2_T/TQK6/TQK7 block
  structs and 2048-point codebook (device table).
- iq_kernels.cu: Fmt<144..146> (the fork's tq.cuh lane decode against q8_1,
  4 q8_1 blocks per 128-block), dq_tq in dq_dispatch (prompt FP16 path,
  embedding), is_iq / row bytes; hadamard_rows / hadamard_rows_f16
  (shared-memory FWHT in the CPU's butterfly order) and
  hadamard_device_signs; native_expert_grouped rotates h when
  NativeExpertLayout::had_block is set.
- verify.cpp (local GPU), remote_experts.cpp (helper GPUs), prefill.cpp
  (FP16 fallback; folded layers never take MMQ) rotate x / h into their
  own buffers; the shared expert and the CPU doorbell copy keep x.
- native_expert_parity --synthetic-hadamard; ctests for tqk6/tqk7 and
  tq2_t when ggml is the agention fork.
- generate.cpp: APR packs run only with STRATA_APR=1 until validated end
  to end on a GPU.
- hip_backend.cmake: gfx1151 as an unvalidated architecture.

Rebased onto upstream 0.1.39: native_expert_grouped takes the separate
SwiGLU / rotate / q8_1 passes when the down weights are folded (the one-pass
swiglu_q8_1 kernel has no h to rotate); the new decode peer GPU
(peer_experts.cpp) rotates its private input copy and passes the down signs,
as remote_experts.cpp does.

Ported from agentionai/Strata rc2 6c7abde (rc2 = 9ff02c9), author Laurent Zuijdwijk.
This commit is contained in:
Laurent Zuijdwijk authored and Niko1221 committed 2026-10-15 21:29:38 +02:00
1 parent f47b0385f3
commit fbf045eb6a
13 files changed
+629 -26

No files matched your search

+12 -6
View File
@@ -3016,13 +3016,19 @@ int main(int argc, char** argv) {
(void) strata::prefill::mmq::supported(f.d_type);
#endif
}
// APR (prism.hadamard) packs: the CPU pool rotates the expert activations (native_quant_act / _h), the GPU
// expert kernels, the remote GPUs and the prompt path do not yet. Refused here
// rather than run with unrotated activations, which would produce plausible-looking garbage.
// APR (prism.hadamard) packs: every expert path rotates its activations (CPU pool: native_quant_act / _h;
// GPU verify, remote GPUs, prompt FP16 path: hadamard_rows), but the GPU side has been checked
// by native_expert_parity only, not end to end on a GPU: opt-in until it has (STRATA_APR=1).
if (strata::kernels::cpu::hadamard_spec().any()) {
std::fprintf(stderr, "strata generate: this pack's experts are Hadamard-folded (hadamard.txt, an APR "
"model); the GPU expert paths cannot apply the activation rotation yet\n");
return 1;
const char* apr = std::getenv("STRATA_APR");
if (apr == nullptr || apr[0] != '1') {
std::fprintf(stderr, "strata generate: this pack's experts are Hadamard-folded (hadamard.txt, an APR "
"model), whose GPU path is not validated end to end yet; set STRATA_APR=1 to "
"run it anyway\n");
return 1;
}
std::fprintf(stderr, "strata generate: APR pack: Hadamard-folded experts (block %d), experimental\n",
strata::kernels::cpu::hadamard_spec().block);
}
}
const bool native_pack = strata::kernels::cpu::expert_layout().native;