[note] M3 HyperFormer: four risks to watch #5

Closed
opened 2026-11-11 18:40:13 +00:00 by dsh · 1 comment
Member

Note from the TARDITS side after M2 (#3), not a blocker. M3 (#4) moves from one recurrent path to a hybrid arch, so these are the places I would expect silent breakage.

  1. Hybrid is broader than M2. is_hybrid plus per-layer is_recr_impl and a KV cache for attention layers changes both prefill and decode. Test the recurrent and attention layers separately before testing the mixed graph.

  2. Define the HyperFormer golden reference first. The Python side has no KV cache, so the M3 C++ golden needs an independent reference path, or an explicitly documented expected mismatch. Do not reuse the RAT golden as if the hybrid decode path were identical.

  3. Keep the scan op level-agnostic. ggml_tardits_scan should be reusable for RAT levels 2-4; cd_mul is the next numerical minefield after the hybrid path works. Avoid baking level-1 assumptions into the op.

  4. Add numeric CI fixtures, not only docs. A tiny single-step and short-prefill fixture for both the recurrent and hybrid paths would catch M3 changes that move the RAT numbers silently. The 3.8e-6 / 3.3e-6 checks from M2 are a good fixture shape.

M2 record: #3

Note from the TARDITS side after M2 (#3), not a blocker. M3 (#4) moves from one recurrent path to a hybrid arch, so these are the places I would expect silent breakage. 1. **Hybrid is broader than M2.** `is_hybrid` plus per-layer `is_recr_impl` and a KV cache for attention layers changes both prefill and decode. Test the recurrent and attention layers separately before testing the mixed graph. 2. **Define the HyperFormer golden reference first.** The Python side has no KV cache, so the M3 C++ golden needs an independent reference path, or an explicitly documented expected mismatch. Do not reuse the RAT golden as if the hybrid decode path were identical. 3. **Keep the scan op level-agnostic.** `ggml_tardits_scan` should be reusable for RAT levels 2-4; `cd_mul` is the next numerical minefield after the hybrid path works. Avoid baking level-1 assumptions into the op. 4. **Add numeric CI fixtures, not only docs.** A tiny single-step and short-prefill fixture for both the recurrent and hybrid paths would catch M3 changes that move the RAT numbers silently. The 3.8e-6 / 3.3e-6 checks from M2 are a good fixture shape. M2 record: https://git.pvlb.dev/ml-lab/llama.cpp/issues/3
Author
Member

Thanks - this note was spot on. How each point landed in M3 (0b47c9e60):

  1. Hybrid is broader than M2. Tried it first and hit exactly the class of silent breakage you meant: build_inp_mem_hybrid() builds both sub-inputs and a uniform file then crashes in set_input on the unused half (tensor not in graph). Resolution: two arch strings - tardits = recurrent (RAT), tardits-hyper = attention (HyperFormer). The arch string is now the memory-layout contract; hybrid stays available for genuinely mixed files later. RAT was re-verified unchanged after the switch.
  2. Golden reference first. Hyper golden = PyTorch full-window forward (the Python model has no KV cache), and the C++ prefill + KV-cached decode must reproduce it - which it does. Documented in devops/runtime.md (M3 section); no reuse of the RAT step semantics.
  3. Scan op level-agnostic. ggml_tardits_scan is untouched by M3 and still level-1 complex-plane arithmetic. Levels 2-4 are a separate kernel question (cd_mul); the caveat is written into devops/runtime.md and the new M4 issue (#6).
  4. Numeric CI fixtures. Added tardits2gguf/tools/check_parity.sh: four checks (single-step + prefill-44 for both families) against committed goldens, tolerance configurable, non-zero exit on regression. Currently 4/4 PASS: RAT 3.815e-06 / 3.338e-06, hyper 1.907e-06 / 1.907e-06. Greedy chains exact. Both generate via stock llama-completion.

A true CTest fixture (requires generating a tiny random-init GGUF in the build tree) is still on the list - tracked in #6.

Thanks - this note was spot on. How each point landed in M3 (`0b47c9e60`): 1. **Hybrid is broader than M2.** Tried it first and hit exactly the class of silent breakage you meant: `build_inp_mem_hybrid()` builds both sub-inputs and a uniform file then crashes in `set_input` on the unused half (tensor not in graph). Resolution: **two arch strings** - `tardits` = recurrent (RAT), `tardits-hyper` = attention (HyperFormer). The arch string is now the memory-layout contract; hybrid stays available for genuinely mixed files later. RAT was re-verified unchanged after the switch. 2. **Golden reference first.** Hyper golden = PyTorch full-window `forward` (the Python model has no KV cache), and the C++ prefill + KV-cached decode must reproduce it - which it does. Documented in `devops/runtime.md` (M3 section); no reuse of the RAT `step` semantics. 3. **Scan op level-agnostic.** `ggml_tardits_scan` is untouched by M3 and still level-1 complex-plane arithmetic. Levels 2-4 are a separate kernel question (`cd_mul`); the caveat is written into `devops/runtime.md` and the new M4 issue (#6). 4. **Numeric CI fixtures.** Added `tardits2gguf/tools/check_parity.sh`: four checks (single-step + prefill-44 for both families) against committed goldens, tolerance configurable, non-zero exit on regression. Currently 4/4 PASS: RAT 3.815e-06 / 3.338e-06, hyper 1.907e-06 / 1.907e-06. Greedy chains exact. Both generate via stock `llama-completion`. A true CTest fixture (requires generating a tiny random-init GGUF in the build tree) is still on the list - tracked in #6.
dsh closed this issue 2026-11-11 19:07:09 +00:00
Sign in to join this conversation.
No description provided.