# Serving systems: core principles

Status: beginner-first illustrated article, upgraded 2026-11-17. Original research: 2026-11-13; mechanism/source refresh: 2026-11-16. The complete earlier lesson remains an optional same-page reference.

## Run

Open [index.html](./index.html) directly in a modern browser. It uses local classic scripts and CSS, no CDN, fetch, server or build step.

**Canonical existing preview:** <http://127.0.0.1:18768/serving-systems/index.html>. The other existing preview serves this folder directly at <http://127.0.0.1:18767/index.html> (not at `/serving-systems/` on that port). Do not start/stop those existing servers as part of lesson validation.

The changed reference renderer and stylesheet use versioned asset URLs. An existing shared preview had kept the old building renderer after an ordinary reload even while its HTML was fresh; the versioned URLs were checked in that same preview and loaded the replacement views.

For an independent preview only when none is already available, from this folder:

```powershell
python -m http.server 8765 --bind 127.0.0.1
```

Stop that foreground command with Ctrl+C when finished.

## Primary illustrated reading path

The canonical page is [index.html](./index.html). Start with a repeated concrete request, `Help · me · plan · a · trip`, then open one box at a time:

1. The repeated job: shared preparation is not a cached answer.
2. Token labels, prefill/decode, keys/values and a hand-computed weighted value.
3. Address translation: trace position 4 to physical 33:0, relocate it to 5:0, keep the data unchanged.
4. Prefix reuse: a compressed trip/meal tree, leading matches, identity gating and the exact 4/5 full-block count.
5. Hybrid recovery: endpoint 5 versus fallback 4, complete state and the difference between captured host state and absent state.
6. Scheduling: a separate A/B/C ledger with 2 slots and 4 positions/tick; explain the deliberate simplification.
7. Reassembly and apples-to-apples cold/warm policy counts, then benchmark criteria.

Five primary-path interactions have resets and reuse the preserved numerical models. Address tables, token tapes/branching, state timelines and scheduling ledgers intentionally use different visual grammars. The small-screen radix tree reflows as readable HTML rather than shrinking SVG text. Predictions, intermediate values and takeaways sit beside their mechanisms.

### Optional same-page depth: all earlier content preserved

The seven reference chapters remain in `details#technical-reference > .reference-content`. Existing IDs, equations, sources, controls and four original labs remain in place. The six former miniature renderers in `deep-lesson.js` and their styles in `world.css` have been replaced, not hidden. Numerical models and both numerical test files are unchanged. Deep links automatically expand the enclosing reference tier. There is no separate old-design page.

The reference tier retains:

1. Request lifecycle, model weights versus per-request state, prefill/decode, vocabulary and packet contracts.
2. vLLM and SGLang end-to-end lifecycles; FlashStates as a vLLM research extension, not a third interchangeable full engine.
3. PagedAttention address translation **and actual attention arithmetic** across scattered KV pages: causal visibility, scaled scores, stable softmax, weighted values and relocation invariance. Includes copy-on-write, prefix hashes and the distinction from FlashAttention.
4. An actual compressed radix tree with three insertions, edge-split logs, editable request matching, identity mismatch and separately illustrated page-aligned reuse.
5. Hybrid recovery with complete endpoint state, capture/export options, host-tier constraints and a shared-block ownership/eviction dry-run.
6. End-to-end capability comparison, a same-workload teaching table for cold/warm/edited prefixes, and a real-benchmark protocol. No invented latency leaderboard.
7. All four original numerical panels below, preserved as additional inline labs in the same light design.

The optional walkthroughs now use six different representations:

| Mechanism | Representation | What changes |
| --- | --- | --- |
| Request lifecycle | Sequence trace between actors | Highlighted message and packet contract |
| Framework organization | Responsibility matrix | Active lifecycle column across all three systems |
| Paged attention | Logical tape, directory and physical-slot map | Actual addresses, visible positions and output from the attention controls |
| Radix insertion | Growing compressed tree | Real insertion A, then B, then C; compatible request matching |
| Hybrid recovery | Aligned KV/state endpoint timelines | Inspected requirement at illustrative endpoint 26 |
| Controlled comparison | Measurement protocol and event boundaries | Fixed inputs, tracing, validation, then scoped reporting |

Paging and radix read the existing numerical models and track their live controls, including reset and invalid-input errors. The other views are explicitly illustrative, not GPU traces or measured timings. All keep manual Previous/Next, opt-in Play, global pause and reduced-motion support. No building, roof-lift or forced isometric runtime remains in the active page. Official figures are unchanged.

Everyday analogies include a restaurant, library catalog, commute, cooking checkpoint and delivery service. Each maps back to technical objects, states its limits and returns to a numerical mechanism. They are not factual performance evidence. No unverified trivia has been added.

### Retained original labs

1. **Foundations:** prefill, decode, KV memory, and a stepped token-budget scheduler. New requests enter between iterations; finished requests release their slots.
2. **vLLM:** map logical token positions to scattered physical blocks; change context/block sizes and inspect tail waste. The tensor layout is schematic, not a backend ABI.
3. **SGLang:** compare token-ID prefixes, page-aligned reuse and the suffix to compute; inspect a compressed radix path.
4. **FlashStates:** require matching attention KV plus recurrent/auxiliary state; compare an invented block-grid checkpoint with exact-end capture, then invalidate components or edit the prefix.

Every panel has a worked dry-run, equations, packet contracts and source links. Continuous connector motion is decorative and can be paused.

## Important distinctions

FlashStates is a research system built on a vLLM fork, not a peer engine replacing every function of vLLM or SGLang. The singular "FlashState" in the request was resolved to the upstream FlashStates project.

Both vLLM and SGLang have scheduling, KV pools and prefix reuse. The lesson isolates their characteristic mechanisms; it does not claim these capabilities are exclusive. Current vLLM attention backends differ from the original PagedAttention kernel.

FlashStates' comparison uses an invented grid baseline, not a claim about all current vLLM/SGLang releases. Exact-end reuse requires a complete state at the same model configuration and matching prefix. Capacity and transfer costs are not measured here.

The refreshed vLLM snapshot has partial-block entries and copy-on-write paths even though its prefix-cache documentation describes full blocks. The exact modes enabling those paths were not verified. The radix tree toy deliberately separates token-level compression from aligned physical reuse; it is not a literal drawing of SGLang's page-group child keys. Full-prompt final-logit/boundary recomputation is not included in the reuse-count toys.

Both current pinned engines contain hybrid-related components; their support was not exhaustively audited. FlashStates' baseline claims apply to its stated releases, not all later versions. Its options were read in the pinned change document, not enabled or executed.

The ideal KV equation covers dense full attention, not sliding-window, compressed, latent-attention or hybrid recurrent storage. Toy interactions claim no measured speedup, TTFT or throughput. The clearly labeled official FlashStates figure retains upstream historical benchmark values with configuration-specific attribution; those are not lesson measurements or a modern-engine leaderboard.

## Official figures and reuse rights

Three original static PNGs are rehosted unmodified: two vLLM documentation block-lifecycle diagrams and the FlashStates overview. They are project-authored figures in pinned Apache-2.0 official repositories. Full license texts and FlashStates NOTICE are retained. Captions supply a purpose, “notice this”, takeaway, full-size link and version-specific caveat.

See [figure provenance](./assets/official/provenance.json) for URLs/revisions, SHA-256, byte sizes and dimensions, and [attribution](./assets/official/ATTRIBUTION.md) for reuse evidence and notices. SGLang's official authors' radix blog figure is **linked only**, because its reuse rights were not established. No image generators or copied tutorial prose/artwork were used. All displayed images are local/static and work offline; external source links need a connection.

## Source and code

- [sources.json](./sources.json): official sources and source-code snapshot references.
- [models.js](./models.js): pure teaching calculations, also importable by Node tests.
- [app.js](./app.js): UI and SVG rendering.
- [illustrated.js](./illustrated.js) and [illustrated.css](./illustrated.css): new article interactions and responsive reading/visual grammar, without altering old models.
- [models.test.cjs](./models.test.cjs): focused calculation and scheduler tests.
- [deep-models.js](./deep-models.js) and [deep-models.test.cjs](./deep-models.test.cjs): paged attention, compressed radix insertion/matching, shared ownership and comparison-count models.
- [deep-lesson.js](./deep-lesson.js) and [world.css](./world.css): live reference articles and six concept-specific visual grammars; [styles.css](./styles.css) supplies the retained base layout.
- [lesson.browser.test.cjs](./lesson.browser.test.cjs): self-contained loopback fixture plus Edge/Playwright checks; page/context closes complete, but browser-process teardown has the limitation below.

Run checks:

```powershell
node --test models.test.cjs deep-models.test.cjs
node --check app.js
node --check deep-lesson.js
```

Browser checks use Node Playwright and installed Microsoft Edge. They are optional development dependencies, not lesson runtime dependencies. If Playwright is absent, install it in a disposable tools directory, then run:

```powershell
npm install --prefix '<tools-directory>' --no-save --package-lock=false playwright
$env:NODE_PATH = '<tools-directory>\node_modules'
node --test --test-force-exit models.test.cjs deep-models.test.cjs lesson.browser.test.cjs
```

Set `LESSON_SCREENSHOT_DIR` to an output directory to capture desktop/mobile full-page images during that run. No model packages are required.

The isolated tools used for this upgrade were in `verification\tools\node_modules` (`NODE_PATH`); that entire tools folder was removed after validation. Recreate an isolated development dependency using the commands above when rerunning.

**Teardown clarification (2026-11-17):** every test assertion and awaited per-test `page.close()` completed. The after-hook races `browser.close()` against 3 seconds, asserts only `isConnected() === false`, closes its own HTTP connections/server, and uses `--test-force-exit` to end the runner. Transport disconnection does **not** prove browser-process exit, and the hang was not confirmed to be merely profile-directory cleanup. Follow-up found orphan Edge helpers. The final-run root/helper PIDs 20100/61312 were already absent when cleanup reached them. Earlier owned GPU helper PID 8652 remains visible in CIM, while `Get-Process` and `Stop-Process -Id 8652` report it absent; OS resource cleanup for that inconsistent entry is **Unresolved**, not claimed successful. No unrelated browser or existing preview server was stopped. Future fixture reruns should explicitly track browser PIDs and verify process exit.

## Current validation (illustrated article, 2026-11-17)

**Latest visual correction:** the repeated isometric renderers are replaced with the six representations listed above. The full **19-test serving suite passed again**, including progressive tree splits, live address relocation, identity errors, playback/pause, official assets and 1360px/390px layout. The [concept-view receipt](./verification/concept-views-receipt.json), [test transcript](./verification/concept-views-tests.txt) and [screenshots](./verification/concept-views/) describe this current revision. The earlier receipt below describes the initial illustrated-article rebuild; its preserved-file hashes are historical, not hashes of the later renderer changes. The browser teardown limitation remains open. A new before capture timed out, so no new matched before/after pair is claimed.

**19 tests pass:** 10 unchanged numerical tests and 9 browser tests (5 preserved regressions + 4 new illustrated-article tests). Exact address relocation, prefix edits/identity gating, host captured/uncaptured recovery, equal-policy comparison, scheduler completion order/budgets and all resets are checked. Image bytes match registry hashes and all three decode to positive natural dimensions. Desktop/mobile overflow, unique IDs, in-page anchors, reference deep-link expansion, SVG bounds and reduced-motion behavior are checked.

See [the durable validation receipt](./verification/validation-receipt.json) for commands, evidence paths, preserved-file hashes, corrections and limitations. Before/after screenshots use 1440×1000 desktop and 390×900 mobile viewports. No actual model, GPU or benchmark was run.

## Recovered separate-session context

Source session: `4f1e8d33-a9d8-4643-bc92-9c7e7b990c4d`, local turns 0–3. All four accessible turns were queried; one assistant response was absent. The recovered request established `Concept_Learning` as the working folder and asked for FlashStates/vLLM/SGLang core principles. The existing lesson, models, source registry, guide and root records supplied the durable implementation state. This is the accessible local history, not a claim of recovering inaccessible chats or every external artifact.

The separate session's original researched tool catalog remains at [the project catalog](../instructions/interactive-explainer-ecosystem-research.md). The project prompt was revision 2 while the completed H-Net work had advanced to revision 3. It is now synchronized to [revision 4](../instructions/interactive-technical-explainer-system-prompt.md), preserving that tool catalog/routing and adding the subsequent teaching, design, complete-migration and everyday-life bridge requirements. The two session prompt copies were synchronized as well.

## Historical validation (2026-11-16 expanded lesson)

- Verified 2026-11-16: **15 tests passed** (10 numerical and 5 browser); `node --check` passed for `app.js`, `deep-models.js` and `deep-lesson.js`. Local documentation links resolve and the source registry parses as JSON.
- Browser geometry passed at **1360 and 390 CSS pixels** across all retained labs. Full-page desktop/mobile captures were produced; top layout and the final miniature/connector region were visually inspected. This is not a claim that every possible input/layout combination was visually inspected.
- All three revision-4 prompt copies matched SHA-256 `50701380146fc32abed972fd94b832d88a3aeac52689373104040ac9f46365e1`. The loopback preview returned HTTP 200 on port 18767; port 18765 was left untouched after returning an empty response.
- Run the commands above to reproduce the tests. The numerical suite covers hand-computed attention, relocation invariance, causal visibility, radix insertion/splits/endpoints, identity gating, dependency-safe freeing, declared comparison counts and invalid input, alongside all original tests.
- Browser coverage exercises new calculations, all original panels, long-label tree containment, unique IDs, working chapter anchors, equal isometric axes, roof-step controls, global pause/reduced motion and desktop/mobile geometry. Screenshots are captured from the generated UI; no pre-change image is claimed.
- New primary-source refresh inspected the pinned vLLM scheduler/cache files, SGLang radix/cache-policy files and FlashStates README/change/benchmark documents. It did not re-read the FlashStates PDF, audit the fork enforcement code, reproduce benchmark results or trace every frontend-to-output function. General lifecycles are explanatory synthesis. Per-source scope is recorded in [sources.json](./sources.json).
- The ownership lab closes the earlier shared-accounting task; it is not a complete GreedyDual-Size admission/eviction simulator. A real-engine trace still requires explicit model/hardware/budget selection.

## Historical validation (original four panels)

- `node --test models.test.cjs`: **5 tests passed**, covering scattered addresses, block boundaries, page-aligned reuse, incomplete/edited hybrid states, host restore, aligned-endpoint fallback, ideal KV bytes and scheduler completion/budget.
- `node --check app.js`: passed.
- Source registry JSON parsing and relative Markdown-link existence checks: passed.
- Integrated-browser smoke checks: scheduler step, paging address, inspected-index adjustment, radix alignment, visible invalid-input error, exact endpoint, missing-state fallback, host restore, prefix edits, reset, endpoint-following slider and motion pause passed; no JavaScript page errors observed during those checks.
- Additional browser regression: an incomplete grid-aligned endpoint falls back one grid, and a complete host copy restores that endpoint.
- Browser geometry checks at viewport widths **1280 and 390 CSS pixels**, across all four panels: no page-level horizontal overflow or SVG text outside its viewBox. Diagrams intentionally scroll inside their own container on narrow screens.
- Screenshot capture failed in the browser tool. Screenshot-based visual inspection is therefore **not completed**; geometry checks do not prove all possible node/label collision cases.
- Direct integrated-browser file preview was blocked by its trusted-folder restriction. Browser checks used a temporary loopback HTTP server scoped to this lesson folder; that server was stopped afterwards. Direct-file operation in a separate ordinary browser was not independently tested.
- Research agents inspected public sources; they did not run engines, install packages or reproduce paper benchmarks.

The first scheduler test incorrectly expected arrival order to equal completion order. Its expectation was corrected to B, A, C: B has fewer output steps. A slider endpoint-following ordering issue and incomplete grid-aligned state fallback were corrected and validated before delivery.
