M2: tardits arch skeleton in llama.cpp (RAT level 1 parity) #3
Labels
No labels
NaNs
area/android
area/backup
area/build
area/docs
area/dsh
area/forgejo
area/gguf
area/host
area/kernel
area/runtime
area/security
bootcamp
needs-operator
note
priority/later
priority/next
priority/now
type/bug
type/experiment
type/task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
ml-lab/llama.cpp#3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Register the
tarditsarch in C++ and run RAT level 1 end-to-end inside the fork, with numeric parity against the Pythonstepreference.Scope (detail:
devops/runtime.md, learning path:devops/cxx.md):LLM_ARCH_TARDITS+ name/KV/tensor maps,llama_model_tarditsinsrc/models/models.h, newsrc/models/tardits.cpp,llama_model_mapping()case,llm_arch_is_recurrent()entry +n_embd_s(), saver switch.load_arch_hparams/load_arch_tensorsfor the GGUF from #2: split.real/.imagplanes, 2-D flattened tensors, plane-majoroutput.weight.v (x) conj(k),S = cd_mul(S, gamma) + kvin recurrent memory, recall, complex out_proj, SAIL, branch norm, real LM head. Prefill v1 = unrolled steps.tardits2gguf/goldens/rat45m.{npz,json}; tolerance ~1e-4 relative (f32), documented; grep the goldens, never the scan.Blocked by nothing now (#2 converter is in). Expected first artifact: one-token step logits matching the golden within tolerance, then 44-token prefill and the greedy 8
[14, 0, 65, 78, 68, 0, 84, 72].M2: tardits arch skeleton in llama.cpp (RealGPT parity)to M2: tardits arch skeleton in llama.cpp (RAT level 1 parity)M2a is in (
cd45cd306, pushed): the arch loads and its first-token logits match PyTorch.LLM_ARCH_TARDITS+ name/tensor maps,src/models/tardits.cpp(loader for the split real/imag planes,HyperRMSNormvia stockrms_normon the concatenated 2C reals withweight/sqrt(2), eps 5e-7, plane-major LM head), factory + rope-type cases.tardits.context_length,.embedding_length,.block_count,.attention.head_count[_kv],.attention.layer_norm_rms_epsilon); both GGUFs regenerated.tardits2gguf/tools/tardits_parity.cpp(linkslibllama, decodes one token id, compares to a raw f32 golden). Result onrat45m.gguf, token 52: max_abs_diff = 3.815e-06, argmax 72 on both sides. Pythonstepgolden intardits2gguf/goldens/rat45m_t0.{f32,json}.Known gaps, all M2b (recipe written up in
devops/research/m2-notes.md):n_tokens == 1, sollama-clion a normal prompt aborts;v (x) conj(k)+ decay + recall path is scaffolded underTARDITS_USE_STATEbut its layout is not validated yet (the zero-state shortcut is what passed);test-llama-archsauto-enumerates the new enum and goes red - exclude it viaarch_supported()until it has a fixture;llm_arch_is_recurrent()-> true andllm_arch_supports_save()-> false still needed.M2b plan from the notes: state row layout
[p][v][k](real heads then imag heads,n_embd_s = 2*H*hs*hsderived fromssm_d_state*ssm_d_inner, so no hparams patch),build_rs_inp/build_rs+ per-token unrolled update + oneggml_cpywrite-back, then 44-token prefill parity and then_ubatch=16split check.M2 is done (
e9559bd84): RAT runs in llama.cpp, end to end.What landed:
llm_arch_is_recurrent()-> true,llm_arch_supports_save()-> false; state size derived byn_embd_s()fromssm_d_inner = n_head,ssm_d_state = 2*hs*hs*hd, so nollama-hparams.*patch.ggml_tardits_scan(ggml/include/ggml.h,ggml/src/ggml.c,ggml/src/ggml-cpu/{ops.h,ops.cpp,ggml-cpu.c}):S = S (x) gamma + v (x) conj(k),out = S (x) qfor the whole ubatch, returnsout_r | out_i | new_statein one tensor (RWKV-WKV7 pattern). The graph unroll was abandoned: it blewgraph_max_nodes = 8*n_tensorson prefill.src/models/tardits.cpp: batched projections/SAIL/norms over the ubatch,build_rsstate read per layer, one scan op,ggml_cpystate write-back.v (x) conj(k)imag sign - the zero-state shortcut had masked it (same 5.03 diff the old kv path showed). Fixed the golden greedy chain; addedtardits2gguf/tools/tardits_prefill.cpp; excluded the arch from the synthetic test fixture.Verified (all against the Python
stepreference, never the scan):max_abs_diff=3.815e-06, argmax 72 bothmax_abs_diff=3.338e-06, identical forn_ubatch=44andn_ubatch=16[0, 52, 72, 69, 0, 83, 84, 65]matches PyTorch across 8 separatellama_decodecalls (state write/read works)llama-completion -m models/tardits/rat45m.gguf -p "The quick brown fox" -n 16->"The quick brown fox is the same thi"llama-tokenizeround-trips the char vocab;test-llama-archsskips tardits (151/151 passed)Known limits: single sequence (
n_seqs == 1assert), notest-backend-opsentry for the new op, save disabled by design. Next: #4 (HyperFormer) - the arch must flip tollm_arch_is_hybridwith per-layeris_recr_implfor M3.