Skip to content

docs: target 1's gate at today's build — the shared handoff is 0.12-5.56 ms of cell bookkeeping, and the imported region is ASan-clean (refs #698) - #1281

Merged
bong-water-water-bong merged 4 commits into
mainfrom
1bit/t1-gate-1106
Nov 6, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
1bit/t1-gate-1106

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Runs target 1's gate again in the shape that ships and corrects the page I merged two hours ago (#1271): the shared
handoff is cells bookkeeping, not flat in prompt length. Refs #698.

Measured (2026-11-06, build at pin d70b67bf0, gpu-hold -l zerocopy, die 66 °C, held 377 s)

Cross-process: a separate provider process, the region exported over SCM_RIGHTS, an AddressSanitizer-instrumented
provider mapping it and prefilling into it, the decoder adopting the cells (t1_handoff_lengths.sh +
t1_asan_import.py, now env-overridable for server/provider/model):

prompt tokens region provider import decoder adopt cells n_read prompt_n text ASan
307 648 MiB 40.57 ms 0.122 ms 307 0 1 The tide comes in twice a day, 0
4 105 1.1 GiB 78.73 ms 1.988 ms 4 105 0 1 identical 0
16 399 2.8 GiB 150.40 ms 5.558 ms 16 399 0 1 identical 0

prompt_n 1 on every arm is the contract that matters: the decoder decoded from the adopted cells instead of
re-processing the prompt (engine#941's shape), and n_read 0 is "no prompt bytes moved".

What was wrong on the page

"0.05-0.26 ms, flat in prompt length" was an in-process measurement at 256-2 048 cells. Across a process boundary at
307-16 399 cells the same adoption step is 0.12-5.56 ms — ~0.34 µs per cell. It still moves no prompt bytes, so it is
still 8.2-242.9 ms cheaper than the file route at the same lengths, but "flat" was a claim the numbers do not support and
the page now says what was measured. The provider's own side (40-150 ms to map and first-touch 0.6-2.8 GiB, a page fault
per page it writes) is on the page too, labelled as sanitizer-inflated and not a copy, and the page states why the shared
column is a 4B while the file column is 30B-A3B (a 30B under ASan prefills for hours — not a measurement worth making for
a property that does not depend on the model).

Also closes something the lane owed

The ASan pass on the imported region, outstanding since 2026-10-31: three lengths, 0 AddressSanitizer reports, 0
glibc corruption lines. That is the check that was described as "removing the teardown removed the detector" — it is
detected here, at three sizes, with the sanitizer on the side that actually maps and writes the region.

Docs only. tools/copyright.py --check clean; no code or test changed.

…, not "flat", 0.12-5.56 ms

The merged zero-copy page claimed the shared handoff was "0.048-0.258 ms, flat in prompt length". Running
target 1's gate in the shape that ships says otherwise and the page has to say what was measured:

  cells   307 / 4 105 / 16 399
  adopt   0.122 / 1.988 / 5.558 ms      n_read 0, prompt_n 1 on every arm
  import  40.6 / 78.7 / 150.4 ms        648 MiB / 1.1 GiB / 2.8 GiB mapped and first-touched, ASan provider
  text    identical on all three        ASan reports: 0

So the handoff moves no prompt bytes but its cost is per *cell*, ~0.34 us each: 0.12 ms at 307 cells, 5.56 ms
at 16 399 — still 8.2-242.9 ms cheaper than the file route at those lengths, and the 10-31 in-process figure
(0.048-0.258 ms at 256-2 048 cells) was the same step without the process boundary. Also records the
provider's own side honestly (a page fault per page it writes, sanitizer-inflated) and why the shared column is
a 4B while the file column is 30B-A3B.

This is also the ASan pass the lane had owed since 2026-10-31: three lengths, zero reports in the provider.

Harness: t1_handoff_lengths.sh + t1_asan_import.py (zero-copy probe set), now env-overridable for the server,
provider and model. Refs #698.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

#1281 ready for review at c8799da601c98b9080440f01f0c232b8bef00cb2 — MERGEABLE, docs only, 1 file (docs/zero-copy.md), +25/−8. It records target 1's gate run at today's build and fixes a claim #1271 shipped two hours ago that the numbers do not support (flat in prompt length): the handoff is per-cell, 0.122 / 1.988 / 5.558 ms at 307 / 4 105 / 16 399 cells, with n_read 0, prompt_n 1 and identical greedy text on every arm. Same run is the lane's owed ASan pass on the imported region: 0 reports at three lengths. Gate was gpu-hold -l zerocopy (held 377 s, released clean), tools/copyright.py --check clean.

@bong-water-water-bong
bong-water-water-bong merged commit a47d8e8 into main Nov 6, 2026
9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/t1-gate-1106 branch November 6, 2026 20:19
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

698 - Partially compliant

Compliant requirements:

  • Target 1's gate is implemented and measured
  • The hybrid KV handoff is now zero-copy, using shared memory
  • The gate is met with text identity, not a tolerance
  • Measurements are provided for 307, 4105, and 16399 tokens
  • ASan-clean provider mapping and prefilling is verified
  • Cross-process measurement using SCM_RIGHTS is documented
  • The provider's own side of the handoff is measured
  • Two usability properties are implemented and documented
  • ONEBIT_KV_SHARE behavior is correctly implemented

Non-compliant requirements:

  • The PR does not include the actual code changes for enabling zero-copy KV handoff, only documentation updates

Requires further human verification:

  • Verification that the actual implementation of zero-copy KV handoff is correctly integrated into the serving paths
  • Confirmation that the cross-process measurement setup is correctly configured and functional
  • Validation that the fallback behavior for non-exporting backends works as expected
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Documentation Update

The documentation has been updated to reflect the correct measurement results for target 1, changing the cost from flat in prompt length to cell metadata cost. This is a documentation-only change and does not introduce any new code or functionality.

| 1 | hybrid KV handoff without the file | **shipped**, opt-in: `ONEBIT_KV_SHARE=1` ([docs/hybrid.md](hybrid.md), "The shared route"). 0 bytes copied; the cost is cell metadata, **0.12 ms at 307 cells to 5.56 ms at 16 399** |
| 2 | NPU runtime: activations live in BOs | **not done**. Measured price is ~4 % of a token on the 27B NPU path, and the two things that decide it are the M=128 pad and the XDNA cache model — both NPU-runtime work, not a transport fix |
| 3 | ONNX EP IO binding onto BO memory | **not done**. Priced, not measured per-call here; ORT IO binding exists and is unused |
| 4 | this audit | **this page** |

## Target 1 — the hybrid handoff moves no bytes

The file route writes the provider's sequence state to disk and the decoder reads it back through the page
cache, for a handoff that never leaves the box. `ONEBIT_KV_SHARE=1` replaces it with dma-buf fds: the decoder
exports its KV region, serve passes the descriptors to the provider as inherited fds, the provider prefills
into that region, and the decoder adopts the cells with no data movement (`llama_kv_cells_adopt`). The
provider contract, the flag semantics and the fallbacks are in [docs/hybrid.md](hybrid.md); what this page
adds is the price.

| route, same box, same model | handoff | what it scales with |
|---|---|---|
| state file, 27B hybrid (Qwen3.5): 307 / 4 096 / 16 384 prompt tokens | **28.82 / 61.82 / 198.53 ms** | prompt KV (65 536 B/token) **plus** ~151 MB of GDN recurrent state on every handoff |
| state file, 30B-A3B (full attention): 307 / 4 096 / 16 384 | **8.22 / 68.29 / 242.86 ms** | prompt KV only (98 304 B/token), no constant term |
| shared region, 4B, 307 / 4 105 / 16 399 prompt tokens | **0.12 / 1.99 / 5.56 ms**, `n_read` 0 | the number of **cells**, not bytes: ~0.34 us per cell |

Measured in the shape that ships (2026-11-06, build at pin `d70b67bf0`): a *separate* provider process, the
region exported over `SCM_RIGHTS`, an **AddressSanitizer-instrumented** provider mapping it and prefilling into
it, the decoder adopting the cells. **0.122 / 1.988 / 5.558 ms** to adopt 307 / 4 105 / 16 399 cells, with
`n_read` **0** and `prompt_n` **1** on every arm — the decoder decoded from the adopted cells instead of
re-processing the prompt — and **0 ASan reports** in the provider. So the handoff is cells bookkeeping and it
does grow with the prompt, just not with prompt *bytes*: 0.12 ms at 307 cells, 5.6 ms at 16 399. The shared
figures are on a 4B because that is the model the ASan harness drives (a 30B under the sanitizer prefills for
hours); the property being measured — cells, not bytes — does not depend on the model, and the file column
beside it is the 8.2-242.9 ms that same handoff costs at those prompt lengths on 30B-A3B.

The provider's own side of that handoff is **40.6 / 78.7 / 150.4 ms** to map and first-touch 648 MiB / 1.1 GiB
/ 2.8 GiB of region — a page fault per page it writes, not a copy, and inflated by the sanitizer; an
in-process run of the same adoption step measured 0.048-0.258 ms at 256-2 048 cells. The gate for this target
is text identity, not a tolerance: greedy text identical to `--device hrx` on every arm.

Two properties that make it usable rather than a demo: a decoder that refuses to export now falls back to the
state-file route for that request (engine#1203) instead of losing the handoff, and a decoder that *cannot* export (any backend but `ggml-hrx`:
the CPU, for instance) starts normally and warns once instead of dying at load (fork#212). `ONEBIT_KV_SHARE`
is read as "set and non-empty" on both sides: `=0` still enables the route, an unset variable is the opt-out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant