Skip to content

feat(adapters): HRM-Text dual-timescale recurrent adapter - #60

Merged
synapticode-ai merged 1 commit into
mainfrom
feat/hrm-text-adapter
Jun 13, 2026
Merged

feat(adapters): HRM-Text dual-timescale recurrent adapter#60
synapticode-ai merged 1 commit into
mainfrom
feat/hrm-text-adapter

Conversation

@synapticode-ai

Copy link
Copy Markdown
Collaborator

First recurrent architecture in the adapter registry — the "compresses recurrent architectures" capability (probe HRM_PROBE_20260613T011321Z, 2026-06-13).

What

  • New src/terncore/adapters/hrm_text.py (HrmTextForCausalLM, model_type=hrm_text).
  • One registry entry in adapters/__init__.py; registry canonical-set test updated to match.
  • New tests/test_hrm_text_adapter.py (22 tests).

Architecture notes

  • Dual-timescale recurrence: two separately-parameterised stacks (H_module slow z_H / L_module fast z_L) share a block design but own distinct weights. Per forward the L-stack executes (2 H-cycles × 3 L-steps), the H-stack — equal footprint, asymmetric reuse leverage. stack_of() tags H/L/shared for per-stack reporting.
  • Fused projections: the safetensors stores attn.gqkv_proj (gated QKV) and mlp.gate_up_proj; the converter reads them directly → 128 fused ternary tensors (64 H + 64 L), not the 256 of the split state_dict. No H/L collision.
  • Parameterless MagicNorm: only protected tensors are embeddings, untied LM head, and the 1-D recurrent init z_L_init (named explicitly).
  • Reuses the standard substring + dimensionality classification — no new quant logic.

Verification (sapientinc/HRM-Text-1B)

Dry-run and full CLI convert both: 128 ternary / 3 fp16 / 83.0% ternary / 3.07× vs bf16 / ~63 s, byte-for-byte identical to the runtime-registered prototype. 96 adapter/registry/validation tests pass locally.

Scope

Pure addition — no existing adapter or converter logic touched (only the registry list + its canonical-set test). Footprint only: no throughput (recurrence-forward runtime integration is scoped, not done) and no coherence claim (Lane B held under the program QAT hold).

🤖 Generated with Claude Code

First recurrent architecture in the adapter registry. HRM-Text
(HrmTextForCausalLM, Sapient HRM-Text) is dual-timescale: two separately-
parameterised H/L block stacks (slow z_H / fast z_L) that share a block
design but own distinct weights; per forward the L-stack executes 6x and
the H-stack 2x. The safetensors stores fused attn.gqkv_proj (gated QKV)
and mlp.gate_up_proj — the converter reads these directly (128 fused
ternary tensors for the 1B, 64 H + 64 L; not the 256 split state_dict).
MagicNorm is parameterless, so the only protected tensors are the
embeddings, the untied LM head, and the 1-D recurrent init z_L_init
(named explicitly). classify_weight reuses the standard substring+
dimensionality policy; a stack_of() helper tags H/L/shared for per-stack
reporting of the asymmetric reuse leverage.

Pure addition: one new adapter file + one registry entry (registry
canonical-set test updated to match). No existing adapter or converter
logic touched. Verified against sapientinc/HRM-Text-1B: dry-run + full
convert both 128 ternary / 3 fp16 / 83.0% ternary / 3.07x vs bf16 /
~63s, matching the runtime-registered prototype byte-for-byte
(probe HRM_PROBE_20260613T011321Z). Footprint only — no throughput
(recurrence-forward runtime integration scoped, not run) and no
coherence claim (Lane B held under program QAT hold).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@synapticode-ai
synapticode-ai merged commit c8c7244 into main Jun 13, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant