Skip to the content.

Native 753B serving — staged plan (GLM-5.2 glm_moe_dsa)

2026-06-23. The track to make fak serve the real GLM-5.2 753B model natively, on the pure fak engine, end to end. This note records the plan and the first slice that landed today; it is a living map, not a finished product. The track is multi-month and will not finish in one session.

Current direction — and a reconciliation (#917). Native 753B GLM-5.2 is the active, committed track; this plan is the single current direction. Earlier GLM-5.2 planning (mid-June 2026) treated in-kernel native serving as out-of-scope / an air-gapped reference path only; that posture is superseded once datacenter-GPU access lifted the compute gate and the loader, quantized device GEMM, and --cpu-offload-experts rungs began landing on origin/main. The dated GLM-5.2 witnesses (2026-06-21 →) are point-in-time snapshots — read their “out of scope [for that session]” residuals as superseded-by-progress along this plan, not as the current posture. The external-engine serving track is a separate, parallel deliverable (#413 runbook), not a replacement for this one.

Where we start

fak already runs GLM-5.2’s forward bit-exact on GPU kernels (cosine 1.0) and its real-oracle Generate matches HF greedy — but only at small scale and in f32. The wall between that and serving the actual 753B model is four pillars:

  1. GGUF glm_moe_dsa config + weight parse — read a real GLM-5.2 checkpoint.
  2. Quantized (non-f32) device GEMM — run the matmuls at Q4_K/Q6_K/Q8_0, not f32.
  3. Multi-GPU NCCL / tensor-parallel sharding — the model does not fit one GPU.
  4. CPU-offload serving — experts that dwarf VRAM live in host RAM (and beyond).

A survey of the existing code (four parallel readers + a synthesis pass) found that the substrate is much further along than greenfield, and that the honest gaps are specific. The good and the missing, per pillar:

Pillar 1 — GGUF parse

Pillar 2 — quantized device GEMM

Pillar 3 — multi-GPU

Pillar 4 — CPU offload

First slice landed today (P1, foundationOrder 1)

applyGLMMoeDsaConfig in internal/ggufload/gguf.go — a glm_moe_dsa branch in (*File).Config that reads the MoE + MLA + DSA-indexer metadata KV into the existing model.Config fields, mirroring applyGemma4Config. Plus a (*File).Bool scalar accessor and a table-driven golden test (gguf_glm_test.go).

Time estimate summary

The remaining uncompleted milestones (7 items) are estimated at 13–20 weeks total:

Range: 13–20 weeks (1–2 weeks per item × 7 items, with P3 items weighted heavier due to complexity).

Staged plan (dependency-ordered)

Each milestone is a shippable green step with a one-line acceptance test. “ships now” means it needs nothing downstream and can land before the heavy pillars.

Phase Milestone Acceptance Depends on
P1 Config parse applyGLMMoeDsaConfig reads MoE+MLA+DSA metadata into Config go test ./internal/ggufload -run TestGLMMoeDsaConfig green — (landed)
P1 Tensor names (1:1 ✅) CanonicalTensorNameArch maps the MLA/indexer attn tensors, ffn_gate_inp router, exp_probs_b, ffn_*_shexpshipped b1c0f04; the batched ffn_*_exps stay unmapped (fail loud) for the splitter the 1:1 names resolve (golden TestGLMMoeDsaCanonicalTensorNames); ffn_*_exps still “no canonical mapping” until the splitter P1 Config parse
P1 Expert splitter ✅ a [E,out,in] ffn_*_exps blob splits into per-expert canonical 2-D tensors on load (wired into both loader loops) — shipped f673dca synthetic *_exps loads bit-equal to manual slicing ✅ + an e2e GGUF→F32Tensors→per-expert gate P1 Tensor names (1:1)
P1 E2E ✅ (load + forward + oracle) a complete glm_moe_dsa GGUF resolves its full tensor set + splits experts (2e632ef), LoadModelForward RUNS the native glm_dsa forward (d3e1c1d), AND it forwards BIT-FOR-BIT == a model built directly from the same canonical tensors (431b52a, ...ForwardMatchesReference) — so the round-trip is correctness-faithful, not just structural. P1 is COMPLETE: fak loads AND forwards glm_moe_dsa from GGUF, proven. GGUF-loaded argmax + logits == reference ✅ (bit-exact) P1 Expert splitter
P2 Vulkan Q4_K GEMM Vulkan compute.Backend gains a Q4_K dequant-fused GEMV→GEMM Vulkan Q4_K MatMul vs cpu-ref at cosine floor + argmax-exact (AMD node) ships now (kernel); real bytes need P1
P2 Metal HAL + CUDA witness (CUDA ✅) expose metalgemm Q4_K via the unified HAL (open); the -tags cuda Q8_0/Q4_K gates run + recorded on an sm_80 node, 2026-06-24 Metal Q4_K via HAL host-witnessed cosine (open); CUDA recorded: Q8_0 0.99999980, Q4_K 1.00000000, argmax-exactwitness P2 Vulkan Q4_K
P2 Full-model quant forward (Q8 ✅) end-to-end Q8 memory-lean glm_moe_dsa forward from GGUF — LoadModelQuantForward+Session decode RUN to finite logits (shipped 0c2d74f, ...QuantLoadForwards); the mixed-precision Q4_K lane + a faithful argmax-match (needs a non-degenerate fixture — Q8-vs-f32 is uncorrelated on random tiny weights, by design) remain Q8 full-model forward finite ✅; Q4_K mixed-precision ◻ P1 E2E load; P2 Vulkan Q4_K
P3 Collective bridge ✅ BackendCollective: model.Collective wrapping compute.CollectiveBackend (the NCCL plug-in seam) — shipped 41017e3 BackendCollective == LocalCollective at max|Δ|=0 ✅; ForwardTP equal both ways (cpu-ref) ✅ ships now (de-risks seam); real use needs P1+P2
P3 MLA-aware TP + EP an MLA-aware (not head-parallel) TP decomposition + expert-parallel placement; quant-aware sharding ForwardTP sharding-invariant on a synthetic glm_moe_dsa+MoE quant model P3 Collective bridge; P1 E2E; P2 Full-model
P3 Host cross-process collective ✅ DistComm: a coordinator-rooted process group (host []float32) running AllReduceSum/AllGather over a REAL wire — the distributed twin of LocalCollective, mirroring TCPTransport; de-risks the rank-coordination + wire-protocol + rank-order-reduce + fail-closed plumbing the device rung’s wire swap stands on. Cross-PROCESS, NOT multi-GPU/NCCL. each rank holds only its part; every rank’s result == LocalCollective/sumPartialsRankOrder byte-for-byte (max|Δ|=0) on loopback across ranks {1,2,3,5} ✅; fail-closed (ragged / mis-width / op-desync) deadlock-free ✅ ships now (de-risks the device row); the multi-GPU claim still needs the device row below
P3 Real cross-process NCCL (device) a non-cpu-ref device compute.CollectiveBackend (NCCL/RCCL on the GPU node, or a device-tensor TCP transport): add AllReduce/AllGather/ReduceScatter/AllToAll to cudaBackend + flip Caps().Collective. Host plumbing now de-risked by DistComm. a 2-GPU/2-process all-reduce of a device tensor matches cpu-ref — only now may “multi-GPU” be claimed P3 Host cross-process collective; P3 MLA-aware TP
P4 Device paging primitive ✅ (standalone) an upload→compute→free pagedKernel with an observable pageIn counter — shipped f54e01a (the first honest “paged to device on demand”) GEMM bit-equal to resident ✅; paged weight absent from halW ✅; pageIn counts each page-in ✅ — standalone primitive; halW-integration is P4 Async streaming ships now (existing fixture); real win needs P2
P4 Async expert streaming per-weight VRAM ring + async/pinned H2D so host-resident experts stream per-layer; serve loop auto-sizes the split a >VRAM glm_moe_dsa serves on the GPU node at a measured tok/s within budget P4 paging primitive; P2 Full-model; P1 E2E
Integration 753B serve real GGUF → mixed-precision device GEMM → multi-GPU TP/EP → CPU/NVMe-tiered offload, with a real-GGUF golden native 753B Generate matches the real-oracle greedy at the agreed bar on the GPU server P3 Real NCCL; P4 Async streaming; all P1/P2

Risks / honesty ledger

Load-bearing existing code (reuse, don’t duplicate)

ggufload generic reader + full dequant suite · applyGemma4Config (the template P1 mirrored) · model.Config MoE/MLA/DSA fields · glm_dsa.go native forward (the downstream consumer that fixes the target canonical names) · CUDA k_q4k_gemm/k_q8_gemm