Option A: a large stack at every byte
The same large model processes c, then a, then t, then !. It has four positions to process.
This is straightforward, but a long document has many byte positions. Large-network work can be expensive.
An illustrated reading journey · H-Net
A language model still has to predict the next byte. H-Net learns which positions deserve a deeper update—and keeps a lighter path running at every position.
cat! to keep the arithmetic small. The displayed vectors are teaching inputs, not outputs from a trained H-Net.01 / The job, before the machinery
Imagine the model has read ca. Its immediate job is not “understand the whole word.” It must assign scores to possible next bytes. The next byte might be t, r, or something else.
t! possible future
r! another possible future
A powerful network can do this at every byte. But that makes its deepest layers process a long sequence. H-Net asks a narrower question: can the deep network work on fewer positions, while the outer network still handles every byte?
Predict: if the deep network waits on the next position, must the entire model stop? Keep that question in mind.
Takeaway 01. H-Net changes the internal route, not the next-byte prediction task.
02 / Make the input tangible
Bytes: integers from 0 to 255. In our deliberately simple ASCII example, each visible character is one byte. A lookup table turns each byte ID into a list of numbers called an embedding. A small causal encoder updates that representation using only the prefix already read.
999711633Notice the difference: 99 is an input byte ID, not an embedding value or a boundary score.
UTF-8 encodes é with two bytes and 猫 with three. Real byte-level modeling cannot assume “one position = one letter.” Special sequence markers are omitted here.
Predict: does the model need a pre-built dictionary entry for the whole string cat!? No—it starts from byte IDs.
Takeaway 02. A byte ID is fixed; its contextual representation changes with the bytes seen so far.
Before the router / how a retained vector remembers
Yes—through the causal encoder. Gather copies the encoder's vector at a selected position; it does not copy that position's raw byte. By then, the vector has already been updated by every earlier byte. The router also decides from those vectors, so an earlier byte can change both what is sent deeper and whether a later position is sent.
Grounding: v2 §2.1.2 gives encoders two jobs—preserve fine detail for the residual and compress context into vectors for the main network. Appendix E.1 compares the default gather with max/mean pooling and cross-attention and reports parity, which the authors interpret as the encoder already compressing context into boundary vectors.
A declared toy encoder, not Mamba and not learned. Each known byte has a chosen two-number embedding. The encoder is the simplest causal memory: h[t] = 0.5·h[t−1] + E[byte t]. The router projections are chosen non-identity matrices: Wq = [[1, 0.5],[0, 1]] and Wk = I. All values are teaching constants; they show the dependency, not what a trained encoder learned.
Compare cat! with cot!. Position 1 is skipped in both. Yet the encoder state at position 2 differs by exactly 0.5 × (E[a] − E[o]), and the router's decision at t flips. The deep network therefore never receives an isolated byte: it receives a vector whose history includes a byte that was never gathered.
Why gather can work. Selection is cheap because the outer encoder has already summarized the past. The real encoder is a stack of causal Mamba-2 layers; this chapter shows the dependency, not their learned features.
The missing bridge / one whole forward pass
The main network is not a mysterious source of the numbers 2 and 10. It is the large sequence model that performs most of the high-capacity processing, on a shorter sequence of continuous vectors. Here is the full composition before any isolated scalar experiment.
Grounding: v2 §2.1 / Eqs. 1–3, §2.2 / Eqs. 4–9, §2.3; pinned implementation. B is batch size; K is the learned number of selected positions, not a fixed sequence length.
| Operation | Input → output | What really happens |
|---|---|---|
| Embedding + encoder | IDs [B,L] → [B,L,1024] | Learned byte lookup; four causal Mamba-2 layers, then network RMSNorm. Every position gets a contextual vector. |
| Router + gather | [B,L,1024] → selected [B,K,1024] | Compare adjacent projected encoder vectors; gather those marked b=1. There is no chunk-average operation in the default downsampler. |
| Main network | [B,K,1024] → [B,K,1536] → [B,K,1024] | Append a shared learned 512-coordinate vector, run the 22-layer Transformer main network, apply RMSNorm at width 1536, then take the first 1024 coordinates on return. |
| Dechunk | [B,K,1024] → [B,L,1024] | EMA over the selected outputs using their selected scores; repeat the latest smoothed vector. The STE factor is 1 in the forward pass. |
| Residual + decoder | two [B,L,1024] paths → [B,L,1024] | Add the learned linear projection of the encoder outputs, then run four causal Mamba-2 decoder layers and RMSNorm. |
| Byte head | [B,L,1024] → [B,L,256] | The untied linear head supplies next-byte scores at every original position. Softmax gives a distribution; a generation policy can sample from it. |
Shape notation is logical and per sequence: K can differ across batch members. The release handles variable-length inputs using packing/masks; [B,K,D] is not a promise of one rectangular physical layout for every batch.
Exact configuration and head: one-stage Large config · LM wrapper. Widths and layer counts are one concrete release, not universal H-Net constants.
For a Transformer main network, each selected vector becomes an input position. Learned Q/K/V projections and causal self-attention let it use earlier selected vectors; feed-forward blocks transform the resulting features. “Selected” does not mean “understood already.” The main network does the expensive modeling on those selected inputs. H-Net is the surrounding architecture, not a replacement attention equation.
Connected numerical example from supplied encoder states to illustrative next-byte scores. Not checkpoint inference. Actual bytes are [99,97,116,33]. Embeddings E[99], E[97], E[116], E[33] and the trained Mamba encoder are not evaluated. We supply invented two-coordinate encoder outputs. The deepest main stand-in is one causal attention head with Q=K=V=I—not a full Transformer block or T22. Residual W=0.25I; outer decoder=identity; no width expansion or network norms. A two-stage option adds an explicitly invented causal inner encoder and decoder. Head weights are hand-defined. These choices explain composition, not learned segmentation or language ability.
Encoder matrix for the supplied option: [[1,0], [0.8,0.6], selected option, [−1,0]]; its router uses identity Wq/Wk, so strict selection means negative adjacent cosine and the paper/release projection-order difference is hidden. The computed options use the encoder chapter's embeddings, recurrence and non-identity Wq/Wk, so the convention switch changes the actual scores. In the eight-byte two-stage release-convention example the stage-0 selected positions are [0, 2, 3, 4] and the deepest main receives two vectors; under the paper convention the inner stage keeps fewer. The vector selector applies only to the supplied option. Coefficients use ordinary JavaScript arithmetic, not CUDA/dtype equivalence. A single sequence starts at position 0; zero-norm vectors are invalid in this toy.
Tables show a full causally masked four-position calculation, not permission for earlier outputs to see later rows. Change position 2: positions 0 and 1 stay unchanged. “Not selected here” does not guarantee no later selection; later cosine scores are recalculated too.
Inward: bytes → E⁰ → Chunk⁰ → E¹ → Chunk¹ → M
Outward: M → Dechunk¹ + Linear(E¹) → D¹ → Dechunk⁰ + Linear(E⁰) → D⁰ → byte head
A two-stage H-Net replaces the first stage's main block with another complete encoder/chunk/main/dechunk/decoder system. Stage 1 receives the selected vectors from stage 0, not raw bytes again. Each stage has its own routing scores, selection map, smoothing state and residual. The outer smoother consumes the inner decoder's returned vectors, not the deepest main output directly.
Neither “stage 0 = characters” nor “stage 1 = words” is guaranteed. Those are interpretations of learned behavior, not architectural type constraints. v2 §2.1.
Whole-process takeaway. H-Net learns which contextual vectors the large inner model processes, and how its shorter output informs every outer prediction. Routing alone is not H-Net.
03 / A four-beat reading strip
Read our example one byte at a time. The strip deliberately hides unread positions. A selected position sends its current encoder vector deeper. It does not collect a completed future word.
Predict before clicking: after reading ca, changing the future from t! to r! should leave all earlier results unchanged.
Separate scalar zoom, not the complete trace above. Invented scores: [1, 0.2, 0.8, 0.1] by default. Hypothetical main outputs at selected positions: 2 and 10. We compute selection and smoothing here, not learned encoder or main-network vectors.
Notice that the “outer path” count increases even when the deep count does not.
Takeaway 03. Causal means “no unread future.” Waiting deeper does not mean waiting everywhere.
04 / Open the selector
The router compares neighboring contextual representations and produces a score between 0 and 1. A large score signals a change. The released code keeps a position when its score is strictly greater than 0.5; the first position is forced to be kept.
In this toy we choose the score ourselves. Keep the four input bytes fixed for this experiment, and change only the score at position 2. That isolates the decision from everything else.
Predict: at exactly 0.50, will position 2 be kept? Make your prediction, then set the score.
Notice what crosses the gate: a vector of numbers at one position, not a string token. An earlier unselected byte can still influence a later encoder vector through the causal encoder.
Notice this: in the authors' routing panel, each little circle sits above a contextual vector. The diagonal arrows compare neighboring vectors—not whole words.
The score derives from cosine similarity of learned projections of adjacent encoder states. Similar directions give a low score; different directions can give a larger score. This is not a word-boundary detector with a dictionary.
Paper §2.2.1 / Eq. 4 writes p = (1 − cos(Wq x_current, Wk x_previous))/2 and uses p ≥ 0.5. The pinned release compares Wq x_previous with Wk x_current and uses strict p > 0.5. Learned unequal projections can make the scores differ. This lesson's toys use the release's strict decision; they do not simulate the learned projections.
Takeaway 04. The router learns which contextual positions to retain; it does not wait to recognize whole words.
05 / One number before a whole vector
Suppose the previous smoothed deep value is 2. At position 2, the main network hypothetically returns 10. Rather than completely replacing the old value, H-Net uses the routing score to mix old and new.
For now we use one number instead of a whole vector. Both numbers are invented, not the byte IDs 99 and 116.
Predict: with score 0.8, should the result be closer to the new 10 or the old 2?
These controls share the score with the selector above. Below or at 0.5, the new main output is not consumed: the correct result is “reuse 2,” not an interpolation with 10.
Notice the two jobs of the score: it decides whether to keep a position, and—at a kept position—weights the smoothing update.
Notice this: each upper square receives one arrow from the new output below and one from the preceding smoothed state on the left.
At selected index j, each coordinate uses the same scalar weight: smoothed[j] = P[j] × main[j] + (1 − P[j]) × smoothed[j−1]. This recurrence is evaluated over selected positions, not all original byte positions.
Our first selected value is exactly 2 in the unclamped conceptual toy. The released kernel clamps selected scores to [0.0001, 0.9999], so numerical execution has small differences. The retained dry-run offers the kernel-clamp option.
Takeaway 05. Smoothing blends selected deep outputs; it does not secretly process skipped positions.
06 / Return to every position
After processing fewer positions, we need one coarse value per original byte position again. Reuse the most recent smoothed value until another selected position arrives. This is causal repetition, not recovery of deleted bytes.
| Position / byte | 0 / c | 1 / a | 2 / t | 3 / ! |
|---|---|---|---|---|
| Deeper update? | yes | no | yes | no |
| Restored coarse value | 2 | 2 | 8.4 | 8.4 |
But the coarse path is only half the story. The encoder also sends a projected fine-detail residual directly to the decoder at every position. “Residual” just means an additional signal added to the coarse one. The decoder still updates on every byte, and its output head still scores the next byte.
Predict: hold the coarse vector fixed. Can changing only the fine detail change the next prediction? Try it.
New zoom level: to illustrate addition and an output head, switch from the earlier scalar 8.4 to a separate invented two-number vector [2, 1]. This is not a conversion between those examples.
Identity toy decoder; three invented candidate IDs A/B/C, not actual letters or trained predictions. The real byte-level head has 256 scores. Our head computes logits [first coordinate, second coordinate, −their sum], then softmax.
Takeaway 06. A reused coarse state does not force reused predictions: the fine-detail path and decoder still change.
07 / Connect the toy to the real design
Now open the real architecture, after the small example makes its arrows meaningful. This is the official H-Net repository's static architecture figure—not a live simulation and not our drawing.
Notice this: start at the bottom-left E, climb through the shorter middle, and finish at the top-left D. The right-hand panels open the operations we just computed.
Read the official panels again using the separate scalar lab's default score of 0.8: two selected outputs instead of four original positions, one blend producing 8.4, then restoration to [2, 2, 8.4, 8.4]. The full figure uses its own example and more positions; its colors are not our toy's byte IDs.
The authors' own explanation of an easily missed problem: a returned chunk representation can be misaligned with the position that needs it.
The embedding, encoder, router projections, main network, residual projection, decoder and prediction head are learned jointly. Training uses next-byte prediction plus a ratio-targeting auxiliary loss and gradient estimators around hard routing. Smoothing supplies a differentiable path through the routing scores; it does not make the discrete choice exactly differentiable.
We have not run trained weights. Our widgets reuse validated toy selection, smoothing and head arithmetic. Neither our chosen scores nor our invented vectors prove that a trained model will segment a particular sentence in the same way. Real learned boundaries can be context-dependent and need not match words.
Open training, straight-through estimation and ratio-loss labs ↓Takeaway 07. The toy explains the operations; the official figure shows how they compose and recurse.
Close the loop / learning and autoregressive generation
So far we have described a forward calculation. Training adds a target: after input c, score the true next byte a; after a, score t; after t, score !. These targets shift by one position. Our four-byte fixture has no supplied target after !, so it excludes that last row from its demonstration loss. Real training uses the surrounding data and the training sequence conventions.
Prediction loss: LAR = −mean(log probability of the true next byte).
Total: L = LAR + α ΣsLratios. Paper α = 0.03; there is one auxiliary term for each chunking stage.
Hard gather has no ordinary derivative telling the router “keep this other position instead.” H-Net does not magically solve that with backpropagation through an exact discrete choice. It uses two routes for a surrogate training signal:
The ratio term discourages an unhelpful “send everything deep” solution and targets a chosen compression ratio N. For each stage F = mean(b) and G = mean(p):
Lratio = N/(N−1) · [(N−1)FG + (1−F)(1−G)]F is computed from hard selections; gradients flow through G here. N is a training target, not a demand for exactly N bytes per chunk. Only along the special line F=G does this expression have its minimum at 1/N. It is not a universal “loss ≥ 1” theorem. The retained ratio-loss lab exposes the actual equation and partial derivative.
Grounding: v2 §2.2, Eqs. 7–10 and §2.3. Learned projections, embeddings and sequence models receive training signals jointly. The fixture evaluates losses only; it performs no optimizer step or gradient computation.
Here is the smallest connected version of the claim “the router learns from next-byte error.” We give the router one trainable number, φ: it rotates Wk. Everything else—embeddings, Wq, the tied toy head, the attention stand-in—stays fixed. The page then splits the derivative into the parts that can be differentiated and the part that is a declared surrogate.
One local derivative, not training. One stage, release convention, hard selection mask frozen while differentiating, central differences with ε = 10−6, and one parameter step. The gate derivative is also checked against independent softmax calculus. No optimizer state, mini-batches, other parameters or generalization are involved.
Read the table in this order. A skipped position still has a confidence c = 1 − p. Its forward gate is exactly 1, so ordinary differentiation of the forward pass sees no effect from the gate. The straight-through rule substitutes a backward derivative of 1 for the gate, so the router receives a signal from every position. Because dc/dp = +1 when retained and −1 when skipped, the local surrogate term is (2b − 1) × dL/dgate × dp/dφ. It is an estimator, not the derivative of the hard router. Try cot!: at a small step the surrogate-driven change does not improve the immediate fixed-mask loss; larger steps change the hard mask, which fixed-mask calculus cannot predict.
| Component | At every outer byte? | State and work |
|---|---|---|
| Encoder | Yes | Advance causal Mamba state; produce the current contextual vector. |
| Router | Yes | Compare with the immediately previous incoming encoder vector—even if that previous position was skipped. Remember the current vector for the next comparison. |
| Inner/main | Only when selected | Advance its Transformer KV cache or nested state on its own shorter clock. A nested stage may decide not to advance its own deeper main. |
| Dechunk | Called each step | On a boundary, update smoothed returned state; otherwise reuse it. This is not a new deeper-model computation. |
| Residual + decoder + head | Yes | Add the current projected detail; advance the decoder; produce the next-byte logits. |
Prefill first: consume the prompt and construct encoder/router/main/dechunk/decoder caches. Use the last prompt logits to sample one byte; consume that byte in the next decode step. Public LM step explicitly requires batch size 1; do not generalize this demonstration to arbitrary batched serving. The router remembers the previous incoming vector, not the last selected one.
v2 §2.4 · HNet.step and cache allocation · routing and dechunking step · official generation loop · cache contracts and worked notes.
Learning versus inference. Training changes weights using prediction and ratio losses. At generation, weights stay fixed; data-dependent routing changes which inner states advance.
Evidence for the design / what happened when parts were removed
An operation can be correct without being necessary. Paper v2 includes controlled removals and replacements. They support specific design choices in the tested settings; they do not prove every component is uniquely optimal or that every result transfers to another modality.
| Changed component | What the authors compared | Reported effect | What it does and does not show |
|---|---|---|---|
| EMA smoothing | Replace smoothing by direct upsampling (“w/o smoothing”) in the H-Net 2-stage ablation, Large scale, FineWeb-Edu (§3.3, Fig. 7). | Compression ratios fluctuated severely during training and performance degraded substantially; the authors call smoothing essential for stable training. | Supports smoothing as the most important of the three removals tested here. It does not show EMA is the only possible fix. |
| Cosine-similarity router | Replace adjacent-vector similarity with direct probability prediction from individual inputs. | Less critical than smoothing, but important for stability and final performance; the authors report more consistent compression and more interpretable chunks. | Supports comparing adjacent representations. “Interpretable” is the authors' qualitative reading, not a guarantee of word boundaries. |
| Straight-through estimator | Skip the STE in Eq. 9 (“w/o STE”). | Also less critical than smoothing, but contributes to stability and final performance. §2.2.2 says the model already performs well without it, with additional improvement when included. | Supports STE as a helpful estimator, not a necessity for any chunking behavior. |
| Downsampling by gather | Default gather versus max pooling, mean pooling or cross-attention, with and without boundary residuals (Appendix E.1, Fig. 13). | The simple default performed on par with the alternatives. | “On par” means extra pooling machinery was not shown necessary; it does not claim gather is superior. This is why the encoder-state chapter matters. |
| Encoder/decoder layers | M4-M4, M2T1-T1M2, T1M2-M2T1 and T2-T2 on raw bytes with H-Net (1-stage) (§3.3, Fig. 8); additional DNA ablations in Appendix E.3. | The authors report Mamba-based encoders/decoders significantly outperformed Transformer layers in text. In HG38, M3T1 slightly beat pure M4; they state a Transformer in the encoder did not help text and the DNA result may be modality-specific. | Supports the Mamba-heavy outer networks for these tests. It does not transfer unchanged to every modality or sequence length. |
Experiment details: §3.3 says the component ablations use Large scale trained on 36B FineWeb-Edu tokens; the displayed Fig. 7 x-axis is total training bytes. Statements above are taken from the paper's text and figure captions; this page does not re-plot, reproduce or independently remeasure the curves.
Operational explanation versus empirical rationale. The earlier chapters explain what each primitive computes. This table explains why the authors kept them, and how strong each piece of evidence is.
Practical limits stated by the authors
The earlier compute calculator is deliberately narrow. Paper v2's §4 adds scoped engineering observations that matter when deciding whether to use the architecture:
step additionally requires batch size 1.| Question | Measure | Why the inner-length calculation cannot answer it |
|---|---|---|
| Is training faster? | Tokens or bytes per second at matched quality and hardware | Outer encoder/decoder, routing, dynamic packing and kernels all cost time. |
| Will it fit? | Peak memory distribution over real data | Memory depends on the learned selection rate in each batch. |
| Is serving cheaper? | Latency and throughput for the intended batch size | The public step path is single-sequence; batched dynamic work is unresolved in the source. |
Less inner work is not the same as a better system. Treat the analytic reduction as an opportunity and the paper's engineering observations as scoped warning evidence.
Before comparing results
Bits per byte (BPB) converts a model's total negative log likelihood (natural-log units, “nats”) into a cost per byte of text: BPB = total NLL in nats ÷ (bytes × ln 2). Lower is better. It is a likelihood measure, not accuracy and not speed.
Same likelihood, different units: a tokenized model can have a larger loss per token and the same BPB. Therefore equal token loss does not mean equal byte loss. A token model's likelihood for one canonical tokenization is also at most the string's total likelihood (the string can have other tokenizations), so using one tokenization can only overstate NLL. Part II's prompt-boundary/marginalization correction is about this evaluation issue.
| Source | Measured quantity | Comparison condition | Do not conclude |
|---|---|---|---|
| Paper v2 §3 | Validation BPB on FineWeb-Edu; zero-shot task accuracies and their average | Matched training data and FLOP budgets at Large and XL; parameter counts differ | Accuracy gains are not BPB gains; matched training FLOPs are not matched latency or parameters |
| Cartesia Part I | Compute-equivalent advantages: about 1.28× to validation loss and 2.06× to the OLMES-based downstream measure in the carefully matched one-stage ladder | Controlled byte-versus-BPE ladder; separate, less tightly matched two-stage comparison | These are not speedups, not accuracy points and not production latency. The blog, not this page, defines the exact OLMES task mix. |
| Cartesia Part II | Loss-to-loss: validation BPB against downstream behavior, with compute-to-loss kept separate | Controlled comparison of byte, BPE, BPE-NP, BLT-like and H-Net models; special correction for the BPE-NP prompt-boundary issue | A better pretraining loss does not automatically give the same downstream result; interpretation as “understanding” remains a hypothesis |
Name the denominator. Before using any improvement, ask: loss or accuracy, bytes or tokens, validation or downstream, compute-equivalent or wall-clock, and which comparison conditions were controlled.
Read the sources without merging different models
Both supplied blogs are dated October 28, 2026. Part I explicitly describes a “much improved version,” calls the earlier published model LH-Net (“lazy” or “lookahead”), and says the improvements are planned for release. We audited the public code at the pinned revision, not an unpublished internal model. We cannot invent equations for the latter or claim that our widgets reproduce it.
| Source | Use it for | Do not assume |
|---|---|---|
| Paper v2 · July 15, 2025 | Recursive architecture, cosine routing, selected-vector downsampling, EMA/STE, ratio loss, original experiments and limitations. | The original model already contains every improvement reported in 2026. Historical benchmarks are not new local measurements. |
| Public GitHub · 3673fe1 | Actual operation order, strict ties, coefficient clamp, width/norm placement, caches, release configurations. | The implementation exactly follows every notation/tie in the paper, or implements undocumented internal changes. |
| Part I · Scaling Hierarchical Networks | Improved internal architecture, controlled scaling ladders, dynamic contextual/in-context chunking, original-versus-improved discussion. | Its qualitative chunk examples or compute claims are output from the public 2025 checkpoint or our fixture. |
| Part II · Learning from Raw Data | Compression versus transfer, role of pretokenization, byte/token comparisons, proxy boundaries versus joint learning. | Compression alone causes understanding; a BLT-like controlled baseline is the complete original BLT; compute ratios imply latency ratios. |
Part I says the older model can draw the boundary only after seeing the beginning of the next chunk. That is a statement about chunk alignment and when a useful representation becomes available. The public autoregressive implementation still consumes only current and past input. A vector selected on the current byte can summarize earlier context; a color band labeled with a chunk must not be interpreted as a complete future word embedded at its start. The paper's Figure 2 above makes this alignment problem visible.
Part II removes the hand-crafted regex pretokenization step from BPE in a controlled baseline, BPE-NP. Its BPE merge vocabulary is still corpus-learned. It compresses more yet can transfer worse in their experiments. So “the inner sequence is shorter” is not a sufficient explanation of quality. Which boundaries are chosen, and how they are learned with the model, matters.
Part I's controlled one-stage ladder reports about 1.28× compute-to-validation and 2.06× compute-to-OLMES advantages. These are historical author-reported research comparisons, not measured speedups on your machine, and not inference latency. The larger two-stage comparison has different parameter counts, data/cooldown controls and approximately matched FLOPs per byte; it is not an otherwise identical production race.
Part II then asks whether equal validation loss produces equal downstream results. Its transfer curves and proxy/frozen-boundary comparisons support the value of end-to-end learned boundaries under those tested budgets. “The model understands semantics better” remains an interpretation or hypothesis, not a proven causal mechanism.
A learned router can produce different boundaries for the same characters in different prefixes, including an in-context example. That changes activations and decisions with fixed weights. It does not mean the model retrains itself while you type.
Evaluation caveat from Part II: canonical tokenization need not represent the full probability of a byte string. Their BPE-NP comparison uses a prompt-boundary/marginalization correction; standard BPE curves generally do not receive that same correction. Do not mix the corrected and uncorrected quantities without saying so.
Open Part I for Figure 1's architecture, training dynamics, language/code chunk examples and in-context tokenization; open Part II for the scaling-law selector and boundary-learning comparisons. These are linked rather than rehosted: no separate reuse permission for the blog artwork was established. Our local images are the explicitly licensed repository/paper figures, not an imitation of the authors' interactive components.
Source-grounded conclusion. We can explain and compute the 2025 public mechanism. We can explain what the 2026 authors report and how their comparisons are scoped. We cannot silently turn that into a verified implementation of their improved internal model.
08 / Put the pieces back together
Final prediction: at position 1 (a), our toy does not select a deeper update. What happens?
Takeaway 08. Every byte keeps its own outer computation; only the expensive inner sequence gets shorter.
Optional same-page reference chapters
The original detailed explanations and numerical labs are preserved here, under their original section anchors. Repetitive page headers/navigation and the mandatory miniature-town presentation are not part of this reading path. The original source documents are preserved byte-for-byte in original-material.
Imagine the input is cat!. Because these four characters are ASCII, it is four bytes: 99, 97, 116, 33. A byte model must still produce a next-byte prediction after every input position.
The same large model processes c, then a, then t, then !. It has four positions to process.
This is straightforward, but a long document has many byte positions. Large-network work can be expensive.
A smaller outer network still reads all four bytes. A learned router may send only selected contextual vectors into the larger inner network.
The decoder uses both the latest inner result and the fine-detail path. It still produces a prediction at every byte position.
In the worked example below, deeper updates occur at c and t. This is a manually chosen teaching pattern, not a claim that trained H-Net splits this word that way.
Fewer deep updates explain the efficiency idea. They do not prove lower real latency, and they do not mean fewer model weights need to be stored.
A byte such as 99 is an index, not a meaning. The learned embedding table maps it to a list of numbers called a vector.
If the toy width is 2, a vector has two coordinates. The released Large model's outer width is 1024. Coordinates are learned; they are not named fields such as “word” and “emotion.”
The encoder processes the current vector using already-seen context. Its output is a contextual vector.
After reading a in ca, that vector can depend on both c and a. It cannot depend on the unread t. It is not guaranteed to store a perfect copy of the prefix.
The router gives a confidence score. The released code selects a position when its score is greater than 0.5; the first position is always selected.
The downsampler is the gather operation: it keeps those encoder vectors in order. It does not average a future word.
The larger network sees the selected contextual vectors, in causal order. It performs its own learned computation on that shorter sequence.
It does not receive the unselected vector as another position. But selected vectors may carry information about previously seen, unselected bytes through the encoder.
It smooths a newly returned inner vector with the previous smoothed vector. Between selected positions, it repeats the latest result.
“Upsampling” means restoring the number of positions, not reconstructing an exact original string or increasing numerical precision.
A learned projection of every encoder vector bypasses the shorter path. This is the skip/residual path. It supplies current fine detail.
The decoder combines that detail with the repeated inner result and uses its causal state. The output head maps its vector to 256 next-byte scores.
A packet shape such as [1,4,2] means: one example, four positions, two coordinates at each position. Shortening to [1,2,2] changes the number of positions from four to two; it does not necessarily change the vector width.
cat! without peeking into the future.Press “Read next byte”. Unread bytes stay hidden. The display tells you the prefix that has been read; that label is teaching metadata, not literal text stored inside a real neural vector.
Other fixed toy scores: position 0 = 1, position 1 = 0.2, position 3 = 0.1. This slider also drives the smoothing/training examples below. It is not a trained router or a learned segmentation result.
After reading ca, the outer encoder has updated twice. Its second vector may contain information about both bytes.
With the toy score 0.2, the second vector is not sent deeper. The repeated inner result is still 2. The current encoder vector and the decoder state are not frozen.
With the toy score 0.8, the third encoder vector is selected. It can depend on the already-read prefix cat. The main network returns a new hypothetical scalar value 10.
The smoother blends this with its previous value 2, giving 8.4. The model does not send the character string “cat” as a new dictionary token.
Stop after reading ca. Change the prepared input from cat! to car!. The read prefix, byte IDs and toy coarse state remain identical. The different third byte must not affect an earlier causal state.
The toy uses the same invented scores and values for both inputs, so it also does not model how a trained encoder might react differently after the third byte. This experiment tests no future peeking, not semantic understanding.
Assume the old smoothed value is 2 and a selected new main-network value is 10. The confidence p controls their blend.
At p = 0.8, take 80% of 10 and 20% of 2:
At p = 1, use the new value entirely. At p = 0.6, use 60% new and 40% old. At p ≤ 0.5, this toy position is not selected under the code convention, so there is no new deeper update and the result stays 2.
Bars show the effective blend weights. When the position is not selected, effective new weight is 0 and old weight is 1. The real module smooths full vectors coordinate by coordinate; these scalars isolate the arithmetic.
With p = 0.8, the inner path updates at positions 0 and 2. Its smoothed values are [2, 8.4]. Returning to four positions gives:
Position 1 reuses the newest available inner value, from position 0. Position 3 reuses the value from position 2. This is a causal hold: never pull a value backward from a future position.
The first selected score is 1 and the initial smoothed state is 0, so the conceptual first EMA equals the first main output. The released kernel clamps scores slightly away from 0/1; this beginner example omits that numerical detail.
No. Only one input to the decoder is repeated. The fine-detail input can change at every byte, and the real decoder has its own causal state.
Hold the coarse vector fixed at [2,1]. Change a projected detail vector [0,d]. Add them to get [2,1+d].
To isolate the addition and head, use an identity decoder in this toy: its output equals its input. A real H-Net decoder is a learned sequence network, not identity.
Our toy head has only three candidate IDs A, B and C; they are labels, not the letters in cat!. A real head scores all 256 byte IDs.
These weights are invented. The example proves that differing detail can change scores even with a fixed coarse input. It does not demonstrate a trained model's next-byte accuracy.
Slide d while the coarse vector stays fixed. The probabilities change because the head receives a different combined vector.
Softmax converts arbitrary scores into nonnegative probabilities that sum to 1. It is not choosing a new chunk; it is producing a next-symbol distribution.
Start with six encoder vectors e₀ … e₅. Their labels mark positions, not semantic types. Assume the first router selects positions 0, 2 and 4.
Nothing requires the first stage to be “letters to words” and the second to be “words to sentences”. Those are possible interpretations of learned patterns, not supervised stage definitions. Each stage selects positions in the sequence it actually receives.
It comes from the direction of two learned, projected contextual vectors—not from comparing raw byte IDs. In a two-coordinate example, use previous vector [1,0] and current vector [−0.6,0.8], with identity projections. Both have length 1; their dot product is −0.6, so their cosine similarity is −0.6.
This is a tiny numerical example of the actual similarity rule, not evidence that “t” produces those coordinates. The encoder and projections learn these numbers during training. Explore the angle slider →
The actual training objective rewards better next-byte prediction and adds a compression-budget penalty. It does not provide a correct boundary label for every word. Below, isolate only the smoothing gradient using a toy numerical target.
At p = 0.8, the blend is 8.4. Moving p up gives more weight to 10 and less to 2, so the blend increases.
With target 9, the derivative is −9.6. Gradient descent subtracts a negative number, so it raises p. With a small step 0.01, p becomes 0.896; the blend becomes 9.168 and squared error falls from 0.36 to 0.028224.
This is only a fixed-selection derivative. It is not exact differentiation through the decision to gather a position. The actual model also backpropagates through many layers.
The score is shared with the reader. The step is allowed only when it stays above the selection threshold and inside [0,1]. Invalid fixed-selection steps are explained, not silently clipped.
A hard keep/skip decision does not have an ordinary useful derivative at the switch. H-Net adds a surrogate gradient path using decision confidence.
Its gate equals 1 in the forward pass, so it does not shrink the repeated vector. In the backward pass, the gate passes a gradient to confidence. This is a training device, not another averaging operation.
The detailed chapter below includes the exact STE equations and code/paper distinctions.
Always keeping everything removes the efficiency benefit. Keeping almost nothing may discard useful context.
The ratio loss encourages a target average retained fraction. “Target 3 positions per chunk” does not mean split every third byte, and it does not guarantee every example attains exactly that average.
For six inputs, the actual router might keep two, three or another number depending on learned scores. The regularizer shapes training; it does not impose a fixed stride.
No. The encoder and decoder still update at that byte. Its information can also influence a later selected encoder vector. Only its direct position in the inner input sequence is omitted.
No. At “c”, “a” and “t” have not been read. The vector depends on the current prefix and earlier context. A later selected vector at “t” can depend on “cat”. Neither vector is a fixed word token.
No. It restores positions using smoothed inner outputs and causal repetition. The separate fine-detail path helps the decoder; there is no guaranteed lossless inverse.
Yes. Current projected detail and the causal decoder state can change. The three-candidate toy explicitly shows different probabilities from one fixed coarse vector.
A byte is one input/output symbol from the 256-value alphabet. A chunk here is one selected contextual representation used by the inner network. The output head still predicts bytes, not chunk IDs.
No. H-Net selects positions to send deeper into a shared hierarchy. MoE typically chooses experts for positions. Similar regularization ideas do not make the architectures identical.
No. It demonstrates selection, causal state updates, blending and a tiny arithmetic head. Language quality must be evaluated using a trained checkpoint and proper datasets.
Explore the detailed architecture → · Editable full trace → · Gradient and ratio-loss details →
Pause the precise architecture map's connector motion.
BPE chooses chunks using a vocabulary learned before language-model training. Segmentation is not jointly optimized with the language model's next-step objective.
Tokenization makes sequences shorter. Direct byte models lose that efficiency unless the architecture compensates.
The byte alphabet is still discrete. What disappears is the fixed subword vocabulary and external segmentation rule—not encoding, embeddings, or next-symbol prediction.
Its chunks are continuous contextual vectors, not new vocabulary IDs. Chunking can depend on the already-seen context.
A character such as “é” uses two UTF-8 bytes; many other characters use more. A byte-level decoder can emit a partial character before all its bytes have arrived. This widget encodes text only; it does not predict boundaries.
Teaching plan: understand bytes → follow the hierarchy → calculate routing → reconstruct a toy trace → understand gradient paths → inspect causal decoding → separate analytic savings from empirical results.
Choose a released Large configuration. Click any block to see its contract and source. The inner lengths are symbolic: learned boundaries determine them for each example.
This in-page schematic uses the same light palette. It preserves the exact layer counts, weights, tensor contracts and connector motion alongside the byte-by-byte illustrated article.
The coarse path supplies expensive context. The projected skip supplies fine-grained information at every original position. Selecting fewer vectors is not a claim that the input was reconstructed losslessly.
Byte embeddings, encoder/decoder blocks, inner blocks, router projections Wq/Wk, residual projections and the output head are learned.
Gathering boundary vectors and repeating by cumulative boundary count have no learned pooling weights. Wider stages append a shared learned vector; returning stages take the original leading dimensions.
Shapes: Wq, Wk and residual W are [Dˢ,Dˢ]. Large byte embeddings and untied head are each [256,1024] as stored in PyTorch. Activations are floating-point; byte IDs are integers; masks are booleans.
Paper §2.1 / Eqs. 1–3. The block scaffold follows the interactive flow-diagram template, adapted from service request flows to a full learning lesson.
Set Wq = Wk = I and use nonzero unit vectors. The first vector points at 0°. Change the next vector's angle.
The paper and code swap which adjacent input receives Wq versus Wk. They agree in this identity-projection toy; they need not agree for arbitrary trained matrices. Code argmax chooses “no boundary” at a tie.
Identical directions → p = 0. Orthogonal directions → p = 0.5. Opposite directions → p = 1. A score above 0.5 means negative projected cosine; the encoder/router learn the geometry.
“Probability” is the paper's informal confidence terminology, not a demonstrated calibrated semantic probability. No rule here says “split at spaces.”
Pinned router and dechunk sourcePositions 0–7 stand for a sequence. You provide boundary scores p and scalar hypothetical main-network outputs v. Selected outputs enter the EMA. Values at unselected positions are ignored by the coarse path. The real encoder, main network and decoder are not simulated.
Slate positions are retained. Orange outlines mark the inspected position. The table shows the full causal trace, not future information available to earlier outputs.
The EMA lives in selected-position space. Repetition maps it back to original-position space. On a non-boundary, the coarse state stays unchanged while the real outer encoder/decoder still update.
| Position | p | Selected? | Chunk index | v if selected | EMA / repeated value | Decision confidence c |
|---|
Default example, unclamped: keep [0,2,4,6] → coarse values [2,10,−4,6] → smoothed [2,8.4,0.96,5.496] → repeat [2,2,8.4,8.4,0.96,0.96,5.496,5.496]. Toggle the code clamp to see its small numerical effect.
Paper §2.2 / Eqs. 5–9. The zero-based indexing here is equivalent to the paper's one-based indexing.
Thresholding and gathering remain discrete. This is not exact differentiation through the selected index set; STE is a surrogate estimator. Its usefulness is empirical, not a guarantee of unbiased gradients.
Moving p without crossing the threshold does not multiply the displayed forward value by c. That is an easy STE misconception.
This calculation uses the current scores from the dry-run. Target N is a training preference, not a runtime command that guarantees exactly N bytes per chunk.
Curve is the illustrative F = G diagonal, not the actual hard-routing objective trajectory. Its minimum is 1 at F = G = 1/N; off that diagonal, the formula can fall below 1.
Each encoder, main network and decoder ends in RMSNorm to balance scales. The skip has a separate learned residual projection, with its weight initialized to zero in the inspected code. Width increases use learned padding. Residual initialization accounts for network depth. Stage-specific learning-rate modulation accounts for width and effective sequence lengths. Together these help prevent an unstable router/hierarchy from overwhelming training.
Every original byte updates the outer path. Not every byte updates the deepest path. Prefill computes the prompt's causal trace and populates caches; decoding then advances those states.
There is still autoregressive next-byte decoding. It does not automatically emit a complete learned chunk in one step.
The released LM step() asserts batch size 1. That is an implementation limit, not a mathematical requirement of H-Net.
Suppose position 0 is “c”, then “a”, then “t”. If only position 0 is selected, its coarse vector cannot contain the unseen “a” or “t”. The outer causal path still reads them. A later selected position can summarize previously seen context through the encoder. Therefore the vector repeated over an interval is the most recent selected contextual state, not a pooled representation of every byte in that visible interval.
Visual chunk spans are useful bookkeeping, but they do not prove that the selected vector knows future characters or corresponds to a complete word.
Stage count follows the architecture selector. Ratios here are analytic assumptions, not the ratio-loss targets or measured values from the dry-run.
This omits outer encoder/decoder work, routing, width changes, normalization, packing, kernel overhead and batching. It does not measure end-to-end FLOPs, peak memory, throughput or latency.
Longer effective reach per inner position is possible, but the model still has trained context limits and must preserve useful information. Compression is not unlimited memory.
These are historical, paper-reported results, transcribed from Table 2. They were not reproduced here. Models are matched in training data and FLOP budgets within each scale, not in parameter count. BPB is lower-is-better; average accuracy is higher-is-better.
| Scale | Model | Params, Table 1 | FineWeb-Edu BPB | 7-task average (%) |
|---|---|---|---|---|
| Large budget | Tokenized Transformer | 760M | 0.756 | 53.3 |
| Large budget | H-Net 1-stage | 680M | 0.755 | 53.6 |
| Large budget | H-Net 2-stage | 870M | 0.743 | 55.5 |
| XL budget | Tokenized Transformer | 1.3B | 0.730 | 55.5 |
| XL budget | H-Net 1-stage | 1.3B | 0.728 | 56.2 |
| XL budget | H-Net 2-stage | 1.6B | 0.715 | 58.2 |
Table 1: architecture · Table 2: evaluations · Other datasets
H-Net is the hierarchical wrapper and dynamic chunking mechanism. Its sequence blocks may be Transformers, Mamba-2 or hybrids. It resembles a causal U-Net, but uses learned variable-length subsampling rather than fixed spatial pooling. Its router selects positions for deeper processing, not one of several experts. The ratio loss draws inspiration from MoE load balancing; H-Net is not therefore an MoE.
MegaByte uses fixed-size grouping. SpaceByte uses delimiter-based selection. BLT uses entropy-based patching with an auxiliary predictor. H-Net trains its contextual boundary scores jointly with the main model using smoothing, STE and ratio regularization. These are mechanism comparisons; they are not a newly run benchmark ranking.
They can learn coarser abstractions, and the paper shows qualitative examples. No loss explicitly labels a stage as “words” or “sentences”. Stage meanings are not fixed or guaranteed. Contextual continuous vectors differ from a reusable dictionary of token strings.
Too many selected vectors remove the compute benefit; too few can lose useful context. Hard choices complicate gradients. Smoothing can blur representations. Variable lengths complicate packing and batching. Byte decoding requires more outer updates than token decoding for the same text. Long-range information can be lost in compression. UTF-8 encoding and special-symbol conventions still matter. Training FLOPs do not capture every serving cost.
Yes, after agreeing on a compatible checkpoint and compute environment. Start with the official code, run a short inference-mode prompt, read bpred_output, and record each stage's mask/scores. Preserve the checkpoint revision, dtype, byte IDs and causal position mapping. A compatible PyTorch hook or NNsight trace may capture additional tensors; do not assume generic TransformerLens adapters support this custom recursive model. Plot actual outputs in marimo/anywidget or this interface. No such inference was performed here.