# H-Net, one byte at a time

**Canonical entry:** <http://127.0.0.1:18768/hnet/index.html>  
**Project directory:** `./Concept_Learning\hnet`

A source-grounded illustrated reading journey: the next-byte task → byte IDs → a causal `cat!` reader → selection → one-coordinate smoothing → fine detail and prediction → official architecture → recap/caveats. Every section has a precise takeaway and a prediction prompt. Different relationships use different visual forms: a shared-prefix fork, byte ledger, two-lane timeline, selection strip, worked contributions, restoration table, probability bars and official source panels.

## What is interactive?

- A connected, eight-operation numerical trace from either supplied encoder states **or computed toy-encoder states** through routing, gather, a computed causal-attention main, vector EMA/repeat, residual/decoder and an illustrative **256-way** head. Switch exact-tie conventions and the release coefficient clamp; with computed states the non-identity `Wq`/`Wk` make the paper and release orderings give different scores.
- An encoder chapter that changes only a skipped byte (`cat!` → `cot!`) and shows the later retained vector, its contribution decomposition and the router decision change.
- An eight-byte two-stage trace (`cat cot!`, release convention) in which the deepest main receives two vectors and both stages skip positions.
- A one-parameter learning lab that splits one local derivative into EMA, ratio and STE-surrogate paths, including skipped positions, and reports a recomputed loss, any hard-mask change and an ordinary-only comparison. It is not training.
- Ablation-evidence, published-cost and metric chapters, including a bits-per-byte calculator.
- One-/two-stage switching executes the inner encoder/router/main/dechunk/residual/decoder and feeds the actual inner return into the outer smoother. Inspect ancestry and both return paths; this is not just a length animation.
- UTF-8 byte inspector (`cat!`, `é`, `猫`).
- Next/back/reset causal reader; swap `cat!` for `car!` without changing the already-seen `ca` prefix.
- Shared routing/blending score: strict `0.5` tie, selected-only update, synchronized restored values.
- Fine-detail vector changes a three-ID toy head while coarse input stays fixed.
- Comprehension feedback; global reset restores all primary experiments.
- The original numerical labs are also functional inside optional same-page reference chapters.

These are educational calculations, **not trained H-Net inference**. The new composed trace explicitly starts at invented encoder outputs: it does not evaluate byte embeddings or the trained encoder. Main attention, inner encoder/decoder, residuals and head are declared teaching substitutions. The exact public Large shape/norm contract is displayed separately. The original isolated experiments remain separate rather than being silently reinterpreted as outputs of that trace.

The July 2025 paper/public implementation and the October 2026 blogs' improved internal H-Net are now visibly separated. Training/STE/ratio loss, prefill/decode update clocks, and both blogs' compression/transfer findings have dedicated primary sections. See [the correction and claim audit](./SOURCE-AUDIT.md).

For the retained micro-labs: The first toy uses one scalar; the separate head demonstration explicitly switches to a two-coordinate vector. Byte IDs, routing scores and hypothetical neural values are distinguished. The paper/release threshold and projection-order differences, selected-score clamp, causal repetition, residual path and lack of guaranteed word boundaries are explicit.

## Files and preservation

- `index.template.html`: original primary article and figure captions.
- `lesson.css`, `lesson.js`: local original design and interactive primary path.
- `build.cjs`: deterministic assembly of `index.html` and `provenance.json`.
- `reference-notes.js`: generated from all 17 original additional worked-explanation definitions; keeps their computed text synchronized with the original labs, without their universal building visuals.
- `hnet-core.js`: original scalar APIs retained, extended with the tested connected one-/two-stage `forwardFixture`; `hnet-basics-core.js` unchanged.
- `forward-fixture.test.cjs`: focused composed-attention, tie/clamp/causality, head/loss and recursive-return tests.
- `SOURCE-AUDIT.md`: source/version reconciliation, claim/source map, exact versus synthetic operations and limitations.
- `original-material\`: byte-for-byte pre-upgrade session files, source lessons, old builder, guide, page and runtime assets. No original file was deleted.
- `hnet-guide.md`: retained historical v1 written guide, with a pointer to the corrected source reconciliation.
- `assets\official\`: original architecture PNG, two documented crops, MIT notice and pinned source evidence; original paper v2 Figure 2 and its CC BY 4.0 attribution notice.
- `verification\`: before/after desktop/mobile screenshots and machine-readable test receipt.

The builder embeds **all 17 original educational sections** (8 beginner + 9 detailed sections), equations, tables, citations and controls in two optional reference chapters. It removes duplicate page headers, menus and footers; the original pause control is relocated rather than discarded. One obsolete architecture caption now names the illustrated article, and the displayed inference-note title says “prediction” rather than “roof.” Original numerical UI scripts and worked-note computations are retained unchanged. Existing `#basics-*` and `#full-*` deep links automatically open the enclosing reference chapter.

The old compulsory isometric world and per-section building visuals are **not executed in the new article**. All 17 extra worked-explanation definitions remain accessible as optional textual notes within the reference chapters. Their original node computations are reused verbatim; the original visual runtime/artwork remains archived. This is retained content, not a second primary interface.

The old session page `http://127.0.0.1:18766/hnet-world.html` now automatically redirects to the canonical page. Existing `#full-*` / `#basics-*` fragments and query strings are preserved; retired town anchors map to relevant reading sections. Its original content remains archived byte-for-byte under `original-material\hnet-world.html`. No existing server is started, stopped or reconfigured.

## Official imagery and source grounding

Source: <https://github.com/goombalab/hnet>, revision **3673fe1217ebeb0d1438c7c71d58d32bdd190ec2** (resolved via GitHub API on 2026-11-17).

Repository license inspected **before download**: MIT, copyright © 2025 brwa-cartesia. The official README embeds `assets/arch.png`; no separate asset restriction or third-party attribution was found in the inspected README/license. The required complete notice is retained in `assets\official\LICENSE`. This is the reuse basis, not an assertion that every arbitrary repository image inherits its code license.

| File | Dimensions | Treatment |
|---|---|---|
| `assets\official\arch.png` | 3176 × 2720 | Original bytes, unmodified |
| `assets\official\routing-crop.png` | 1281 × 515 | Rectangular crop of panel (a), x=1895, y=2080 |
| `assets\official\smoothing-crop.png` | 1281 × 575 | Rectangular crop of panel (c), x=1895, y=800 |
| `assets\official\paper-v2-smoothing.png` | Exact PNG dimensions in `provenance.json` | Unmodified paper v2 Figure 2, CC BY 4.0; separate notice |

`provenance.json` records complete source URLs, revision, authorship, rights, checksums, byte sizes, crop coordinates and original-source snapshots. Every displayed figure has alt text, a “notice this,” an explanation, a takeaway, credit and a full-size/source link. The official English/code/Chinese/Korean GIFs were identified in the source listing/README but deliberately not downloaded: static source imagery avoids compulsory animation.

Current mechanism claims were checked against the supplied [paper v2 §§2.1–2.4](https://arxiv.org/html/2507.07955v2), its relevant ablations/discussion/Appendix E.1, [Cartesia Part I](https://www.cartesia.ai/blog/from-tokens-to-bytes-part-1), [Part II](https://www.cartesia.ai/blog/from-tokens-to-bytes-part-2) and pinned `hnet\modules\dc.py` / `hnet\models\hnet.py` (local snapshots in `assets\official`). General progression inspiration: Jay Alammar's illustrated explanation; no prose, artwork or visual identity copied.

## Build and validate

From this directory:

```powershell
node .\build.cjs
node --test .\hnet-core.test.cjs .\hnet-basics-core.test.cjs .\forward-fixture.test.cjs
$env:HNET_PLAYWRIGHT='./.copilot\session-state\14c48ac6-7170-4cd0-8c15-8482eb592b94\files\hnet\tools\node_modules\playwright'
node --test --test-force-exit .\lesson.browser.test.cjs
```

`prepare-figure-crops.ps1` reproducibly creates the two documented panel crops from the retained original on Windows; it does not fetch or redraw imagery.

Browser tests use installed Microsoft Edge, not a downloaded browser, and the existing canonical preview. Set `HNET_URL` to override the URL and `HNET_PLAYWRIGHT` to an installed Playwright module. Playwright was installed only after the missing-module failure, under isolated session `hnet\tools`; it is not a lesson runtime dependency. **Teardown limitation:** `--test-force-exit` bypasses an unresolved Playwright/Edge teardown hang; it is not proof of leak-free cleanup. Every test body completed and its pages closed, but a stale owned runner/Edge chain was subsequently found and terminated by exact PID. The suite now also asserts zero contexts before browser close. Focused redirect/context/process evidence and the correction are in `verification\followup-clarification.json`; `verify-followup.cjs` runs only those focused checks.

The browser suite separately records specific legacy-redirect `ERR_ABORTED` cancellations of obsolete scripts. They are expected navigation cancellations, not failed canonical runtime assets; all other failed requests still fail validation.

The browser suite checks exact section DOM preservation with scripts disabled, snapshot/image hashes, all local image decoding and dimensions, anchors/unique IDs, new interactions, backward/reset behavior, original lab response, deep links, keyboard operation, reduced motion and 1440/390px layout. The figure's full-size link is available when labels are too small on a phone. Wide reference diagrams/tables intentionally scroll **inside** their own containers.

See `verification\receipt.json` for actual results; do not infer test success from this description. No model execution, benchmark reproduction or assistive-technology user study was performed. All runtime assets are local; source hyperlinks require internet.
