HRM-Text, Looped Transformers, Standard Transformers, and Attention Residuals
This note compares HRM-Text with standard transformers, looped transformers, and
attention-residual transformers using the local resources in resource/.
The most important comparison convention is:
Compare models at the same number of executed transformer-block applications,
not at the same number of parameters.
This matters because HRM-Text and looped transformers reuse blocks across
recurrent steps. A standard transformer with the same number of parameters or
the same config value n_layers is not necessarily doing the same number of
block computations.
Source Map
- HRM-Text architecture:
resource/HRM-Text/models/baselines/hrm_nocarry_bp_warmup.py - HRM-Text transformer block:
resource/HRM-Text/models/transformer.py - HRM-Text attention, SwiGLU, RoPE, RMSNorm helpers:
resource/HRM-Text/models/layers.py - Standard transformer wrapper:
resource/HRM-Text/models/baselines/transformer_wrapper.py - Looped baselines:
resource/HRM-Text/models/baselines/ut_nocarry.py,
resource/HRM-Text/models/baselines/trm_nocarry.py,
resource/HRM-Text/models/baselines/rins_nocarry.py - HRM-Text configs:
resource/HRM-Text/config/arch/net/hrm.yaml,
resource/HRM-Text/config/arch/net/transformer.yaml,
resource/HRM-Text/config/arch/net/trm.yaml,
resource/HRM-Text/config/arch/net/trm_match_recurrence.yaml,
resource/HRM-Text/config/arch/net/ut.yaml,
resource/HRM-Text/config/arch/size/*.yaml - Attention residual implementation:
resource/attn_res/attn_res/main.py,
resource/attn_res/README.md
Notation
All hidden states are residual-stream tensors. To keep equations readable, the
batch dimension is omitted. With batch included, every state below has shape
.
Let:
- : number of executed atomic transformer blocks used as
the comparison budget. - : hidden size.
- : sequence length.
- : token embedding residual stream. This is
the input to the first atomic transformer block. - : residual stream after atomic transformer
block has finished both its attention sublayer and its MLP sublayer. In
this report, one atomic transformer block means one attention sublayer plus
one MLP/SwiGLU sublayer. - : RMSNorm. HRM-Text uses pre-norm blocks, so normalization happens
before each sublayer. - : attention sublayer function in block . This includes the
Q/K/V projections, RoPE, attention kernel, attention gating, and output
projection. - : MLP/SwiGLU sublayer function in block .
- : the attention residual increment produced by block .
- : the intermediate residual stream after the attention increment has
been added, but before the MLP sublayer runs. This is the quantity you asked
about: it is the post-attention, pre-MLP state. - : the MLP residual increment produced by block .
- : one atomic transformer block with
parameters . - : a stack/module containing atomic
transformer blocks, with parameters
. In code, looped TF and HRM usually
loop this stack/module, not necessarily a single atomic block.
HRM-Text uses pre-norm transformer blocks. A single atomic transformer block
maps residual stream to in four conceptual steps:
- Normalize the current residual stream before attention:
- Compute the attention residual increment:
- Add that attention increment back into the residual stream:
Here is not a separate learned state. It is the intermediate residual
stream after the attention sublayer and its residual addition. It is the input
state that the MLP sublayer sees after normalization.
- Normalize , compute the MLP increment, and add it:
Combining these steps gives the compact block equation:
Therefore the residual stream after blocks is:
where:
This sum form is useful but slightly deceptive if read too quickly: and
are not independent additive constants. Each one is computed from the
current residual stream produced by all previous blocks.
HRM-Text Transformer Block Details
The HRM-Text transformer in models/transformer.py is a pre-norm decoder-style
block with final RMSNorm. In code:
Attention in models/layers.py is gated multi-head attention. For a hidden
state :
The MLP is SwiGLU:
The implementation uses PrefixLM-compatible FlashAttention metadata during
training, but the residual-stream math above is independent of the particular
attention kernel.
Are the Transformer Blocks Themselves Different?
Mostly, no. In the HRM-Text repo, the standard transformer, looped transformer
baselines, TRM baseline, RINS baseline, and HRM-Text all build their internal
computation from the same Transformer and TransformerBlock implementation:
So the core block type is the same pre-norm attention-plus-MLP transformer
block. The architectural difference is how residual streams are passed between
block applications.
| Model family | Internal TF block in local resource | What changes relative to standard TF? |
|---|---|---|
| Standard TF | HRM-Text TransformerBlock | No recurrence; one residual stream flows through distinct blocks once |
| Looped TF / Universal TF | Same HRM-Text TransformerBlock, wrapped in a recurrent loop | The same block stack is reused across cycles; the conditioning/injection stream is a design choice |
| TRM | Same HRM-Text TransformerBlock | HRM-like schedule, but H and L calls share one transformer stack |
| HRM-Text | Same HRM-Text TransformerBlock | Two recurrent streams, and ; separate H/L transformer stacks; low-level stack loops between high-level updates |
| Attention residual transformer | Separate implementation in resource/attn_res with GQA, RoPE, SwiGLU | The residual connection is changed: each sublayer receives a learned weighted mixture of previous residual sources |
Conceptually, if we hold the block internals fixed, the comparison is about
connection topology:
This means your guess is basically right: the main difference is not the
attention or MLP formula inside a block. The main difference is how the model
prepares the input residual stream for each transformer-block application.
There is one implementation-level caveat: the local attn_res repo is not using
the exact HRM-Text TransformerBlock class. It implements a similar modern
decoder block with GQA, RoPE, RMSNorm, and SwiGLU, then changes the residual
routing. For a clean research comparison, one would ideally implement attention
residual routing around the exact same HRM-Text block.
Same Atomic Blocks, Different Connection Operator
Define a generic pre-norm atomic transformer block:
Here is the residual stream prepared for the block, is the
post-attention residual stream, and is the
post-MLP residual stream.
A stack of such atomic blocks is:
The architectural difference is mostly the rule for constructing the stack input
:
-
Standard transformer: one residual stream, untied depth. The connection
rule is , then
. Block just receives the output
of block . Here indexes atomic transformer
blocks. -
Looped transformer: one residual stream, tied recurrent depth. A generic
connection rule is
, then
. The same
-block stack parameters are reused across cycles. Here
is an optional conditioning stream. The local Universal
Transformer baseline uses , but a looped transformer can also
use or a learned/conditional summary. The code calls this
recurrent statez; this report writes it as to keep it
visually separate from HRM’s states. -
HRM: two residual streams, two module roles, and partial weight tying
within each role.- Low-level connection: , then
. This is a looped
-block transformer stack conditioned on the current high-level state. - High-level connection: , then
. This applies an -block
high-level stack after several low-level refinements.
- Low-level connection: , then
-
Attention residuals: one feed-forward depth order, but learned residual
routing. The connection rule is , then . The input
stream is a learned softmax-weighted mixture of previous residual sources, not
just the latest stream or a fixed injected sum.
So, if all models used the exact same attention and MLP sublayers, the
difference would still remain:
Standard Transformer
The standard transformer baseline is TransformerWrapper, which calls the same
underlying Transformer stack once:
The standard transformer has one residual stream. The block index is both a
time/depth index and a parameter index: block 1 uses , block 2 uses
, and so on.
Initialization:
For each block :
Final model output state:
Properties:
- There is one residual stream.
- Each block has distinct parameters.
- The computation depth is exactly atomic transformer blocks.
- Information from earlier layers persists only through additive residuals and
whatever later attention/MLP layers choose to transform.
At fixed block count , this is the reference architecture. It
has more distinct parameters than a looped model that reuses a smaller stack,
but the same number of executed block applications.
Looped Transformer
The simplest looped transformer repeats a shared transformer stack. The
Universal Transformer baseline in ut_nocarry.py has one recurrent residual
stream , where is the recurrence cycle. The local
code calls this state z; here I write it as because it is
the looped model’s residual stream.
where is the learned initial latent state in the local code.
At each cycle, the recurrent state can optionally receive a conditioning or
injection stream :
Here is the input residual stream for cycle . It plays the same
role as would play for an ordinary transformer stack, except that it is
formed from the previous recurrent state plus whatever conditioning stream the
experiment chooses.
Common choices are:
- No repeated injection: . The input is present only through
the initial state, for example . - Input-injected loop: . This is the local
ut_nocarry.pystyle and is the closest single-state analogue of HRM’s first
high-level cycle. - Conditional loop: for some learned or external
summary. HRM’s low-level loop is in this family, with
inside high-level cycle .
The reused stack then applies atomic transformer blocks:
Expanded inside cycle , define:
For internal block :
The recurrent output for that cycle is:
The output is:
Here is the number of blocks inside the reused stack, and the executed
block count is:
For a block-count-fair comparison to a -atomic-block standard transformer,
choose:
This is not parameter-count fair. The looped transformer has only distinct
blocks, while the standard transformer has distinct blocks. That is the
point of this comparison: it asks whether iterative reuse of a smaller program
can compete with a deeper unrolled program at the same executed depth.
Properties:
- It is an iterative dynamical system over the residual state
. - The input or conditioning stream is optional and should be reported
explicitly. The local UT baseline reinjects every cycle; generic looped
TF does not have to. - The same parameters must support early, middle, and late computation.
- It has less layer-specific specialization than a standard transformer.
- It can spend multiple steps refining a hidden state without increasing
parameters linearly with compute depth.
Tiny Recursive Model Baseline
The TRM baseline in trm_nocarry.py is best understood as an HRM ablation. It
keeps HRM’s two recurrent states and HRM’s low/high update schedule, but removes
the distinction between the high-level transformer module and the low-level
transformer module.
In HRM, the two module roles have separate parameters:
In TRM, both roles call the same shared transformer stack:
So TRM is not just the ordinary single-state looped transformer. It still has
two states, and , and it still runs the HRM schedule. The difference
is that the labels “L” and “H” describe the role of the update, not different
stack parameter sets.
With high cycles and low cycles per high cycle:
Initialization in the code:
- is initialized from the token embeddings .
- is initialized from the learned vector
zL_init, broadcast over
the token positions when it is added to . - There is no separate learned initialization in this implementation; the
high-level state starts as the input embedding stream.
For each high cycle :
The executed block count is:
For H=2,L=3,r=1, TRM has the same call order as HRM:
The update timing is:
| Call | Updated state | Conditioning state held fixed during call |
|---|---|---|
| uses | ||
| uses |
So during , is not updated. It stays equal to
. The first high-level update happens only at .
But every one of these calls uses the same -block stack parameters .
HRM instead uses for the six low-level calls and for the
two high-level calls.
The control is therefore:
- If HRM and TRM perform similarly, the schedule and recurrence may matter more
than separate H/L specialization. - If HRM beats TRM at the same executed block count, the result supports the
value of having distinct low-level and high-level modules. - If both beat a plain looped transformer, the two-state HRM/TRM schedule may be
better than a single recurrent stream.
TRM vs Looped Transformer
The difference is the state topology and the conditioning signal. Both models
reuse one -atomic-block stack, but they do not maintain the same state.
-
Looped TF has one recurrent state. It repeatedly applies the same
-block stack to the previous state plus an optional injection
:The local UT-style baseline uses . A pure recurrent loop can
use after initializing the state from the input. -
TRM has two recurrent states. It repeatedly updates a low-level state
conditioned on the current high-level state, then updates the high-level state
conditioned on the low-level result:
The important point is that TRM ties the parameters, not the states.
Compared with looped TF:
| Model | State variables | Stack parameters | Conditioning signal | Schedule |
|---|---|---|---|---|
| Looped TF | one stack | chosen ; local UT uses | ||
| TRM | one stack | low uses ; high uses | ||
| HRM | two stacks | low uses ; high uses |
Deriving the One-Cycle Equivalence
There is a special equivalence when there is only one high-level cycle:
Then is never updated before the low-level loop. It remains:
TRM’s low-level updates are:
Now define a looped transformer state initialized the same way:
The looped transformer update is:
By induction:
Proof sketch:
-
Base case:
-
If , then:
After the low-level loop, TRM performs the high-level update:
Because addition is commutative:
Using the induction result :
Therefore, under these assumptions:
at the level of forward equations.
The assumptions are:
- same initial recurrent state: ;
- same reused stack: ;
- same input injection ;
- no difference in backward truncation or training graph.
Why the Equivalence Breaks for More Than One High-Level Cycle
For , after the high-level state changes:
Then the next low-level loop is conditioned on , not on the original
input embedding :
A plain looped transformer would still inject the fixed :
So for , TRM is a two-state recurrent system. It cannot generally be
collapsed into a single-state looped transformer, unless for all
, which is not true after high-level updates.
HRM-Text
HRM-Text has two latent streams:
- : high-level stream.
- : low-level stream.
It also has two transformer modules:
- : high-level transformer stack.
- : low-level transformer stack.
The code initializes:
The low-level state starts from a learned/global initialized vector that is
broadcast against the token sequence when it is added to . The high-level
state starts from the token embeddings.
During the low-level updates inside a high-level cycle, is held fixed. For
example, with H=2,L=3:
- all use as the conditioning stream.
- updates the high-level state to .
- all use as the conditioning stream.
- updates the high-level state to .
So is updated only at the high-level calls, not during the low-level loop.
The low-level loop repeatedly updates while seeing a fixed .
HRM Macro-Block and Indices
It is helpful to view HRM as a repeated macro-block:
The indices mean:
- : high-level cycle index. It counts how many times the high-level state has
been updated. In the default HRM config, becauseH_cycles=2. - : low-level update index inside high-level cycle . In the default HRM
config, becauseL_cycles=3. - : low-level state after the -th low-level update inside
high-level cycle . - : high-level state after high-level update .
- : the high-level state that conditions all low-level updates
within high-level cycle .
One HRM macro-block at high-level cycle is:
The low-level recurrence needs a starting low-level state for each macro-block.
For , this is the learned initialized state:
For , the code carries forward the previous low-level state:
So HRM is not a stack of independent blocks. It is a two-state dynamical system
where the low-level state performs several fast updates under a fixed high-level
conditioning state, then the high-level state performs one slower update.
Linearized HRM Call Index
The notation is natural for HRM, but to compare with a standard
transformer it is also useful to flatten the recurrent calls into a single
depth index.
First ignore the internal blocks inside each H/L module and count only recurrent
module calls. Define a linear call index :
-
Low-level call maps to:
-
High-level call maps to:
So each HRM macro-block contributes recurrent calls:
For H=2,L=3, this gives:
| Linear call index | HRM call | State update |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 | ||
| 5 | ||
| 6 | ||
| 7 | ||
| 8 |
This is the same sequence previously written as:
If each recurrent call contains exactly one transformer block, then
is also the executed transformer-block index
.
With multiple internal blocks per module, each recurrent call expands into a
range of executed transformer-block indices. Let denote the global executed
block index.
-
Low-level call occupies:
-
High-level call occupies:
This is the fully flattened view that makes HRM comparable to a standard
transformer with executed blocks. The difference is that
the flattened HRM sequence reuses across low-level ranges and
across high-level ranges, instead of assigning a separate
parameter set to every flattened block index.
For example, with H=2,L=3 and , HRM has 16 executed transformer
blocks. The flattened ranges are:
| HRM call | Executed block indices |
|---|---|
| 1-2 | |
| 3-4 | |
| 5-6 | |
| 7-8 | |
| 9-10 | |
| 11-12 | |
| 13-14 | |
| 15-16 |
The recurrent update is:
The output hidden state is:
The executed block count is:
If :
With the local default HRM config:
H_cycles: 2L_cycles: 3half_layers: True
If the size config has n_layers = N, then each of and receives
blocks. The executed block count is:
For the paper-scale comparison you asked for, use the L size from the
HRM-Text resources. The README describes this as the 0.6B-parameter reference
run, with n_layers=24, hidden size 1280, and 10 attention heads. With
half_layers: True, HRM gives 12 atomic blocks to the H module and 12 atomic
blocks to the L module.
| Size Config | Config n_layers | Blocks per H/L module | HRM executed blocks | Standard TF executed blocks with same config |
|---|---|---|---|---|
L | 24 | 12 | 96 | 24 |
This is the key fairness issue. The default HRM config is not doing the same
number of block applications as a standard transformer with the same n_layers
value. For a same-block comparison to the 0.6B L HRM setting, compare against
a 96-block standard transformer, not a 24-block standard transformer.
Concrete 8-Block Comparison: HRM with H=2, L=3
Your intuition is correct: within each high-level cycle, the HRM low-level
module is a looped transformer conditioned on a fixed high-level state.
If each H/L module contains one atomic transformer block:
Then HRM executes:
full transformer-block applications.
The HRM schedule is:
More explicitly:
First high-level cycle:
Second high-level cycle:
The output is:
Why the Low Level Is Like a Looped Transformer
During a single high-level cycle, is held fixed while is updated
three times:
This is exactly a looped transformer update with a constant input injection
. The only difference from a plain looped transformer is that the injected
conditioning stream is not always the original embedding ; it is the
current high-level state.
So the low-level HRM module can be described as:
a 3-step conditional looped transformer, reset only by high-level updates.
The high-level module then updates the conditioning state:
That makes HRM a two-timescale loop:
- fast loop: , repeated three times;
- slow loop: , updated once after each group of low-level steps.
Same 8 Executed Blocks Across Architectures
For a clean comparison, compare all models at eight executed atomic transformer
blocks:
| Model | 8-atomic-block computation | Distinct atomic-block parameter sets | Latent state structure |
|---|---|---|---|
| Standard transformer | 8 | One residual stream | |
| Looped transformer | 1 | One recurrent stream plus input injection | |
TRM with H=2,L=3 | Same schedule, but all calls use shared | 1 | Two streams, one shared atomic block |
HRM with H=2,L=3 | , with and separate | 2 | Two streams, separate low/high blocks |
| Attention-residual transformer | 8 atomic blocks with learned routing over past residual sources | 8 plus small routing vectors | One stream plus explicit source bank |
This table shows the main tradeoff:
- Standard TF has the most layer-specific specialization.
- Looped TF has the strongest parameter sharing.
- TRM tests whether the HRM schedule helps without separate H/L modules.
- HRM sits between looped TF and standard TF: it reuses computation, but allows
separate low-level and high-level specialization. - Attention residuals keep the feed-forward depth order but replace fixed
residual addition with learned depth routing.
Residual-Stream Equations for the 8-Block Case
For a standard 8-block transformer, each executed block has its own parameters.
For :
For an 8-step looped transformer with one shared atomic block, the same parameters
are reused every cycle. The injected input for cycle is:
Then for :
For HRM with one low atomic block and one high atomic block, the low block parameters
are reused for all six low-level calls, while the high block
parameters are reused for the two high-level calls.
For each low-level call and , the injected input is:
The low-level transformer block computes:
After the three low-level calls in high cycle , the high-level injected input
is:
The high-level transformer block computes:
This makes the relationship clear:
- The lower level is looped:
three times per high-level state.
- The full HRM is not just a looped transformer, because it also has a slower
state update:
If “8 Layers” Means HRM-Text Config Layers
The local HRM config also has half_layers: True. If a size config had
n_layers=8, then HRM would give each of H and L four internal transformer
blocks:
With H=2,L=3, the executed block count would be:
So there are two different “8 layer” comparisons:
| Meaning of “8 layers” | HRM internal blocks per module | HRM executed blocks | Fair standard-TF comparison |
|---|---|---|---|
8 recurrent calls in the L,L,L,H,L,L,L,H schedule | 1 | 8 | 8-block standard TF |
HRM config has n_layers=8 with half_layers=True | 4 | 32 | 32-block standard TF |
For conceptual architecture analysis, the first comparison is cleaner. For
matching the HRM-Text config convention, the second is the one to use.
Concrete Comparison Strategy for H=2, L=3
The cleanest comparison is to fix executed atomic transformer-block applications. For
HRM with H=2, L=3, and :
So choose a base internal depth , then compare every architecture at
executed atomic transformer blocks.
Recommended Primary Setting
Use first. This is the most interpretable setting:
| Model | Setting | Executed atomic blocks | Distinct atomic-block parameter sets | Purpose |
|---|---|---|---|---|
| Standard TF | 8 untied blocks | 8 | 8 | Best untied-depth baseline |
| Looped TF | 1-atomic-block stack repeated 8 cycles | 8 | 1 | Pure recurrence and weight tying |
| TRM-style control | Same schedule, one shared 1-block stack | 8 | 1 | HRM schedule without separate H/L parameters |
| HRM | 8 | 2 | Conditional low loop plus high integration | |
| Attention residual TF | 8 atomic blocks with attention-residual routing | 8 | 8 plus routing vectors | Depth routing without recurrence |
For the looped transformer, do not test only the maximally tied case. At the
same executed depth , the looped baseline has an extra
design choice: how many atomic blocks are inside the repeated stack. This is the
ablation you suggested.
| Looped TF variant | Cycles | Stack depth | Executed blocks | Distinct atomic-block parameter sets | Interpretation |
|---|---|---|---|---|---|
| 1 block repeated 8 times | 8 | 1 | 8 | 1 | Maximal recurrence and maximal weight tying |
| 2 blocks repeated 4 times | 4 | 2 | 8 | 2 | Small repeated program; closer to a real transformer mini-stack |
| 4 blocks repeated 2 times | 2 | 4 | 8 | 4 | Less tying, fewer recurrent refinements |
| 8 blocks repeated 1 time | 1 | 8 | 8 | 8 | No meaningful recurrence; essentially an 8-block transformer stack |
The 2-blocks-for-4-cycles looped TF is a useful middle baseline. It asks
whether HRM’s gain comes from hierarchical two-state routing, or merely from
running a short transformer program repeatedly.
This isolates the architectural question:
Paper-Scale Setting: L / 0.6B Only
After the 8-block architecture comparison, scale only to the L reference
setting from the HRM-Text paper/resources, not to the larger sizes. For L:
n_layers = 24hidden_size = 1280num_heads = 10half_layers = True- ,
The executed atomic block count is:
| Model | Setting | Executed atomic blocks | Distinct atomic-block parameter sets |
|---|---|---|---|
| Standard TF, same config | 24 untied blocks | 24 | 24 |
| Standard TF, practical intermediate | 48 untied blocks | 48 | 48 |
| Standard TF | 96 untied blocks | 96 | 96 |
| Looped TF | 12-atomic-block stack repeated 8 cycles | 96 | 12 |
| Looped TF, 24-layer stack | 24-atomic-block stack repeated 4 cycles | 96 | 24 |
| Looped TF + untied integration | 24-atomic-block stack repeated 3 cycles, then independent 24-block stack | 96 | 48 |
| Looped TF + untied integration | 12-atomic-block stack repeated 6 cycles, then independent 24-block stack | 96 | 36 |
| Two-phase looped TF | 12-atomic-block stack repeated 6 cycles, then independent 12-block stack repeated 2 cycles | 96 | 24 |
| TRM-style control | , shared H/L stack | 96 | 12 |
| HRM | 96 | 24 | |
| Attention residual TF | 96 atomic blocks | 96 | 96 plus routing vectors |
| Looped block-attention-residual TF | 24-atomic-block AttnRes stack repeated 4 cycles, tied across cycles | 96 | 24 plus tied routing vectors |
| HRM with two-source attention residual mixer | Same HRM schedule, but replace by learned two-source routing | 96 | 24 plus small routing vectors |
The 96-block standard transformer is the clean same-executed-depth baseline, but
it may be difficult or wasteful to train. A 48-block standard transformer is a
practical intermediate baseline. It is not block-count fair to the 96-execution
HRM run, but it helps answer whether a moderately deeper untied transformer
already closes the gap without going all the way to 96 layers.
The 12-block-stack looped TF is the closest same-shape looped baseline because
each recurrent call has the same internal stack depth as HRM’s H and L modules.
The 24-block-stack looped TF is the scaled version of your “repeat a block set
four times” idea: it uses the same 24 distinct atomic-block parameter sets as
the 0.6B HRM configuration, but applies them as one single-stream loop repeated
four times.
The looped-plus-integration baselines test whether HRM’s benefit comes from a
final untied transformer stack after recurrent refinement. This is the closest
single-stream analogue of the HRM equation:
For attention residuals, include two different controls. A 96-block untied
attention-residual transformer is the clean learned-routing baseline, but it is
not parameter-saving. A looped block-attention-residual transformer ties a
24-block AttnRes stack across four cycles, giving the same 96 executed blocks
with roughly the same distinct block-parameter count as the 0.6B HRM setting.
For this looped AttnRes control, report the injection choice separately:
, , or a carried summary. These are different
architectures, not notation variants.
An even more direct HRM ablation keeps the HRM schedule and replaces the fixed
sum with a learned two-source attention-residual mixer.
What Each Comparison Tests
-
HRM vs standard TF: tests whether recurrence plus H/L state structure can
compete with fully untied depth at the same executed block count. -
HRM vs 48-layer standard TF: tests a practical scaling curve. If 48
untied layers already match HRM, then HRM’s advantage may be mostly extra
compute depth rather than the H/L recurrence pattern. -
HRM vs looped TF: tests whether HRM’s high-level state and separate
parameters improve over a single repeated residual stream. -
HRM vs looped TF plus untied integration: tests whether HRM’s advantage
can be explained by a repeated low-level body followed by a fresh untied
transformer stack, without the second high-level cycle and without two-state
H/L alternation. -
HRM vs TRM-style control: tests whether separate H/L modules matter when
the recurrence schedule is held fixed. -
HRM vs attention residuals: tests fixed two-state recurrent routing
against learned depth-wise residual routing. -
Looped TF vs standard TF: tests pure weight tying and recurrence against
untied depth.
Keep These Fixed
To make the comparison meaningful, keep these constant across runs:
- tokenizer and data mixture;
- sequence length and PrefixLM/causal masking setup;
- hidden size , attention heads, MLP expansion, RoPE, RMSNorm, SwiGLU;
- optimizer, learning-rate schedule, batch tokens, training tokens;
- initialization scheme as much as possible;
- evaluation prompts and decoding parameters.
Do not match parameter count for the primary comparison. Record parameter count
as a secondary axis. The primary axis should be executed block count:
Training-Compute Variants
There are two fair training variants, depending on the question:
-
Forward-depth fair: keep fixed and allow each model’s
natural backward graph. This matches how HRM-Text is actually trained with
truncated recurrent backprop. -
Backward-compute fair: adjust truncation/checkpointing so the number of
backward-tracked block applications is also comparable. This is stricter but
less directly representative of the published HRM-Text recipe.
For HRM with H=2,L=3,r=1 and max bp_steps=5, forward block applications are:
Backward-tracked block applications are:
So, when reporting results, include both:
- forward executed blocks;
- backward-tracked blocks.
HRM as Looped Transformer Plus High-Level Integration
The lower level of HRM is very close to a looped transformer. During high-level
cycle , the high-level state is fixed, and the low-level state
updates as:
Compare this with an input-injected looped transformer:
They have the same structural form:
The difference is what the conditioning stream is:
- This particular looped TF variant uses the original token embedding stream
at every cycle. - HRM low level uses the current high-level state at every
low-level step inside high-level cycle .
So HRM does not generally keep adding raw to every low-level update.
It does that only in the first high cycle because:
After the first high update, the low-level loop receives:
which are learned summaries produced by the high-level transformer, not the raw
embedding stream.
So the lower part of HRM is best described as a conditional looped transformer:
HRM with One High-Level Cycle
If by H=1 we mean one high-level cycle, , then HRM becomes:
followed by one high-level integration step:
This is equivalent to:
- a looped transformer body repeated times,
- with repeated input injection ,
- followed by one final untied transformer stack that
integrates the original embedding stream and the final looped state.
In short:
The equivalence is exact at the level of forward equations if:
- the looped transformer’s recurrent state is initialized to ,
- the looped transformer uses the same repeated input injection ,
- the loop body has the same parameters as ,
- the final untied stack has the same parameters as .
The training behavior can still differ if one model uses full BPTT and the other
uses HRM’s truncated backward schedule.
Looped TF Plus Untied Integration Stack
A useful control between looped TF and HRM is:
Let be the repeated loop body and
be a separate untied integration stack. Initialize:
For :
Here should be reported as part of the experiment. The
HRM- matching control uses . A pure looped control can
use after initializing from the input.
Then use an independent final integration stack:
The executed block count is:
The distinct atomic-block parameter count is:
This architecture is exactly the single-stream analogue of HRM with
only when : repeated low-level refinement with direct
input injection, followed by an untied integration stack that sees both the
original input stream and the final recurrent state.
At the 96-executed-block budget, useful examples are:
| Hybrid | Body | Integration | Executed blocks | Distinct atomic-block parameter sets | What it tests |
|---|---|---|---|---|---|
24x3 + 24 | untied | 96 | 48 | Whether three recurrent passes plus a fresh 24-block integrator can match HRM | |
12x6 + 24 | untied | 96 | 36 | Whether HRM’s 12-block recurrent granularity works without H/L alternation | |
12x6 + 12x2 | second independent loop, | 96 | 24 | Whether two independent recurrent phases can match two HRM modules |
For the two-phase looped version, the second phase is:
and . This is not the same as an untied final
24-block stack, because the 12-block stack is reused twice.
Closed-Form Unrolling for
This is a closed form in the sense of exact unrolling of nonlinear
compositions. It is not a linear-system closed form, because each transformer
stack is nonlinear.
Let:
For any fixed conditioning stream , define the low-level loop map:
When , the high-level conditioning stream is fixed to throughout
the low-level loop. Therefore:
where means repeated applications of the same map. The
output is:
Expanded without the shorthand:
with applications of .
This makes the residual-link structure clear:
- every low-level macro-step receives a direct additive link from ;
- the final high-level step also receives a direct additive link from ;
- earlier low-level states are not separately stored as a source bank; they are
compressed into the latest recurrent state .
If we temporarily write each stack as a residual map:
then the low-level recurrence gives:
The final high-level state becomes:
This equation is useful conceptually: along the identity/residual path,
is injected times. The nonlinear residual increments and then
modify that stream. In the actual HRM-Text code, each module also applies a
final RMSNorm after its internal blocks; the exact composition formula above is
therefore the safest statement. The additive expansion should be read as the
residual-graph interpretation of the transformer blocks.
Is a Special Attention Residual?
It is a special case of a more general residual-mixing operator, but not the
same as full learned attention residuals.
A generic residual mixer would form:
For HRM, the source sets and weights are fixed:
So your intuition is right if we view the low-level macro-steps as layers:
there is a direct residual link from the initial embedding stream to each
low-level macro-step and to the final high-level step.
The caveats are important:
- If contains internal atomic blocks, is injected at
the start of each low-level stack call, not before every internal atomic block. - HRM uses fixed unnormalized weights , while attention residuals use
learned softmax weights that sum to 1. - HRM keeps only the latest low-level recurrent state plus as explicit
sources. Full attention residuals can expose many earlier layer outputs as
separate sources.
Thus HRM is best described as:
HRM with Multiple High-Level Cycles
For , HRM is more than looped TF plus a final layer. It alternates:
After each high-level update, the conditioning stream for the next low-level
loop changes from to . This makes HRM a nested loop:
- inner loop: repeated low-level refinement under a fixed high-level state;
- outer loop: high-level state update that changes the conditioning for the next
low-level loop.
Closed-Form Unrolling for
Use the same shorthand:
The first high-level cycle is exactly the body:
Here and . The second low-level loop no longer
uses as its direct conditioning stream. It uses the updated high-level
summary :
Substituting and gives the exact composition:
This shows what changes from :
- In high cycle 1, the direct conditioning source is .
- In high cycle 2, the direct conditioning source is .
- The raw input still affects cycle 2, but now through the high-level
summary , not as a fresh direct additive injection.
Using the residual-map shorthand and
:
and:
So for , HRM is not simply “input to every layer.” It is:
This is close in spirit to block attention residuals: behaves like a
learned block-level summary that later computation can reuse. But HRM’s reuse is
fixed and scheduled, while attention residuals learn which block or layer
summaries to mix at each sublayer.
HRM Residual Stream Math Inside Each Recurrent Call
For a module , let be its number of internal
transformer blocks. Use:
- for a low-level transformer call.
- for a high-level transformer call.
- : the recurrent state of that same level before the
call. - : the cross-level conditioning stream injected into this call.
- : the internal residual stream inside module after internal
block . - : attention increment from internal block of module .
- : post-attention residual stream inside internal block .
- : MLP increment from internal block .
The injected stream comes from the other level:
- Low-level call:
- High-level call:
Each recurrent call starts with an inter-state residual addition. For a generic
module call:
Here is the input residual stream to the first internal transformer
block of module . It is not yet the output of attention or MLP; it is the
sum of the module’s previous recurrent state and the other level’s conditioning
state.
Then the internal residual stream evolves through standard pre-norm
transformer blocks. For internal block :
The module output is final-normalized:
For the concrete HRM recurrence, this means:
Low-level update:
High-level update:
So HRM has two levels of additive residual structure:
- Inter-state injection:
- Intra-transformer residual updates:
This is why your intuition about a connection to residual routing is reasonable:
HRM combines latent streams by addition before running a transformer block stack.
However, this is still a fixed additive merge, not learned attention over a bank
of past residual states.
Training Loss and Backward Computation
All architectures discussed here can be trained with the same language-modeling
loss. The difference is not the loss function; it is the computation graph that
the loss backpropagates through.
Let the final model hidden state be at token position
. The LM head computes logits:
For target token and valid-token mask , the loss is:
In the local LMHead, ignored labels use IGNORE_LABEL_ID = -100, and the
cross-entropy is summed over valid tokens then divided by the distributed
average valid-token count.
Standard Transformer Backward Pass
A standard transformer with atomic blocks computes:
The backward pass is ordinary full backpropagation through the feed-forward
depth:
Every block application is in the autograd graph. Each block has its own
parameters, so each receives gradients from one depth position.
Looped Transformer Backward Pass
A looped transformer reuses an -atomic-block stack:
If trained with full backpropagation through time, the shared parameters receive
a sum of gradients from every recurrent use:
This is the usual BPTT view: the recurrent computation is unrolled, and the same
parameter tensor appears at multiple depths in the graph.
However, the local Universal Transformer baseline does not necessarily use full
BPTT. In ut_nocarry.py, only the last bp_cycles recurrent cycles run with
gradients enabled:
Earlier cycles are executed under no-grad. Their outputs still affect the
forward pass, but they are treated as constants during backward.
HRM-Text Backward Pass: Truncated BPTT Over Recurrent Steps
Your intuition is right that HRM-Text is not doing full backpropagation through
all recurrent steps by default. More precisely:
HRM-Text performs the full recurrent forward computation, but backpropagates
only through a suffix of the recurrent calls.
The relevant code is in hrm_nocarry_bp_warmup.py:
H_bp_steps = min(self.H_cycles, bp_steps - 1)
L_bp_steps = bp_steps - H_bp_steps
...
with torch.set_grad_enabled(k >= self.H_cycles * self.L_cycles - L_bp_steps):
z_L = self.L_level(...)
...
with torch.set_grad_enabled(i >= self.H_cycles - H_bp_steps):
z_H = self.H_level(...)Let:
There are:
low-level calls and high-level calls. Given a training-time budget
:
Only the last high-level calls and the last
low-level calls are gradient-tracked.
For a low-level call with global low-call index:
the call is gradient-tracked only if:
For a high-level call , the call is gradient-tracked only if:
All earlier recurrent calls are still used in the forward pass, but their
operations and parameters are not part of the backward graph. Their output
states become conditioning constants for later gradient-tracked calls.
HRM with H=2, L=3
For the concrete schedule:
there are six low-level calls and two high-level calls:
The default HRM config warms bp_steps from bp_min_steps=2 to
bp_max_steps=5. At the start, :
Only these recurrent calls are in the backward graph:
At the max setting, :
The gradient-tracked calls are:
The first low-level group:
is still executed, but it is not backpropagated through. Its result influences
, but gradients do not flow into the parameters used by .
This is truncated BPTT, not zero BPTT. HRM-Text backpropagates through the final
part of the recurrent computation.
Parameter Sharing and Gradient Accumulation
The distinction between standard TF, looped TF, and HRM is also visible in how
gradients accumulate onto parameters.
Standard transformer:
are distinct. Each block parameter set is used once.
Looped transformer:
is shared across recurrent calls, so the gradient is a sum over every
gradient-tracked use of the same block.
HRM:
are shared within their own levels. The low-level parameters receive:
and the high-level parameters receive:
where and are the low/high calls that are inside
the truncated backward window.
Attention Residual Backward Pass
Attention residual models are feed-forward in depth, not recurrent in time. If
trained normally, they use full backpropagation through all transformer
sublayers.
The difference is that each sublayer input is a learned mixture:
Write the sources as . The local attn_res implementation uses
a learned pseudo-query vector and normalized source keys:
The attention-residual input is:
Let:
Then the gradient into the mixture has two parts.
First, each source gets a direct value-path gradient:
Second, because the same source also controls its routing logit through
, it receives a key/routing-path gradient. The softmax derivative
gives:
Since:
this can be written more compactly as:
The pseudo-query gradient is:
The routing-path gradient into the source is:
where is the Jacobian of the RMSNorm used to make the source key.
Therefore:
So gradients flow:
- into the ordinary sublayer parameters ,
- into the selected source representations ,
- into the routing weights through the pseudo-query parameters .
This gives earlier residual sources more direct gradient routes from later
sublayers than a plain additive residual stack. It does not require BPTT because
there is no recurrent loop unless one adds recurrence separately.
For block attention residuals, the same derivative applies, but the sources
are block summaries or the current partial-block sum. The gradient into a
block summary then distributes through the ordinary additions that formed that
summary.
The important comparison to HRM is:
- Attention residuals: full backprop through a feed-forward graph with
learned residual-routing weights. - HRM-Text: recurrent forward graph with fixed additive H/L routing, but
truncated backward through only the final recurrent calls.
There is no magic in either case. Attention residuals improve routing and
gradient access to earlier representations. HRM changes the state dynamics and
uses extra iterative compute, while saving backward memory by cutting off the
earlier recurrent prefix.
Training-Graph Comparison
| Model | Forward computation | Backward graph | Shared-parameter gradient behavior |
|---|---|---|---|
| Standard TF | One pass through distinct blocks | Full backprop through all blocks | Each block gets gradients from one use |
| Looped TF, full BPTT | Reuses a block/stack for cycles | Full BPTT through all cycles | Shared parameters get summed gradients over all cycles |
| Local looped TF baseline | Reuses a block/stack for cycles | Truncated to last bp_cycles | Shared parameters get summed gradients only over tracked cycles |
| Looped TF + untied integration | Reuses a loop body, then runs a fresh integration stack | Full BPTT or truncated BPTT through loop; full backprop through final stack | Loop-body gradients sum over tracked cycles; integration-stack parameters are used once |
| HRM-Text | Executes all H/L recurrent calls | Truncated to suffix: last H calls and last L calls | and get summed gradients over tracked calls only |
| Attention residual TF | Feed-forward through all sublayers with source routing | Full backprop through all sublayers and routing weights | Mostly distinct layer parameters; pseudo-query routing vectors get gradients |
| Looped attention residual TF | Reuses an AttnRes stack for cycles | Full or truncated BPTT through cycles; full autograd through routing inside tracked cycles | Shared block and pseudo-query parameters get summed gradients over tracked uses |
| HRM two-source AttnRes mixer | Same H/L schedule as HRM, but learned two-source mixing before each H/L stack | Same truncated HRM backward schedule unless changed | H/L block gradients as HRM; mixer pseudo-query gradients from tracked H/L calls |
Backward Compute and Activation Memory
The forward compute is determined by the number of executed block applications.
The backward compute is determined by how many of those applications are kept in
the autograd graph.
| Model | Forward block applications | Backward-tracked block applications | Activation-storage implication |
|---|---|---|---|
| Standard TF | Stores activations for all blocks, modulo checkpointing/FSDP tricks | ||
| Looped TF, full BPTT | Parameter sharing reduces parameter count, not unrolled activation depth | ||
| Local looped TF baseline | suffix only | Earlier cycles can avoid activation storage because they run under no-grad | |
| Looped TF + untied integration | loop policy plus all final-stack blocks | Final integration stack must store activations normally; loop body can be full or truncated | |
| HRM-Text | suffix H/L calls only | No-grad recurrent prefix reduces backward memory and backward FLOPs | |
| Attention residual TF | plus routing ops | Stores source representations or block summaries needed for routing | |
| Looped block-attention-residual TF | loop policy plus routing ops | Use block/cycle summaries to avoid storing all full-depth sources | |
| HRM two-source AttnRes mixer | suffix H/L calls plus mixer ops | Nearly HRM memory, with small extra two-source routing activations |
For HRM with H=2,L=3, one block per H/L module, and max bp_steps=5:
But only these five recurrent calls are gradient-tracked:
Since each call contains one block in this simplified 8-block comparison, the
backward-tracked block count is 5, not 8. If each H/L module has internal
blocks, the forward executed block count is:
while the max-warmup backward-tracked block count is:
This is one reason HRM can spend more forward compute on latent refinement
without paying full backward cost through every recurrent step.
Why HRM-Text Can Be Effective on Text Tasks
HRM-Text’s advantage is not one single trick. The local implementation combines
several effects.
1. More Executed Computation Per Token
With default H_cycles=2, L_cycles=3, and half_layers=True, HRM executes
four times as many transformer-block applications as the standard transformer
with the same n_layers config.
For text tasks that benefit from iterative refinement, this matters. The model
can repeatedly transform a latent representation before producing logits. This
is especially relevant for arithmetic, symbolic reasoning, multi-hop QA,
instruction following, and format-constrained completion.
The fair question is not:
Does HRM beat a standard transformer with the same parameter count?
The cleaner architectural question is:
Does HRM beat a standard transformer with the same number of executed
transformer blocks and the same training data/optimizer budget?
Those are different experiments.
2. Two Timescales: Low-Level Refinement and High-Level Integration
HRM updates the low-level state several times before each high-level update:
This creates a useful division of labor:
- can perform repeated local/detail refinement conditioned on the
current high-level state. - can integrate the result after the low-level state has undergone
several updates.
For textual tasks, this resembles an implicit latent scratchpad: repeated
low-level passes can resolve local token-level or span-level details, while the
high-level state carries a more stable global plan.
3. Persistent Input and Cross-State Injection
The high-level stream starts from token embeddings:
Then every low-level call receives the current high-level state:
Every high-level call receives the refined low-level state:
This repeated addition makes the recurrent computation less likely to drift
away from the original prompt state. It also gives both levels a direct path for
information and gradients through additive residual structure.
4. Distinct H and L Parameters
Compared with a single looped transformer or TRM, HRM has two parameter sets.
That lets the high and low modules specialize:
At the same executed block count, HRM will usually have more parameters than a
single tied looped transformer, but fewer distinct parameters than a fully
unrolled standard transformer with the same executed depth. This is a middle
ground:
- More specialization than a single tied recurrent block.
- More parameter reuse than a fully unrolled deep transformer.
- More compute depth than a shallow transformer with the same
n_layersconfig.
5. Truncated Backpropagation Through Recurrent Steps
The HRM code executes all recurrent calls, but it only enables gradients for a
suffix of those calls. The schedule warms bp_steps from bp_min_steps toward
bp_max_steps.
With default H_cycles=2, L_cycles=3, and bp_max_steps=5:
- There are low-level calls.
- There are high-level calls.
- At max warmup, both high-level calls and the last three low-level calls get
gradient.
This keeps the effective forward computation deep while reducing backprop cost
and possibly improving stability. It also makes the final recurrent steps the
most directly optimized, which encourages the network to use recurrence as a
progressive refinement process.
6. Strong Text-Modeling Engineering
The repo also includes choices that are not unique to HRM but matter for
performance:
- PrefixLM sequence packing.
- FlashAttention path.
- RoPE.
- RMSNorm.
- SwiGLU.
- Gated attention output.
- Scaled embeddings and carefully chosen initialization.
- Large token batch sizes and multi-epoch sampled training.
When explaining HRM-Text’s results, separate these training/system choices from
the architectural recurrence. A proper ablation should keep these fixed.
Attention Residuals
The resource/attn_res implementation replaces fixed additive residual routing
with learned depth-wise attention over previous representations.
Important convention: in attn_res, n_layers means transformer sub-layers,
alternating attention and FFN. Therefore:
For a fair comparison to atomic transformer blocks, set:
Standard Additive Residual as Source Summation
A transformer can be viewed as maintaining a cumulative residual stream:
where:
Here is the output increment produced by sublayer . It is not the whole
cumulative residual stream; it is the new contribution that gets added to or
routed into later computation. In a standard residual transformer, the stream
is the sum of the input plus all previous increments .
Every previous sublayer output has fixed coefficient . Later layers can
transform the stream, but the residual routing itself is not learned.
Full Attention Residuals
Full attention residuals keep a source bank:
Before sublayer , the model computes:
where:
Then:
The pseudo-query is learned and initialized to zero,
so at initialization:
This gives stable uniform routing at the start of training, then lets the model
learn which earlier representations each sublayer should use.
Block Attention Residuals
Block attention residuals reduce memory by grouping sublayers into blocks. Let
be the set of sublayers in completed block . Define block summaries:
Here is a block-level summary: instead of storing every individual
sublayer increment from block , the model stores one aggregate
source for that block.
Inside the current block, define a partial sum:
Here is the current block’s partial summary up to, but not including,
sublayer .
The source set for sublayer is:
The input is:
Block attention residuals are therefore closer to learned routing over
block-level residual summaries than learned routing over every sublayer output.
Fair Attention-Residual Comparisons
There is not just one fair comparison to HRM. Attention residuals introduce a
different architectural axis:
Weight tying is a separate axis:
So we should compare several attention-residual variants.
Untied Attention Residual: Routing-Only Baseline
The clean routing-only baseline is:
atomic blocks with attention-residual routing. In attn_res notation this means:
because that repo counts attention and FFN as separate sublayers.
This is fair in executed compute, but not parameter-saving:
atomic-block parameter sets plus small pseudo-query routing vectors.
Looped Attention Residual: Parameter-Saving Baseline
To save parameters, tie a smaller attention-residual stack across recurrent
cycles. Let be an attention-residual stack with
atomic blocks, including both ordinary transformer parameters and
pseudo-query routing vectors. Then:
Again, is a design choice, not part of the definition of looped
TF. Reasonable variants are:
- , with : pure recurrent loop.
- : UT-style repeated input injection.
- equal to a learned or carried summary: closer to HRM’s
conditional low-level loop.
The executed and distinct block counts are:
For the 0.6B HRM comparison:
This matches the “24 blocks repeated 4 times” looped-TF idea, but changes the
residual routing inside the repeated 24-block stack from ordinary addition to
learned attention-residual routing.
The confusing part is the attention-residual source bank. It is the internal
depth-routing memory used by the AttnRes stack. It is not the same thing as
the recurrent state .
There are two clean implementation choices.
Option A: reset the AttnRes source bank inside each recurrent cycle.
Cycle starts from:
Inside the 24-block stack, sublayer attends only to sources produced
inside the current stack call:
The final output of that stack becomes:
This does not mean the model forgets earlier cycles. Earlier cycles are
still summarized in . It only means that sublayer
in cycle cannot directly attend to every block output from cycle
.
Gradient behavior for Option A:
-
With full BPTT, gradients flow across cycles through the recurrent state
. -
The tied AttnRes parameters and tied pseudo-query vectors receive summed
gradients over all tracked cycle uses: -
With truncated BPTT, earlier cycles are detached exactly like a looped TF or
HRM no-grad prefix.
Option B: carry compact cycle summaries as extra AttnRes sources.
Keep one summary per previous recurrent cycle. For example, can be
the final output or a block summary from cycle . Then sublayer in
cycle can attend to:
This option lets the attention-residual router directly choose among previous
cycle summaries. That is closer to HRM’s use of high-level summaries, but with
learned routing instead of fixed addition.
Gradient behavior for Option B:
- If the carried summaries are not detached, later cycles send
gradients directly into earlier cycles through the summary bank as well as
through the recurrent state. This is the richest credit assignment, but it
requires storing more activations. - If the carried summaries are detached, later cycles can read them as
memory but do not backpropagate into the earlier cycles through those
summaries. This is closer to HRM’s truncated no-grad prefix and is easier to
train.
The second option is the fairest attention-residual comparison if the goal is:
It should be easier to train than full 96-block full-attention-residual routing,
because the number of routing sources stays small.
HRM-Shaped Two-Source Attention Residual
The most surgical HRM ablation is to keep HRM’s schedule and replace only the
fixed cross-state addition.
HRM currently uses:
where . Here and are both ordinary residual-stream
tensors in :
| HRM call | means | means | stack input | |
|---|---|---|---|---|
| Low-level call | previous low state | fixed high summary | ||
| High-level call | previous high state | final low state from this cycle |
So is the state being updated, and is the cross-level source used
to condition that update. Both have the same width , and HRM adds them before
passing the result to a normal -wide transformer stack.
A two-source attention-residual mixer would instead use:
with:
Then the ordinary HRM stack runs:
This has almost the same transformer parameters and executed compute as HRM:
It directly tests whether HRM’s fixed residual addition is sufficient,
or whether learned two-source routing improves the H/L interaction.
This is the closest conceptual bridge to attention residuals. In attention
residual notation, the source set would simply be:
and the mixer would compute:
The difference from ordinary AttnRes is the meaning of the sources. AttnRes
sources are usually previous sublayer outputs or block summaries .
HRM sources are recurrent state summaries: the level’s own state and the
opposite level’s state.
Should Attention Residual Use Width?
Usually, no. For the default fair comparison, keep the same hidden size .
The reason is that HRM does not concatenate and into a -wide
vector. It adds two -wide streams:
then runs a normal -wide transformer stack:
Attention residuals also mix several -wide sources into one -wide stream:
So the routing-fair comparison is:
Using would be a different capacity-scaling
experiment. It would increase transformer block parameters and FLOPs roughly
quadratically with width, so it would not isolate residual routing. It may be a
useful extra baseline if the question is “does a wider standard/AttnRes model
match HRM?”, but it should not be presented as the primary fair comparison to
HRM’s two-state routing.
HRM vs Attention Residuals
Your intuition that HRM’s high-level and low-level states have a connection to
attention residuals is right at the level of residual-stream routing, but the
mechanisms are different.
Similarity
Both mechanisms give later computation access to earlier or parallel latent
representations.
HRM does:
Here is the level’s own recurrent stream and is the conditioning
stream injected from the other level.
Attention residuals do:
Both are alternatives to relying only on a single latest residual stream.
Difference 1: Fixed Addition vs Learned Routing
HRM’s cross-state merge has fixed coefficients:
Attention residuals learn token-wise depth weights:
So HRM asks the following transformer stack to interpret the sum. Attention
residuals choose the mixture before the sublayer runs.
Difference 2: Two Recurrent State Variables vs Source Bank
HRM maintains two evolving state variables:
Attention residuals maintain a bank of previous outputs or block summaries:
HRM compresses history into two recurrent streams. Attention residuals retain a
more explicit depth memory.
This is where your interpretation is useful:
-
Attention residuals can adaptively attend to many previous layer outputs:
The weights can change by layer, token, and input example.
-
HRM gives the low-level loop a scheduled summary source:
For fixed high cycle , the high-level source is constant for
all .
So HRM’s cross-level source is piecewise constant over low-level segments.
For the usual schedule:
That makes HRM closer to a hard-scheduled block-summary mechanism:
Attention residuals are more flexible:
The tradeoff is that HRM has a simpler, cheaper routing rule and keeps only two
state variables, while attention residuals expose a richer source bank and learn
the routing weights.
Difference 3: Recurrent Computation vs Residual Rewiring
HRM changes the computation schedule:
Attention residuals keep a mostly standard feed-forward layer order but change
how each layer receives prior representations.
This means HRM increases effective iterative depth, while attention residuals
mainly improve representation routing across depth.
Difference 4: Token-Dependent Routing
Attention residual weights vary by batch item and token position because the
logits use :
HRM’s addition has no explicit learned per-token routing coefficient between
and . Any selectivity must be implemented inside the transformer
blocks after the streams are added.
HRM as a Fixed Two-Source Residual Mixer
Another way to summarize the connection is:
-
HRM uses a fixed two-source mixture before a transformer stack:
For a low-level call, and
. For a high-level call, and
. These are full -wide residual streams, not scalar
gates or concatenated features. -
Attention residuals use a learned multi-source mixture before a sublayer:
Here each is a previous -wide source, such as a sublayer output or a
block summary. The weighted sum is also -wide.
In HRM, the sources are semantically structured:
- : fast/refinement state;
- : slow/integration state.
In attention residuals, the sources are depth-structured:
- previous sublayer outputs in full mode;
- previous block summaries and current partial block state in
block mode.
This suggests a possible hybrid direction:
or, more generally:
That would make HRM’s H/L fusion closer to attention residual routing. The
current HRM-Text implementation does not do this; it uses simple addition and
lets the following transformer stack learn how to interpret the merged stream.
Same-Block Comparison Protocol
The clean comparison variable is executed atomic transformer blocks:
Use this table to configure fair comparisons.
| Architecture | Atomic-block execution count | Distinct atomic-block parameters | Fair same-block setting |
|---|---|---|---|
| Standard transformer | Use blocks once | ||
| Universal/looped transformer | Choose | ||
| TRM-style loop | Choose | ||
| HRM-Text | Choose | ||
| Attention residual transformer | atomic blocks, or sublayers | about atomic blocks plus pseudo-query scalars | Set sublayers |
For HRM with , , and :
For the L / 0.6B HRM-Text setting, n_layers=24 and half_layers=True, so
and:
So a block-count-fair paper-scale comparison is:
| Model | Example setting | Executed atomic blocks | Parameter implication |
|---|---|---|---|
| Standard TF, same config | 24 distinct atomic blocks | 24 | same n_layers as the 0.6B config, but only one quarter of HRM’s executed depth |
| Standard TF, practical intermediate | 48 distinct atomic blocks | 48 | feasibility baseline between same-config and same-executed-depth |
| Standard TF | 96 distinct atomic blocks | 96 | largest atomic-block parameter count |
| Looped TF | 96 | one 12-block stack reused 8 times | |
| Looped TF, 24-layer stack | 96 | one 24-block stack reused 4 times | |
| Looped TF + untied integration | 96 | 48 distinct blocks; recurrent body plus fresh integrator | |
| Looped TF + untied integration | 96 | 36 distinct blocks; HRM-like recurrent granularity plus fresh integrator | |
| Two-phase looped TF | 96 | 24 distinct blocks; two independent repeated stacks | |
| TRM | 96 | one stack reused for H and L roles | |
| HRM | 96 | two 12-block stacks | |
| Attention residual | 96 atomic blocks, n_layers=192 sublayers in attn_res convention | 96 | similar block params to standard plus small routing params |
| Looped block-attention-residual TF | with tied AttnRes stack | 96 | 24 block sets plus tied routing vectors |
| HRM two-source AttnRes mixer | with learned H/L source mixing | 96 | HRM block params plus small routing vectors |
This is the comparison implied by “same number of layers / transformer blocks,
not same parameter number.” The 24- and 48-layer standard transformers are
useful practical baselines, but only the 96-layer standard transformer is the
strict same-executed-block baseline for this HRM setting.
Keep hidden size fixed at the HRM setting, for L / 0.6B, for the
primary AttnRes comparisons. A AttnRes model is a wider-capacity ablation,
not the fair default, because both HRM addition and AttnRes mixing produce a
-wide stream.
Expected Strengths and Weaknesses
Standard Transformer
Strengths:
- Maximum layer-specific specialization at a fixed block count.
- Simple optimization path.
- No recurrence scheduling or truncated-BPTT complexity.
Weaknesses:
- Parameters grow linearly with depth.
- No explicit iterative refinement except depth itself.
- Earlier representations are available only through the cumulative residual
stream, not through learned depth retrieval.
Looped Transformer
Strengths:
- Cheap way to increase executed depth.
- Natural iterative refinement.
- Strong parameter efficiency.
Weaknesses:
- Same parameters must handle all stages of computation.
- Can underfit stage-specific operations compared with an unrolled transformer.
- Repeated application can become dynamically unstable or collapse to a narrow
iterative behavior without careful normalization/injection.
HRM-Text
Strengths:
- Adds iterative depth while preserving some specialization through separate H
and L modules. - Low-level repeated updates can refine details before high-level integration.
- Cross-state residual addition provides direct information paths.
- More expressive than a single tied loop at the same executed block count.
Weaknesses:
- Same
n_layersconfig is not a fair comparison to standard TF because HRM
executes many more blocks. - Fixed addition between and is less flexible than learned
routing. - Truncated backprop means early recurrent steps are optimized indirectly.
- More complicated cache/training/evaluation behavior than a standard stack.
Attention Residuals
Strengths:
- Learns which earlier residual representations to use.
- Provides token-wise depth routing.
- Adds very few parameters: roughly one -dimensional pseudo-query per
sublayer. - Block mode controls memory while preserving explicit depth summaries.
Weaknesses:
- Does not by itself add recurrent compute depth.
- Full mode has high memory cost.
- The local implementation is independent/unofficial and counts layers as
sublayers, so comparisons require care. - Learned residual routing may need ablation against simpler residual-scaling or
gated-residual baselines.
Main Takeaways
- HRM-Text is best understood as a two-state recurrent transformer:
-
Its default config executes far more transformer blocks than a standard
transformer with the samen_layersvalue. For theL/ 0.6B setting,
HRM executes 96 block applications, while the standard transformer config with
the samen_layers=24executes 24. -
In the HRM-Text repo, HRM, TRM, looped TF, and standard TF use the same
internal transformer block. The main difference is the connection rule that
constructs the next block input stream. -
The lower level of HRM is a conditional looped transformer:
If , HRM is equivalent at the forward-equation level to an
input-injected looped transformer with , followed by one
untied final high-level integration stack.
- A fair layer-count comparison should fix executed block count:
For the 0.6B L setting, this gives 96 executed blocks. A 48-layer standard TF
is a useful feasibility baseline, but it should be reported as an intermediate
scaling point, not as the strict same-block comparison.
-
HRM is related to attention residuals because both route information through
latent residual streams, but HRM uses fixed additive two-state fusion, while
attention residuals use learned softmax routing over a source bank. -
HRM’s effectiveness on text tasks likely comes from the combination of
iterative latent refinement, two-timescale H/L specialization, repeated
cross-state residual injection, truncated recurrent training, and strong
language-model engineering. -
The strongest ablation would compare all of the following at the same
executed block count, same data, same optimizer, and same token budget:
- Standard transformer with distinct blocks.
- Looped transformer with .
- TRM with .
- HRM with .
- Attention-residual transformer with atomic blocks.