interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

Remote worker runs a real job: tokenizing text with our own tokenizer (cut 2)

closed efae1573bd9c59e9 #663 · opened 2026-10-18 17:55 UTC · closed 2026-10-29 19:00 UTC

Imported from GitHub aien-dev/aien-sovereign-core-mv#663, by drakestapleton

Base 3606d0411991d65304e17124343e52b669e9bb82 · Head 24bc83cc14f4fc5f53f6f17d1a356aca7f6060f9

drakestapleton wrote on 2026-10-18 17:55 UTC

What this adds

Cut 2 of #637: a useful job for the remote worker, plus input files that travel by digest.

  • aien-bitnet-tokenizer: our BitNet BPE moved out of aien-inference-abi into its own crate so a CPU-only worker can build it without the GPU stack. aien-inference-abi re-exports it as bitnet_tokenizer, so existing paths are unchanged.
  • tokenize_batch (kind 3): the 66-byte request names tokenizer.json and a corpus by sha256. The worker checks file sizes against admission before reading, reads both from its blob store, checks each digest, tokenizes every line across threads, and answers with a digest over every line's ids. The Spark recomputes from its own copies and also decodes every line back to its text.
  • Refusals: a file the worker does not hold is MISSING_INPUT; one whose bytes do not match its name is INPUT_DIGEST_MISMATCH. Both are refused before any task starts. A file that matches its digest but cannot be used fails as INVALID_INPUT:<why>.
  • put-blob stores a file under its sha256. It needs no lock, so it works while a worker is serving.

Evidence

Spark to MacBook Air M2, our tokenizer over aien-architecture docs at 6142a352 (196 files, 3,065,803 bytes, 40,137 lines): RESULTS.md

RunOutcome
tokenize, BOS onVERIFIED, oracle matched, 818,046 tokens, all 40,137 lines round trip; M2 claimed 215.370 ms, round trip 330.033 ms
exact retrystored receipt replayed
corpus the worker lacksMISSING_INPUT, no task
BOS offVERIFIED, 777,909 tokens (one BOS fewer per line)
stored file altered after put-blobINPUT_DIGEST_MISMATCH, no task

The Spark running the same code locally took 286.643 to 380.627 ms (3 runs) at load average 18. The M2's load was about 2.9, so these are not clean benchmarks. Peak RSS was 90,964 KiB against an admission estimate of 169,897,592 bytes.

Tests: cargo test -p aien-hetjob 23/23 on the Spark and on the M2, with frozen tokenize golden digests. cargo test -p aien-bitnet-tokenizer 4/4 and bitnet_tokenizer_real (ignored test, real checkpoint) both pass. Clippy is clean, fmt is clean, and crumbs verify. Two mutation checks, one skipping the blob digest check and one skipping the blob size admission, each turn a test red.

Not run: energy, the iMac (no hosted OS), and a check cheaper than full recompute.

Stacked on #662 (cut 1). Refs #637

🤖 Generated with Claude Code

drakestapleton wrote on 2026-10-29 19:00 UTC

Closing in org cleanup (Drake, 2026-10-29): abandoned; no activity in 11 days, base PR #662 conflicting, failing verification checks. Reopen if still needed.

Apply it

git checkout -b patch-efae1573bd9c59e9 3606d0411991d65304e17124343e52b669e9bb82
curl -fsSL https://interplane.io/drakestapleton/aien-sovereign-core-mv/patches/efae1573bd9c59e9.patch | git am

Raw patch (mbox) · Diff

Provenance

This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record:

github-import 1
aien-dev/aien-sovereign-core-mv
663
24bc83cc14f4fc5f53f6f17d1a356aca7f6060f9
{"kind":"github-import","owner":"aien-dev","repo":"aien-sovereign-core-mv","number":663,"url":"https://github.com/aien-dev/aien-sovereign-core-mv/pull/663","export_sha256":"d815604dc795b494a931d4c9d256159461266bed51d6da460421ed1d94dab90f","imported_utc":"2026-11-18T16:35:49Z"}

Changes

diff --git a/.crumb b/.crumb
index c93eed67..01b2075d 100644
--- a/.crumb
+++ b/.crumb
@@ -119,14 +119,14 @@
         }
       ],
       "children_root": "sha256:b85c8810abe85be616a42d2802e5637c38014f05e3c06d23705fef6ea5a766f2",
-      "compiled_at": "2026-10-18T18:17:57Z",
+      "compiled_at": "2026-10-18T18:25:39Z",
       "compiler": "crumb-compile/1",
-      "digest": "sha256:c4260b8cc00d572edfa8cc7e5506892a42300ce06c3495ba32b1b072cdf61371",
-      "evidence_files": 1592,
-      "evidence_root": "sha256:dd834f70bfdb3f67de9ed0bfb206f2d496e51c0b4e2f4e3afd29410ac6d872f1",
-      "files": 5917,
-      "generated_at_commit": "8614d32bf2ae8e068e0ae0f596fa25c28c1a63df",
-      "source_tree": "sha256:9880b5bd612e0bf4511c8a7187efffbb88693eff9fa8fea9a89553792675c709"
+      "digest": "sha256:0a793bc0c0509b0594f30d985677bc1d0860e07ff3a5c463a7c23d56a2e8856c",
+      "evidence_files": 1599,
+      "evidence_root": "sha256:08fcbb44e1877bbbf5cf07b1a3db391912e399956afb4748143543fdb7498101",
+      "files": 5927,
+      "generated_at_commit": "6b51783897c7a329d540547818572f6d8d991c1e",
+      "source_tree": "sha256:d06eb00b5bd849d2d4314a9c5a98e761057bbb527d43977285cff9f718065829"
     }
   },
   "history": [],
diff --git a/Cargo.lock b/Cargo.lock
index 697d4a27..3449425f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -73,6 +73,14 @@ dependencies = [
  "tempfile",
 ]
 
+[[package]]
+name = "aien-bitnet-tokenizer"
+version = "0.1.0"
+dependencies = [
+ "regex-syntax",
+ "serde_json",
+]
+
 [[package]]
 name = "aien-campaign-verifier"
 version = "0.1.0"
@@ -171,6 +179,7 @@ dependencies = [
 name = "aien-hetjob"
 version = "0.1.0"
 dependencies = [
+ "aien-bitnet-tokenizer",
  "aien-pi-spark-task",
  "aien-test",
  "ed25519-dalek",
@@ -184,6 +193,7 @@ name = "aien-inference-abi"
 version = "0.1.0"
 dependencies = [
  "aien-abi-core",
+ "aien-bitnet-tokenizer",
  "aien-kv-cache",
  "aien-omega-bf16",
  "aien-omega-dattn",
@@ -197,7 +207,6 @@ dependencies = [
  "async-trait",
  "parking_lot",
  "rayon",
- "regex-syntax",
  "serde",
  "serde_json",
  "sha2 0.10.9",
diff --git a/Cargo.toml b/Cargo.toml
index ed97aea0..708dad00 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,6 +22,7 @@ members = [
     "crates/spark-aegis",
     "crates/aien-inference-abi",
     "crates/aien-kv-cache",
+    "crates/aien-bitnet-tokenizer",
     "crates/aien-hetjob",
     "crates/aien-kv-store",
     "crates/aien-scheduler",
diff --git a/crates/aien-bitnet-tokenizer/Cargo.toml b/crates/aien-bitnet-tokenizer/Cargo.toml
new file mode 100644
index 00000000..c3ba9a2b
--- /dev/null
+++ b/crates/aien-bitnet-tokenizer/Cargo.toml
@@ -0,0 +1,11 @@
+[package]
+name = "aien-bitnet-tokenizer"
+version = "0.1.0"
+edition = "2021"
+authors = ["Drake Stapleton <aien@aienos.com>"]
+description = "Our own LLaMA-3 byte-level BPE for BitNet b1.58 2B-4T, read from tokenizer.json, no tokenizer library"
+license.workspace = true
+
+[dependencies]
+regex-syntax = "0.8"
+serde_json = "1.0"
diff --git a/crates/aien-bitnet-tokenizer/README.md b/crates/aien-bitnet-tokenizer/README.md
new file mode 100644
index 00000000..6d4d62b2
--- /dev/null
+++ b/crates/aien-bitnet-tokenizer/README.md
@@ -0,0 +1,7 @@
+# aien-bitnet-tokenizer
+
+Our own tokenizer for BitNet b1.58 2B-4T: the LLaMA-3 byte-level BPE read from the checkpoint's `tokenizer.json`, with no tokenizer library in the path. Special tokens are cut out first, a hand-written scanner follows the LLaMA-3 split pattern exactly (Unicode tables from `regex-syntax`, no regex engine runs), then BPE merges by rank. Any `tokenizer.json` setting it does not implement is refused by name.
+
+It lives in its own crate so a CPU-only machine can tokenize without building the GPU stack: `aien-hetjob` runs it on remote workers (the `tokenize_batch` job, aien-sovereign-core#637). `aien-inference-abi` re-exports it as `aien_inference_abi::bitnet_tokenizer`, so existing paths are unchanged.
+
+Tests: `cargo test -p aien-bitnet-tokenizer` (split pattern, byte alphabet, toy merges, refusals). Against the real checkpoint: `BITNET_DIR=~/models/BitNet-b1.58-2B-4T-bf16 cargo test -p aien-inference-abi --test bitnet_tokenizer_real -- --ignored` (acceptance id lists and round trips). On real data: 40,137 lines of our architecture docs, every line decodes back to itself, same ids on the Spark (aarch64 Linux) and an M2 (aarch64 macOS), see `crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/`.
diff --git a/crates/aien-inference-abi/src/bitnet_tokenizer.rs b/crates/aien-bitnet-tokenizer/src/lib.rs
similarity index 100%
rename from crates/aien-inference-abi/src/bitnet_tokenizer.rs
rename to crates/aien-bitnet-tokenizer/src/lib.rs
diff --git a/crates/aien-hetjob/Cargo.toml b/crates/aien-hetjob/Cargo.toml
index 0f9cc1d8..61417315 100644
--- a/crates/aien-hetjob/Cargo.toml
+++ b/crates/aien-hetjob/Cargo.toml
@@ -9,6 +9,8 @@ description = "Allowlisted, integer-exact CPU jobs dispatched over PST1 to a hos
 # PST1 header reader and writer, pinned to the aien-protocols-mv main commit
 # that merged #37.
 aien-pi-spark-task = { git = "https://github.com/aien-dev/aien-protocols", rev = "81b7d75f340a75ad468a241d152315fb5ef7c1a6" }
+# Our own BPE for the tokenize_batch kind (no tokenizer library).
+aien-bitnet-tokenizer = { path = "../aien-bitnet-tokenizer" }
 # Key files, executor fingerprints and canonical signed bytes are reused from
 # the local verification worker (ADR 0033 Decision 6); the bundle schema is not.
 aien-test = { path = "../../tools/aien-test" }
diff --git a/crates/aien-hetjob/README.md b/crates/aien-hetjob/README.md
index 1645d0e6..7064fa06 100644
--- a/crates/aien-hetjob/README.md
+++ b/crates/aien-hetjob/README.md
@@ -2,18 +2,19 @@
 
 Runs allowlisted CPU jobs on another machine and checks the answer. The Spark (coordinator) sends a job to a hosted worker (today: an M2 MacBook over SSH); the worker runs it, signs a receipt with its own pinned key and stores it; the Spark verifies the receipt and compares the result with its own recompute. Issue: aien-sovereign-core#637, parent aienix#6.
 
-Status 2026-10-18: cut 1. Shown on real hardware from the Spark to the M2: [evidence/het637-m2-20261018/RESULTS.md](evidence/het637-m2-20261018/RESULTS.md). The iMac is NOT_RUN (no hosted OS). No useful workload yet (cut 2).
+Status 2026-10-18: cut 1 and cut 2 shown on real hardware from the Spark to the M2. Cut 1 (test jobs, every refusal): [evidence/het637-m2-20261018/RESULTS.md](evidence/het637-m2-20261018/RESULTS.md). Cut 2 (a useful job: our BitNet tokenizer over our own docs, 40,137 lines, 818,046 tokens, VERIFIED): [evidence/het637-m2-tokenize-20261018/RESULTS.md](evidence/het637-m2-tokenize-20261018/RESULTS.md). The iMac is NOT_RUN (no hosted OS).
 
 ## What a worker will run
 
-Only these kinds, integer-exact so every architecture gives the same bits (frozen digests in `tests/protocol_tests.rs`):
+Only these kinds, integer-exact so every architecture gives the same bits (frozen digests in `tests/protocol_tests.rs` and `tests/tokenize_tests.rs`):
 
 | Kind | Job | Admission |
 |---|---|---|
 | `matmul_u32` | C = A x B over wrapping u32, A and B generated from a seed; result = sha256 of C | memory 4(mk + kn + mn) bytes and m*k*n multiply-adds against the limits |
 | `digest_chain` | sha256 applied N times to a 32-byte seed | N against the work limit |
+| `tokenize_batch` | every line of a corpus through our own BitNet BPE (`aien-bitnet-tokenizer`); result = sha256 over each line's ids. Both files are named by sha256 and read from the worker's blob store | each file against 64 MiB, then 16 bytes per tokenizer.json byte plus 8 per corpus byte against memory (peak RSS measured at about half of that, see the cut 2 evidence), corpus bytes against work |
 
-Anything else is refused (`DENIED_TASK`). There is no remote shell and no command line from the peer.
+Anything else is refused (`DENIED_TASK`). There is no remote shell and no command line from the peer. Input files travel by digest only: the request carries the sha256 of each file, a file the worker does not hold is `MISSING_INPUT`, one whose bytes do not match its name is `INPUT_DIGEST_MISMATCH` (both refused before a task starts), and a file that matches but cannot be used (a tokenizer.json our BPE refuses, a corpus that is not UTF-8) ends the task as `INVALID_INPUT`.
 
 ## Wire
 
@@ -33,9 +34,11 @@ PST1 (aien-protocols `specs/pi-spark-task`, crate `aien-pi-spark-task`), one mes
 # on the worker
 aien-hetjob keygen --state ~/aien-hetjob/state      # prints the public key for the Spark's roster
 aien-hetjob caps --state ~/aien-hetjob/state        # claimed platform and a local baseline
+aien-hetjob put-blob --state ~/aien-hetjob/state tokenizer.json   # store an input file by its sha256 (works while serving)
 # on the Spark
 aien-hetjob dispatch --roster roster.txt --ssh macbook-hetjob --matmul 512 512 512 637
 aien-hetjob local --matmul 512 512 512 637          # same job here, worker algorithm and oracle timed
+aien-hetjob dispatch --roster roster.txt --ssh macbook-hetjob --tokenize tokenizer.json corpus.txt --bos
 ```
 
 Exit 0 means verified; anything else prints `OUTCOME FAILED|CANCELLED|UNCERTAIN|REJECTED <reason>` and exits 1.
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/09-tokenize-bos.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/09-tokenize-bos.txt
new file mode 100644
index 00000000..666ac47f
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/09-tokenize-bos.txt
@@ -0,0 +1,21 @@
+aien-hetjob serve: Summary { completed: 1, replayed: 0, denied: 0, cancelled: 0, failed: 0, refused_frames: 0 }
+cause_id=80ec42b1c38b856fcdc6ff711f8f3b8ef9f2ef51fb1ffd32c301212093948b6f
+task_id=f73d72c6802ffb12ef4d94c5e16dac7c
+idempotence_key=483bf307f7f40d9906928bc66a79f6f5
+kind=tokenize_batch
+work_units=3065803
+oracle_lines=40137
+oracle_tokens=818046
+oracle_round_trips=40137
+round_trip_ms=330.033
+frames=6
+stale_ignored=0
+oracle_ms=674.015
+OUTCOME VERIFIED
+output_digest=b3ebc7d8cf5d5e9a25f3998141548e1a2502df2ab23523133a1c564768903357
+oracle=matched
+worker_key_fingerprint=310482aafb104bcf37f0a14c00eb38f0aacbc9ea4bc02735497c4184ac7af309
+claimed_platform=macos aarch64 cpus=8 memory_bytes=8589934592
+claimed_program_digest=a7406da86c6f107714d282564348e36912c791efaade0d59621ca238347404ce
+claimed_remote_compute_ms=215.370
+claimed_threads=4
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/10-retry-replay.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/10-retry-replay.txt
new file mode 100644
index 00000000..4094fb32
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/10-retry-replay.txt
@@ -0,0 +1,21 @@
+aien-hetjob serve: Summary { completed: 0, replayed: 1, denied: 0, cancelled: 0, failed: 0, refused_frames: 0 }
+cause_id=80ec42b1c38b856fcdc6ff711f8f3b8ef9f2ef51fb1ffd32c301212093948b6f
+task_id=f73d72c6802ffb12ef4d94c5e16dac7c
+idempotence_key=483bf307f7f40d9906928bc66a79f6f5
+kind=tokenize_batch
+work_units=3065803
+oracle_lines=40137
+oracle_tokens=818046
+oracle_round_trips=40137
+round_trip_ms=23.738
+frames=5
+stale_ignored=0
+oracle_ms=560.190
+OUTCOME VERIFIED
+output_digest=b3ebc7d8cf5d5e9a25f3998141548e1a2502df2ab23523133a1c564768903357
+oracle=matched
+worker_key_fingerprint=310482aafb104bcf37f0a14c00eb38f0aacbc9ea4bc02735497c4184ac7af309
+claimed_platform=macos aarch64 cpus=8 memory_bytes=8589934592
+claimed_program_digest=a7406da86c6f107714d282564348e36912c791efaade0d59621ca238347404ce
+claimed_remote_compute_ms=215.370
+claimed_threads=4
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/11-missing-input.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/11-missing-input.txt
new file mode 100644
index 00000000..55a789c6
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/11-missing-input.txt
@@ -0,0 +1,14 @@
+aien-hetjob serve: Summary { completed: 0, replayed: 0, denied: 1, cancelled: 0, failed: 0, refused_frames: 0 }
+cause_id=a074c97d5ad1ba9e4f5d80b52273bf0ee06c49366e76c2c5ff69632736210c19
+task_id=425f5815e619353ada4ac1e7342c6edc
+idempotence_key=fe83633674cd26c09aeb502c9bda5745
+kind=tokenize_batch
+work_units=3065838
+oracle_lines=40138
+oracle_tokens=818054
+oracle_round_trips=40138
+round_trip_ms=4.008
+frames=1
+stale_ignored=0
+oracle_ms=649.890
+OUTCOME FAILED MISSING_INPUT:0b44387321092d874a44d591e3b82567a247e7549f403a666e88d08f9c32c3d7
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/12-tokenize-no-bos.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/12-tokenize-no-bos.txt
new file mode 100644
index 00000000..629133d3
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/12-tokenize-no-bos.txt
@@ -0,0 +1,21 @@
+aien-hetjob serve: Summary { completed: 1, replayed: 0, denied: 0, cancelled: 0, failed: 0, refused_frames: 0 }
+cause_id=f8a2266e3d5924fa1486fbb106b04e4f142299e18e23fbf4ef2d41a9a7f86881
+task_id=fd60cffee6e6774845b5314ad4951265
+idempotence_key=4e0c1ab07548f9f15a1fe1634b0861c3
+kind=tokenize_batch
+work_units=3065803
+oracle_lines=40137
+oracle_tokens=777909
+oracle_round_trips=40137
+round_trip_ms=339.001
+frames=6
+stale_ignored=0
+oracle_ms=672.856
+OUTCOME VERIFIED
+output_digest=4cd7c87806c04e359ddd595870726e991d56381d0d516548ff9e0cd5f415ab8b
+oracle=matched
+worker_key_fingerprint=310482aafb104bcf37f0a14c00eb38f0aacbc9ea4bc02735497c4184ac7af309
+claimed_platform=macos aarch64 cpus=8 memory_bytes=8589934592
+claimed_program_digest=a7406da86c6f107714d282564348e36912c791efaade0d59621ca238347404ce
+claimed_remote_compute_ms=232.432
+claimed_threads=4
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/13-tampered-input.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/13-tampered-input.txt
new file mode 100644
index 00000000..68512673
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/13-tampered-input.txt
@@ -0,0 +1,14 @@
+aien-hetjob serve: Summary { completed: 0, replayed: 0, denied: 1, cancelled: 0, failed: 0, refused_frames: 0 }
+cause_id=75c99d7e1c4c7ee031ad8bbfad4dd59076ee09f4759f297509d0125d4b1a22dd
+task_id=fbac63ae7d724e931012b80e836a8628
+idempotence_key=8b4432f6e54cd8a51e10ab4e9a565566
+kind=tokenize_batch
+work_units=2780
+oracle_lines=100
+oracle_tokens=602
+oracle_round_trips=100
+round_trip_ms=41.317
+frames=1
+stale_ignored=0
+oracle_ms=205.129
+OUTCOME FAILED INPUT_DIGEST_MISMATCH:3f6bdaa23a42f7deb39b750760467ee3ad807f356bb6141a49f9ed7483b6b3af
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/RESULTS.md b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/RESULTS.md
new file mode 100644
index 00000000..289b6bf8
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/RESULTS.md
@@ -0,0 +1,40 @@
+# het637-m2-tokenize-20261018: a useful job, Spark coordinator to M2 worker
+
+Issue: aien-sovereign-core#637 cut 2 (parent aienix#6). Branch `feat/637-het-tokenize`, commit `b5ab184f` (the M2 worker was built from `git archive` of that commit). Date 2026-10-18, about 18:40Z.
+
+## The job
+
+`tokenize_batch`: tokenize every line of a corpus with our own BitNet b1.58 2B-4T BPE (`crates/aien-bitnet-tokenizer`, no tokenizer library). The request names both input files by sha256; the worker reads them from its blob store and checks each digest before use.
+
+| Input | sha256 | Size |
+|---|---|---|
+| `tokenizer.json` (BitNet b1.58 2B-4T, the digest pinned as `BITNET_2B4T_TOKENIZER_SHA256`) | `e134af98b985517b4f068e3755ae90d4e9cd2d45d328325dc503f1c6b2d06cc7` | 9,085,698 bytes |
+| corpus: every `*.md` in aien-architecture at `6142a352d3e6fe324ed757a44519e9b0142aa48d` (196 files, C-locale sorted paths, blobs concatenated) | `683ca95b94d1b5b8e214e22e50ecb9ceb0a889b3be2a28f5d8b794c90d663273` | 3,065,803 bytes, 40,137 lines |
+
+Rebuild the corpus: `git ls-tree -r --name-only 6142a352 | grep '\.md$' | LC_ALL=C sort`, then `git cat-file blob 6142a352:<path>` for each, appended in that order.
+
+Worker setup, roster and link: as in [../het637-m2-20261018/RESULTS.md](../het637-m2-20261018/RESULTS.md) (same pinned worker key, fingerprint `310482aa...af309`, same forced-command SSH key). Worker program digest (claimed): `a7406da86c6f107714d282564348e36912c791efaade0d59621ca238347404ce`.
+
+Tests: `cargo test -p aien-hetjob` 23/23 on the Spark (debug) and 23/23 on the M2 (release), including the frozen tokenize digests, so both machines produce the same token ids.
+
+## Runs (files in this folder)
+
+| File | Job | Outcome | Worker compute (claimed) | Round trip |
+|---|---|---|---|---|
+| 09 | tokenize, BOS on | VERIFIED, oracle matched; 40,137 lines, 818,046 tokens, every line decodes back to itself | 215.370 ms | 330.033 ms |
+| 10 | exact retry of 09 (same idempotence key, task id, cause id) | VERIFIED; the stored receipt was replayed (same compute time, nothing recomputed) | 215.370 ms | |
+| 11 | a corpus the worker does not hold (09's corpus plus one line) | FAILED `MISSING_INPUT:0b443873...`, no task created | | |
+| 12 | tokenize, BOS off | VERIFIED, oracle matched; 777,909 tokens (40,137 fewer: one BOS per line) | 232.432 ms | 339.001 ms |
+| 13 | a 100-line corpus whose stored file was changed after `put-blob` | FAILED `INPUT_DIGEST_MISMATCH:3f6bdaa2...`, no task created (the tampered file was removed afterwards) | | |
+
+The Spark running the same worker code locally (`aien-hetjob local --tokenize ... --bos --threads 4`, three runs, load average 18 from pipeline runs): 380.627, 289.224, 286.643 ms. The M2's load average was about 2.9. Neither number is a clean benchmark; both include parsing the 9 MB tokenizer.json, which is single threaded.
+
+Peak memory (Spark, `/usr/bin/time -v`, one process running the worker algorithm and the recompute): 90,964 KiB with 4 threads, 90,336 KiB with 1. The admission estimate for the same inputs is 169,897,592 bytes (16 bytes per tokenizer.json byte plus 8 per corpus byte), so admission is conservative by about 1.9x here.
+
+## What this shows and what it does not
+
+- Shown: a real workload (our tokenizer on our own documentation) dispatched from the Spark to a different physical machine, answered with a receipt signed by the pinned worker key, and matching the Spark's recompute bit for bit. Inputs travel by digest only: the 66-byte request carries no data, and a missing or altered file is refused before any task starts.
+- Self-attested: platform, program digest and timings are the M2's claims.
+- Not offload yet: the Spark recomputes every output to check it. The recompute also decodes every line back to its text, a second code path; the encoder itself is the same code on both sides, so its independence is a different machine and a different build only.
+- Provisioning: the input files reached the M2 by `scp` with the operator's normal SSH key, then `put-blob`. The forced-command job key cannot copy files.
+- Energy: not measured. iMac: NOT_RUN (no hosted OS).
diff --git a/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/roster.txt b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/roster.txt
new file mode 100644
index 00000000..ed6796a1
--- /dev/null
+++ b/crates/aien-hetjob/evidence/het637-m2-tokenize-20261018/roster.txt
@@ -0,0 +1,4 @@
+# aien-hetjob roster: worker receipt keys the Spark coordinator accepts
+# M2 MacBook Air (macOS 26.6.2, Apple M2), key made 2026-10-18 by `aien-hetjob keygen` on the M2
+# M2 SSH host key as pinned in the Spark known_hosts: ED25519 SHA256:Jdrszoi5q21Jc/l6pvFPEYbpspSPhtpRTC1uLbq31S0;
+8d5fe96bea997f8acaf79b514bd37597becddef82a0a9075ef5c5bc53ad7be2a
diff --git a/crates/aien-hetjob/src/main.rs b/crates/aien-hetjob/src/main.rs
index 14842124..166ab95d 100644
--- a/crates/aien-hetjob/src/main.rs
+++ b/crates/aien-hetjob/src/main.rs
@@ -5,15 +5,18 @@
 //!   aien-hetjob serve --state DIR [LIMITS]         serve PST1 on stdin/stdout until the peer closes
 //!   aien-hetjob dispatch --roster FILE (--ssh HOST [--remote CMD] | --local-worker DIR) JOB [--deadline-s N] [--no-oracle] [--idem HEX --task HEX --cause HEX to retry]
 //!   aien-hetjob local JOB [--threads N]            run the worker's algorithm and the oracle here, timed
+//!   aien-hetjob put-blob --state DIR FILE          copy an input file into a worker's blob store, print its sha256
 //!
-//! JOB is `--matmul M K N SEED` or `--chain ROUNDS SEED_HEX64`.
+//! JOB is `--matmul M K N SEED`, `--chain ROUNDS SEED_HEX64` or
+//! `--tokenize TOKENIZER_JSON CORPUS [--bos]` (the worker must hold both files
+//! in its blob store, see put-blob; the coordinator reads its own copies).
 //! LIMITS: --max-memory-mib N, --max-work N, --max-wall-s N, --threads N.
 //! Exit: 0 verified (or command done), 1 any other outcome, 2 usage error.
 
 use aien_hetjob::coordinator::{self, Job, OracleCheck, Outcome, Policy};
 use aien_hetjob::receipt::Receipt;
-use aien_hetjob::store::Store;
-use aien_hetjob::task::{self, Control, Limits, TaskSpec};
+use aien_hetjob::store::{self, Store};
+use aien_hetjob::task::{self, Control, Inputs, Limits, TaskSpec};
 use aien_hetjob::worker::Worker;
 use aien_hetjob::{host, wire};
 use aien_test::bundle::{fingerprint, hex_decode, hex_encode, keygen, load_signing_key};
@@ -72,7 +75,25 @@ impl Args {
     }
 }
 
-fn job_spec(a: &mut Args) -> Result<TaskSpec, String> {
+fn job_spec(a: &mut Args) -> Result<(TaskSpec, Inputs), String> {
+    if let Some(v) = a.values("--tokenize", 2)? {
+        let bos = a.flag("--bos");
+        let read = |p: &str| std::fs::read(p).map_err(|e| format!("--tokenize: {p}: {e}"));
+        let inputs = Inputs {
+            tokenizer: read(&v[0])?,
+            corpus: read(&v[1])?,
+        };
+        let spec = TaskSpec::TokenizeBatch {
+            tokenizer: Sha256::digest(&inputs.tokenizer).into(),
+            corpus: Sha256::digest(&inputs.corpus).into(),
+            bos,
+        };
+        return Ok((spec, inputs));
+    }
+    generated_spec(a).map(|s| (s, Inputs::default()))
+}
+
+fn generated_spec(a: &mut Args) -> Result<TaskSpec, String> {
     if let Some(v) = a.values("--matmul", 4)? {
         let p = |i: usize| {
             v[i].parse::<u64>()
@@ -97,7 +118,10 @@ fn job_spec(a: &mut Args) -> Result<TaskSpec, String> {
             .ok_or("--chain: seed must be 64 hex digits")?;
         return Ok(TaskSpec::DigestChain { rounds, seed });
     }
-    Err("a job is required: --matmul M K N SEED or --chain ROUNDS SEED_HEX64".to_string())
+    Err(
+        "a job is required: --matmul M K N SEED, --chain ROUNDS SEED_HEX64 or --tokenize TOKENIZER CORPUS"
+            .to_string(),
+    )
 }
 
 fn limits(a: &mut Args) -> Result<Limits, String> {
@@ -142,7 +166,7 @@ fn ms(d: Duration) -> String {
     format!("{:.3}", d.as_secs_f64() * 1e3)
 }
 
-fn time_local(spec: &TaskSpec, threads: usize) -> ([u8; 32], Duration) {
+fn time_local(spec: &TaskSpec, inputs: &Inputs, threads: usize) -> ([u8; 32], Duration) {
     let cancel = AtomicBool::new(false);
     let t0 = Instant::now();
     let ctl = Control {
@@ -150,7 +174,7 @@ fn time_local(spec: &TaskSpec, threads: usize) -> ([u8; 32], Duration) {
         deadline: t0 + Duration::from_secs(3600),
         threads,
     };
-    let d = task::run(spec, &ctl).expect("local run is never cancelled");
+    let d = task::run(spec, inputs, &ctl).expect("local run: not cancelled, inputs usable");
     (d, t0.elapsed())
 }
 
@@ -200,7 +224,7 @@ fn run(cmd: &str, a: &mut Args) -> Result<ExitCode, String> {
                 hex_encode(&p.program_digest)
             );
             println!(
-                "claimed_version={}\nkinds=matmul_u32,digest_chain",
+                "claimed_version={}\nkinds=matmul_u32,digest_chain,tokenize_batch",
                 p.version
             );
             let base = TaskSpec::MatmulU32 {
@@ -210,7 +234,7 @@ fn run(cmd: &str, a: &mut Args) -> Result<ExitCode, String> {
                 seed: 1,
             };
             for t in [1usize, Limits::default().max_threads] {
-                let (_, d) = time_local(&base, t);
+                let (_, d) = time_local(&base, &Inputs::default(), t);
                 println!("baseline_matmul_256_threads_{t}_ms={}", ms(d));
             }
             Ok(ExitCode::SUCCESS)
@@ -238,21 +262,30 @@ fn run(cmd: &str, a: &mut Args) -> Result<ExitCode, String> {
             Ok(ExitCode::SUCCESS)
         }
         "local" => {
-            let spec = job_spec(a).map_err(u)?;
+            let (spec, inputs) = job_spec(a).map_err(u)?;
             let threads = a
                 .num("--threads")
                 .map_err(u)?
                 .unwrap_or(Limits::default().max_threads);
             a.done().map_err(u)?;
-            let (d, t) = time_local(&spec, threads);
+            let sizes = [inputs.tokenizer.len() as u64, inputs.corpus.len() as u64];
+            let (d, t) = time_local(&spec, &inputs, threads);
             let t0 = Instant::now();
-            let o = task::oracle(&spec);
+            let o = task::oracle(&spec, &inputs)?;
             let to = t0.elapsed();
             println!(
-                "kind={}\nwork_units={}",
+                "kind={}\nwork_units={}\nadmission_memory_bytes={}",
                 spec.kind_name(),
-                spec.work_units()
+                spec.work_units(&sizes),
+                spec.memory_bytes(&sizes)
             );
+            if let TaskSpec::TokenizeBatch { .. } = spec {
+                let s = task::tokenize_summary(&spec, &inputs)?;
+                println!(
+                    "lines={}\ntokens={}\nround_trips={}",
+                    s.lines, s.tokens, s.round_trips
+                );
+            }
             println!(
                 "worker_algorithm_digest={}\nworker_algorithm_ms={}\nthreads={threads}",
                 hex_encode(&d),
@@ -270,6 +303,15 @@ fn run(cmd: &str, a: &mut Args) -> Result<ExitCode, String> {
                 ExitCode::from(1)
             })
         }
+        "put-blob" => {
+            let state = PathBuf::from(a.one("--state").map_err(u)?.ok_or("usage:--state DIR")?);
+            let file = a.0.pop().ok_or("usage:put-blob --state DIR FILE")?;
+            a.done().map_err(u)?;
+            let bytes = std::fs::read(&file).map_err(|e| format!("{file}: {e}"))?;
+            let d = store::put_blob(&state, &bytes).map_err(|e| e.to_string())?;
+            println!("{}  {} bytes", hex_encode(&d), bytes.len());
+            Ok(ExitCode::SUCCESS)
+        }
         "dispatch" => dispatch(a),
         other => Err(format!("usage:unknown command {other}")),
     }
@@ -309,7 +351,7 @@ fn dispatch(a: &mut Args) -> Result<ExitCode, String> {
             .ok_or("usage:--cause must be 64 hex digits")?,
         None => random().map_err(|e| e.to_string())?,
     };
-    let spec = job_spec(a).map_err(u)?;
+    let (spec, inputs) = job_spec(a).map_err(u)?;
     a.done().map_err(u)?;
 
     let mut child = match (&ssh, &local_worker) {
@@ -348,11 +390,18 @@ fn dispatch(a: &mut Args) -> Result<ExitCode, String> {
         task_id,
         idempotence_key: idem,
     };
+    let mut summary = None;
     let (oracle, oracle_time) = if no_oracle {
         (None, Duration::ZERO)
     } else {
         let t0 = Instant::now();
-        let o = task::oracle(&spec);
+        let o = if let TaskSpec::TokenizeBatch { .. } = spec {
+            let s = task::tokenize_summary(&spec, &inputs)?;
+            summary = Some(s);
+            s.digest
+        } else {
+            task::oracle(&spec, &inputs)?
+        };
         (Some(o), t0.elapsed())
     };
     let policy = Policy {
@@ -377,11 +426,18 @@ fn dispatch(a: &mut Args) -> Result<ExitCode, String> {
         hex_encode(&ids.task_id),
         hex_encode(&ids.idempotence_key)
     );
+    let sizes = [inputs.tokenizer.len() as u64, inputs.corpus.len() as u64];
     println!(
         "kind={}\nwork_units={}",
         spec.kind_name(),
-        spec.work_units()
+        spec.work_units(&sizes)
     );
+    if let Some(s) = summary {
+        println!(
+            "oracle_lines={}\noracle_tokens={}\noracle_round_trips={}",
+            s.lines, s.tokens, s.round_trips
+        );
+    }
     println!(
         "round_trip_ms={}\nframes={}\nstale_ignored={}",
         ms(stats.round_trip),
diff --git a/crates/aien-hetjob/src/store.rs b/crates/aien-hetjob/src/store.rs
index 7883a7b4..2540fb3e 100644
--- a/crates/aien-hetjob/src/store.rs
+++ b/crates/aien-hetjob/src/store.rs
@@ -9,6 +9,7 @@
 use crate::receipt::{Receipt, ReceiptError};
 use aien_test::bundle::hex_encode;
 use ed25519_dalek::VerifyingKey;
+use sha2::{Digest, Sha256};
 use std::fs::{self, File, OpenOptions};
 use std::io::{self, Write};
 use std::os::unix::io::AsRawFd;
@@ -57,6 +58,10 @@ impl Store {
         })
     }
 
+    pub fn dir(&self) -> &Path {
+        &self.dir
+    }
+
     pub fn key_path(&self) -> PathBuf {
         self.dir.join(KEY_FILE)
     }
@@ -108,3 +113,74 @@ impl Store {
         File::open(self.dir.join(RESULTS))?.sync_all()
     }
 }
+
+const BLOBS: &str = "blobs";
+
+/// Where the input file with this sha256 lives under a state folder. Input
+/// files are content addressed: the name is the digest of the bytes.
+pub fn blob_path(state: &Path, digest: &[u8; 32]) -> PathBuf {
+    state.join(BLOBS).join(hex_encode(digest))
+}
+
+/// Copy bytes into the state folder's blob store and return their sha256.
+/// Needs no lock (the name is the content, written to a temporary file and
+/// renamed), so it works while a worker serves the same folder.
+pub fn put_blob(state: &Path, bytes: &[u8]) -> io::Result<[u8; 32]> {
+    let digest: [u8; 32] = Sha256::digest(bytes).into();
+    let path = blob_path(state, &digest);
+    if path.is_file() {
+        return Ok(digest);
+    }
+    fs::create_dir_all(state.join(BLOBS))?;
+    let tmp = path.with_extension(format!("tmp{}", std::process::id()));
+    {
+        let mut f = File::create(&tmp)?;
+        f.write_all(bytes)?;
+        f.sync_all()?;
+    }
+    fs::rename(&tmp, &path)?;
+    File::open(state.join(BLOBS))?.sync_all()?;
+    Ok(digest)
+}
+
+/// Why an input file could not be used.
+#[derive(Debug)]
+pub enum BlobError {
+    Missing,
+    /// The file's bytes do not hash to its name.
+    DigestMismatch,
+    Io(io::Error),
+}
+
+impl BlobError {
+    pub fn code(&self, digest: &[u8; 32]) -> String {
+        let d = hex_encode(digest);
+        match self {
+            BlobError::Missing => format!("MISSING_INPUT:{d}"),
+            BlobError::DigestMismatch => format!("INPUT_DIGEST_MISMATCH:{d}"),
+            BlobError::Io(e) => format!("INPUT_IO:{d}:{e}"),
+        }
+    }
+}
+
+/// Size of a stored input file, for admission before it is read.
+pub fn blob_size(state: &Path, digest: &[u8; 32]) -> Result<u64, BlobError> {
+    match fs::metadata(blob_path(state, digest)) {
+        Ok(m) => Ok(m.len()),
+        Err(e) if e.kind() == io::ErrorKind::NotFound => Err(BlobError::Missing),
+        Err(e) => Err(BlobError::Io(e)),
+    }
+}
+
+/// Read a stored input file and check its bytes against its digest.
+pub fn load_blob(state: &Path, digest: &[u8; 32]) -> Result<Vec<u8>, BlobError> {
+    let bytes = match fs::read(blob_path(state, digest)) {
+        Ok(b) => b,
+        Err(e) if e.kind() == io::ErrorKind::NotFound => return Err(BlobError::Missing),
+        Err(e) => return Err(BlobError::Io(e)),
+    };
+    if <[u8; 32]>::from(Sha256::digest(&bytes)) != *digest {
+        return Err(BlobError::DigestMismatch);
+    }
+    Ok(bytes)
+}
diff --git a/crates/aien-hetjob/src/task.rs b/crates/aien-hetjob/src/task.rs
index 78a00bce..7923e69a 100644
--- a/crates/aien-hetjob/src/task.rs
+++ b/crates/aien-hetjob/src/task.rs
@@ -2,10 +2,11 @@
 //! admission arithmetic, the worker's computation and the coordinator's
 //! independent recompute.
 //!
-//! Every kind is integer-exact (wrapping u32 arithmetic, SHA-256), so an
-//! x86_64 and an aarch64 machine must produce the same digest bit for bit.
-//! There is no floating point anywhere in this file.
+//! Every kind is integer-exact (wrapping u32 arithmetic, SHA-256, BPE token
+//! ids), so an x86_64 and an aarch64 machine must produce the same digest bit
+//! for bit. There is no floating point anywhere in this file.
 
+use aien_bitnet_tokenizer::BitNetTokenizer;
 use sha2::{Digest, Sha256};
 use std::sync::atomic::{AtomicBool, Ordering};
 use std::time::{Duration, Instant};
@@ -16,10 +17,22 @@ pub const KIND_MATMUL_U32: u8 = 1;
 /// SHA-256 applied `rounds` times to a 32-byte seed. Payload: kind,
 /// rounds (u32 BE), seed (32 bytes).
 pub const KIND_DIGEST_CHAIN: u8 = 2;
+/// Tokenize every line of a corpus with our own BitNet BPE. Payload: kind,
+/// tokenizer.json sha256 (32), corpus sha256 (32), flags (bit 0: prepend
+/// BOS). Both files are read by digest from the worker's blob folder.
+pub const KIND_TOKENIZE_BATCH: u8 = 3;
 
 const MATMUL_LEN: usize = 1 + 2 + 2 + 2 + 8;
 const CHAIN_LEN: usize = 1 + 4 + 32;
+const TOKENIZE_LEN: usize = 1 + 32 + 32 + 1;
 const MATMUL_DOMAIN: &[u8] = b"AIEN-HETJOB-MATMUL-U32-V1";
+const TOKENIZE_DOMAIN: &[u8] = b"AIEN-HETJOB-TOKENIZE-BPE-V1";
+
+/// Admission estimate for tokenize_batch, in bytes per input byte: the parsed
+/// vocabulary and merge table per tokenizer.json byte, and the token ids and
+/// line index per corpus byte. Calibrated from peak RSS (crate README).
+const TOKENIZER_BYTES_PER_BYTE: u64 = 16;
+const CORPUS_BYTES_PER_BYTE: u64 = 8;
 
 /// How often (in inner work items) the worker looks at the cancel flag and
 /// the deadline.
@@ -28,8 +41,39 @@ const CHECK_EVERY: u32 = 4096;
 /// One allowlisted job.
 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
 pub enum TaskSpec {
-    MatmulU32 { m: u16, k: u16, n: u16, seed: u64 },
-    DigestChain { rounds: u32, seed: [u8; 32] },
+    MatmulU32 {
+        m: u16,
+        k: u16,
+        n: u16,
+        seed: u64,
+    },
+    DigestChain {
+        rounds: u32,
+        seed: [u8; 32],
+    },
+    TokenizeBatch {
+        tokenizer: [u8; 32],
+        corpus: [u8; 32],
+        bos: bool,
+    },
+}
+
+/// The files a job reads, already checked against the digests in its
+/// request (empty for the kinds that generate their own inputs).
+#[derive(Debug, Clone, Default)]
+pub struct Inputs {
+    pub tokenizer: Vec<u8>,
+    pub corpus: Vec<u8>,
+}
+
+/// What a tokenize_batch run produced, from the coordinator's recompute.
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub struct TokenizeSummary {
+    pub lines: u64,
+    pub tokens: u64,
+    /// Lines whose ids decode back to exactly the line (a second code path).
+    pub round_trips: u64,
+    pub digest: [u8; 32],
 }
 
 /// Why a request payload is not an allowlisted job.
@@ -41,6 +85,8 @@ pub enum SpecError {
     UnknownKind(u8),
     /// The payload length does not match the kind.
     BadLength,
+    /// A flags byte with bits this version does not define.
+    BadFlags,
 }
 
 /// Why admission refused a well-formed job.
@@ -77,6 +123,8 @@ pub struct Limits {
     pub max_work_units: u64,
     pub max_wall: Duration,
     pub max_threads: usize,
+    /// Largest single input file a job may name.
+    pub max_blob_bytes: u64,
 }
 
 impl Default for Limits {
@@ -86,6 +134,7 @@ impl Default for Limits {
             max_work_units: 1 << 34,
             max_wall: Duration::from_secs(120),
             max_threads: 4,
+            max_blob_bytes: 64 << 20,
         }
     }
 }
@@ -95,6 +144,9 @@ impl Default for Limits {
 pub enum Abort {
     Cancelled,
     Timeout,
+    /// An input file passed its digest check but is not usable (for example a
+    /// tokenizer.json our BPE refuses, or a corpus that is not UTF-8).
+    Invalid(&'static str),
 }
 
 /// What the worker's computation may look at while it runs.
@@ -136,6 +188,18 @@ impl TaskSpec {
                 v.extend_from_slice(&seed);
                 v
             }
+            TaskSpec::TokenizeBatch {
+                tokenizer,
+                corpus,
+                bos,
+            } => {
+                let mut v = Vec::with_capacity(TOKENIZE_LEN);
+                v.push(KIND_TOKENIZE_BATCH);
+                v.extend_from_slice(&tokenizer);
+                v.extend_from_slice(&corpus);
+                v.push(u8::from(bos));
+                v
+            }
         }
     }
 
@@ -167,6 +231,24 @@ impl TaskSpec {
                     seed,
                 })
             }
+            KIND_TOKENIZE_BATCH => {
+                if b.len() != TOKENIZE_LEN {
+                    return Err(SpecError::BadLength);
+                }
+                let flags = b[65];
+                if flags > 1 {
+                    return Err(SpecError::BadFlags);
+                }
+                let mut tokenizer = [0u8; 32];
+                let mut corpus = [0u8; 32];
+                tokenizer.copy_from_slice(&b[1..33]);
+                corpus.copy_from_slice(&b[33..65]);
+                Ok(TaskSpec::TokenizeBatch {
+                    tokenizer,
+                    corpus,
+                    bos: flags == 1,
+                })
+            }
             other => Err(SpecError::UnknownKind(other)),
         }
     }
@@ -175,42 +257,79 @@ impl TaskSpec {
         match self {
             TaskSpec::MatmulU32 { .. } => "matmul_u32",
             TaskSpec::DigestChain { .. } => "digest_chain",
+            TaskSpec::TokenizeBatch { .. } => "tokenize_batch",
+        }
+    }
+
+    /// Digests of the files this job reads, in `Inputs` order.
+    pub fn input_files(&self) -> Vec<[u8; 32]> {
+        match *self {
+            TaskSpec::TokenizeBatch {
+                tokenizer, corpus, ..
+            } => vec![tokenizer, corpus],
+            _ => Vec::new(),
         }
     }
 
-    /// Bytes the worker allocates for this job: A, B and C for the matrix
-    /// product, nothing that scales for the digest chain.
-    pub fn memory_bytes(&self) -> u64 {
+    /// Bytes the worker allocates for this job, given the sizes of its input
+    /// files (`input_files` order): A, B and C for the matrix product,
+    /// nothing that scales for the digest chain, the estimate above for
+    /// tokenize_batch.
+    pub fn memory_bytes(&self, sizes: &[u64]) -> u64 {
         match *self {
             TaskSpec::MatmulU32 { m, k, n, .. } => {
                 let (m, k, n) = (u64::from(m), u64::from(k), u64::from(n));
                 4 * (m * k + k * n + m * n)
             }
             TaskSpec::DigestChain { .. } => 0,
+            TaskSpec::TokenizeBatch { .. } => {
+                let (t, c) = (size(sizes, 0), size(sizes, 1));
+                t.saturating_mul(TOKENIZER_BYTES_PER_BYTE)
+                    .saturating_add(c.saturating_mul(CORPUS_BYTES_PER_BYTE))
+            }
         }
     }
 
-    /// Multiply-adds for the matrix product, hash rounds for the chain.
-    pub fn work_units(&self) -> u64 {
+    /// Multiply-adds for the matrix product, hash rounds for the chain,
+    /// corpus bytes for tokenize_batch.
+    pub fn work_units(&self, sizes: &[u64]) -> u64 {
         match *self {
             TaskSpec::MatmulU32 { m, k, n, .. } => u64::from(m) * u64::from(k) * u64::from(n),
             TaskSpec::DigestChain { rounds, .. } => u64::from(rounds),
+            TaskSpec::TokenizeBatch { .. } => size(sizes, 1),
         }
     }
 
-    /// Admission: checked before any allocation.
+    /// Admission for the request alone, before any file is opened. A kind
+    /// with input files is admitted again with their sizes (`admit_sized`).
     pub fn admit(&self, limits: &Limits) -> Result<(), Denial> {
-        if self.work_units() == 0 {
+        if self.input_files().is_empty() {
+            self.admit_sized(&[], limits)
+        } else {
+            Ok(())
+        }
+    }
+
+    /// Admission with the input file sizes: checked before any allocation
+    /// and before any input file is read.
+    pub fn admit_sized(&self, sizes: &[u64], limits: &Limits) -> Result<(), Denial> {
+        if let Some(&big) = sizes.iter().find(|&&s| s > limits.max_blob_bytes) {
+            return Err(Denial::OverMemory {
+                need: big,
+                limit: limits.max_blob_bytes,
+            });
+        }
+        if self.work_units(sizes) == 0 {
             return Err(Denial::Empty);
         }
-        let need = self.memory_bytes();
+        let need = self.memory_bytes(sizes);
         if need > limits.max_memory_bytes {
             return Err(Denial::OverMemory {
                 need,
                 limit: limits.max_memory_bytes,
             });
         }
-        let need = self.work_units();
+        let need = self.work_units(sizes);
         if need > limits.max_work_units {
             return Err(Denial::OverWork {
                 need,
@@ -221,6 +340,10 @@ impl TaskSpec {
     }
 }
 
+fn size(sizes: &[u64], i: usize) -> u64 {
+    sizes.get(i).copied().unwrap_or(0)
+}
+
 fn splitmix64(state: &mut u64) -> u64 {
     *state = state.wrapping_add(0x9E37_79B9_7F4A_7C15);
     let mut z = *state;
@@ -250,9 +373,45 @@ fn matmul_digest(m: u16, k: u16, n: u16, seed: u64, c: &[u32]) -> [u8; 32] {
     h.finalize().into()
 }
 
-/// The worker's computation: row bands across threads, i-k-j order inside a
-/// band, cancel flag and deadline checked between rows.
-pub fn run(spec: &TaskSpec, ctl: &Control) -> Result<[u8; 32], Abort> {
+fn parse_tokenizer(inputs: &Inputs) -> Result<BitNetTokenizer, Abort> {
+    let text =
+        std::str::from_utf8(&inputs.tokenizer).map_err(|_| Abort::Invalid("TOKENIZER_UTF8"))?;
+    BitNetTokenizer::from_json(text).map_err(|_| Abort::Invalid("TOKENIZER_REFUSED"))
+}
+
+/// The corpus lines: split at `\n`; a final `\n` does not start an empty line.
+fn corpus_lines(inputs: &Inputs) -> Result<Vec<&str>, Abort> {
+    let text = std::str::from_utf8(&inputs.corpus).map_err(|_| Abort::Invalid("CORPUS_UTF8"))?;
+    Ok(text.split_terminator('\n').collect())
+}
+
+/// sha256 over the domain, both file digests, the BOS flag, the line count,
+/// then each line's id count and ids, all big-endian u32.
+fn tokenize_digest(
+    tokenizer: &[u8; 32],
+    corpus: &[u8; 32],
+    bos: bool,
+    ids: &[Vec<u32>],
+) -> [u8; 32] {
+    let mut h = Sha256::new();
+    h.update(TOKENIZE_DOMAIN);
+    h.update(tokenizer);
+    h.update(corpus);
+    h.update([u8::from(bos)]);
+    h.update((ids.len() as u32).to_be_bytes());
+    for line in ids {
+        h.update((line.len() as u32).to_be_bytes());
+        for id in line {
+            h.update(id.to_be_bytes());
+        }
+    }
+    h.finalize().into()
+}
+
+/// The worker's computation. Matrix product: row bands across threads, i-k-j
+/// order inside a band, cancel flag and deadline checked between rows.
+/// Tokenize: line bands across threads, checked between lines.
+pub fn run(spec: &TaskSpec, inputs: &Inputs, ctl: &Control) -> Result<[u8; 32], Abort> {
     match *spec {
         TaskSpec::MatmulU32 { m, k, n, seed } => {
             let (mu, ku, nu) = (usize::from(m), usize::from(k), usize::from(n));
@@ -303,15 +462,93 @@ pub fn run(spec: &TaskSpec, ctl: &Control) -> Result<[u8; 32], Abort> {
             }
             Ok(h)
         }
+        TaskSpec::TokenizeBatch {
+            tokenizer,
+            corpus,
+            bos,
+        } => {
+            let tok = parse_tokenizer(inputs)?;
+            let lines = corpus_lines(inputs)?;
+            if let Some(why) = ctl.stop() {
+                return Err(why);
+            }
+            let mut ids: Vec<Vec<u32>> = vec![Vec::new(); lines.len()];
+            let threads = ctl.threads.clamp(1, lines.len().max(1));
+            let band = lines.len().div_ceil(threads).max(1);
+            let abort = std::thread::scope(|s| {
+                let mut handles = Vec::new();
+                for (out, text) in ids.chunks_mut(band).zip(lines.chunks(band)) {
+                    let tok = &tok;
+                    handles.push(s.spawn(move || {
+                        for (slot, line) in out.iter_mut().zip(text) {
+                            if let Some(why) = ctl.stop() {
+                                return Some(why);
+                            }
+                            *slot = tok.encode(line, bos);
+                        }
+                        None
+                    }));
+                }
+                handles
+                    .into_iter()
+                    .filter_map(|h| h.join().expect("tokenize band panicked"))
+                    .next()
+            });
+            match abort {
+                Some(why) => Err(why),
+                None => Ok(tokenize_digest(&tokenizer, &corpus, bos, &ids)),
+            }
+        }
     }
 }
 
+/// The coordinator's recompute for tokenize_batch: one thread, line by line,
+/// plus a decode of every line's ids back to text. The encoder is the same
+/// code as the worker's; its independence is a different machine and build.
+pub fn tokenize_summary(spec: &TaskSpec, inputs: &Inputs) -> Result<TokenizeSummary, String> {
+    let TaskSpec::TokenizeBatch {
+        tokenizer,
+        corpus,
+        bos,
+    } = *spec
+    else {
+        return Err("not a tokenize_batch job".to_string());
+    };
+    let why = |a: Abort| format!("{a:?}");
+    let tok = parse_tokenizer(inputs).map_err(why)?;
+    let lines = corpus_lines(inputs).map_err(why)?;
+    let mut ids = Vec::with_capacity(lines.len());
+    let (mut tokens, mut round_trips) = (0u64, 0u64);
+    for line in &lines {
+        let v = tok.encode(line, bos);
+        tokens += v.len() as u64;
+        let body = if bos { &v[1..] } else { &v[..] };
+        if tok.decode(body).is_ok_and(|t| t == *line) {
+            round_trips += 1;
+        }
+        ids.push(v);
+    }
+    Ok(TokenizeSummary {
+        lines: lines.len() as u64,
+        tokens,
+        round_trips,
+        digest: tokenize_digest(&tokenizer, &corpus, bos, &ids),
+    })
+}
+
 /// The coordinator's recompute. The matrix product uses a different loop
 /// order (i-j-k dot products, one thread) from the worker, so a shared bug in
 /// the blocked loop does not hide. The digest chain has only one algorithm;
 /// its independence is a different machine and a different build, nothing
-/// more.
-pub fn oracle(spec: &TaskSpec) -> [u8; 32] {
+/// more; tokenize_batch is `tokenize_summary`.
+pub fn oracle(spec: &TaskSpec, inputs: &Inputs) -> Result<[u8; 32], String> {
+    if let TaskSpec::TokenizeBatch { .. } = spec {
+        return tokenize_summary(spec, inputs).map(|s| s.digest);
+    }
+    Ok(generated_oracle(spec))
+}
+
+fn generated_oracle(spec: &TaskSpec) -> [u8; 32] {
     match *spec {
         TaskSpec::MatmulU32 { m, k, n, seed } => {
             let (mu, ku, nu) = (usize::from(m), usize::from(k), usize::from(n));
@@ -335,5 +572,6 @@ pub fn oracle(spec: &TaskSpec) -> [u8; 32] {
             }
             h
         }
+        TaskSpec::TokenizeBatch { .. } => unreachable!("tokenize_batch goes to tokenize_summary"),
     }
 }
diff --git a/crates/aien-hetjob/src/worker.rs b/crates/aien-hetjob/src/worker.rs
index f8dc355e..ceb2f3aa 100644
--- a/crates/aien-hetjob/src/worker.rs
+++ b/crates/aien-hetjob/src/worker.rs
@@ -5,12 +5,13 @@
 //! `text_chunk` messages, `receipt_reference` (SHA-256 of the receipt bytes)
 //! and `completed` (the 32-byte output digest). The receipt is stored durably
 //! before `completed` is sent. A cancel ends in `cancelled`; the deadline in
-//! `failed` with `TIMEOUT`. A request that is not admitted gets one `failed`
+//! `failed` with `TIMEOUT` (or `INVALID_INPUT:<why>` for an input file the job
+//! cannot use). A request that is not admitted gets one `failed`
 //! with ordinal 0 and creates no task.
 
 use crate::receipt::{Platform, Receipt};
-use crate::store::{Lookup, Store};
-use crate::task::{self, Abort, Control, Limits, TaskSpec};
+use crate::store::{self, Lookup, Store};
+use crate::task::{self, Abort, Control, Inputs, Limits, TaskSpec};
 use crate::wire::{self, Ids, Inbound, Msg};
 use aien_pi_spark_task as pst;
 use ed25519_dalek::SigningKey;
@@ -177,6 +178,17 @@ impl Worker {
                             sum.failed += 1;
                             send(&mut w, &job.ids, wire::T_FAILED, job.next, b"TIMEOUT")?;
                         }
+                        Err(Abort::Invalid(why)) => {
+                            sum.failed += 1;
+                            let reason = format!("INVALID_INPUT:{why}");
+                            send(
+                                &mut w,
+                                &job.ids,
+                                wire::T_FAILED,
+                                job.next,
+                                reason.as_bytes(),
+                            )?;
+                        }
                     }
                 }
             }
@@ -246,6 +258,10 @@ impl Worker {
                     Ok(Lookup::Conflict) => return deny(w, sum, &ids, "DUPLICATE_ID"),
                     Err(e) => return deny(w, sum, &ids, format!("STORE_REFUSED:{e}")),
                 }
+                let inputs = match self.load_inputs(&spec) {
+                    Ok(i) => i,
+                    Err(reason) => return deny(w, sum, &ids, reason),
+                };
                 send(w, &ids, wire::T_ACCEPTED, 0, &[])?;
                 send(w, &ids, wire::T_RUNNING, 1, &[])?;
                 let cancel = Arc::new(AtomicBool::new(false));
@@ -259,7 +275,7 @@ impl Worker {
                         deadline: t0 + limits.max_wall,
                         threads: limits.max_threads,
                     };
-                    let result = task::run(&spec, &ctl);
+                    let result = task::run(&spec, &inputs, &ctl);
                     let compute_ns = t0.elapsed().as_nanos() as u64;
                     let _ = done.send(Event::Done(Finished {
                         task_id,
@@ -280,6 +296,29 @@ impl Worker {
             }
         }
     }
+
+    /// The job's input files: sizes admitted first, then each read and
+    /// checked against its digest. Err is the denial reason.
+    fn load_inputs(&self, spec: &TaskSpec) -> Result<Inputs, String> {
+        let files = spec.input_files();
+        if files.is_empty() {
+            return Ok(Inputs::default());
+        }
+        let dir = self.store.dir();
+        let sizes = files
+            .iter()
+            .map(|d| store::blob_size(dir, d).map_err(|e| e.code(d)))
+            .collect::<Result<Vec<u64>, String>>()?;
+        spec.admit_sized(&sizes, &self.limits)
+            .map_err(|d| d.code())?;
+        let mut loaded = files
+            .iter()
+            .map(|d| store::load_blob(dir, d).map_err(|e| e.code(d)))
+            .collect::<Result<Vec<Vec<u8>>, String>>()?;
+        let corpus = loaded.pop().unwrap_or_default();
+        let tokenizer = loaded.pop().unwrap_or_default();
+        Ok(Inputs { tokenizer, corpus })
+    }
 }
 
 /// Refuse one request: a single `failed` with ordinal 0, no task created.
diff --git a/crates/aien-hetjob/tests/protocol_tests.rs b/crates/aien-hetjob/tests/protocol_tests.rs
index 7842aae1..4679cf1f 100644
--- a/crates/aien-hetjob/tests/protocol_tests.rs
+++ b/crates/aien-hetjob/tests/protocol_tests.rs
@@ -5,7 +5,7 @@
 use aien_hetjob::coordinator::{dispatch, Job, OracleCheck, Outcome, Policy, Stats};
 use aien_hetjob::receipt::{Platform, Receipt};
 use aien_hetjob::store::Store;
-use aien_hetjob::task::{self, Limits, TaskSpec};
+use aien_hetjob::task::{self, Inputs, Limits, TaskSpec};
 use aien_hetjob::wire::{self, Ids, Inbound};
 use aien_hetjob::worker::{Summary, Worker};
 use aien_pi_spark_task as pst;
@@ -61,7 +61,7 @@ fn policy(spec: &TaskSpec) -> Policy {
     Policy {
         deadline: Duration::from_secs(20),
         cancel_grace: Duration::from_secs(5),
-        oracle: Some(task::oracle(spec)),
+        oracle: Some(task::oracle(spec, &Inputs::default()).unwrap()),
     }
 }
 
@@ -123,7 +123,7 @@ fn scripted(
 
 /// The frames an honest worker sends for `spec`, signed by `k`.
 fn honest_frames(ids: &Ids, spec: &TaskSpec, k: &SigningKey) -> (Vec<Vec<u8>>, Vec<u8>, [u8; 32]) {
-    let out = task::oracle(spec);
+    let out = task::oracle(spec, &Inputs::default()).unwrap();
     let receipt = Receipt {
         task_id: ids.task_id,
         idempotence_key: ids.idempotence_key,
@@ -189,7 +189,7 @@ fn verified_matmul_and_chain_match_the_oracle() {
         match o {
             Outcome::Verified(v) => {
                 assert_eq!(v.oracle, OracleCheck::Matched);
-                assert_eq!(v.output, task::oracle(&spec));
+                assert_eq!(v.output, task::oracle(&spec, &Inputs::default()).unwrap());
                 assert_eq!(v.receipt.platform, platform());
             }
             other => panic!("{other:?}"),
@@ -241,7 +241,11 @@ fn golden_digests_are_frozen() {
         ),
     ];
     for (spec, want) in cases {
-        assert_eq!(hex(task::oracle(&spec)), want, "{spec:?}");
+        assert_eq!(
+            hex(task::oracle(&spec, &Inputs::default()).unwrap()),
+            want,
+            "{spec:?}"
+        );
     }
 }
 
@@ -267,8 +271,8 @@ fn worker_algorithm_equals_oracle_for_awkward_shapes_and_threads() {
                 threads,
             };
             assert_eq!(
-                task::run(&spec, &ctl).unwrap(),
-                task::oracle(&spec),
+                task::run(&spec, &Inputs::default(), &ctl).unwrap(),
+                task::oracle(&spec, &Inputs::default()).unwrap(),
                 "{spec:?} threads={threads}"
             );
         }
@@ -522,7 +526,12 @@ fn out_of_order_and_missing_receipt_are_rejected() {
     let (o, _) = scripted(&job, &roster, &policy(&SMALL), |i| {
         vec![
             wire::build(i, wire::T_ACCEPTED, 0, &[]),
-            wire::build(i, wire::T_COMPLETED, 1, &task::oracle(&SMALL)),
+            wire::build(
+                i,
+                wire::T_COMPLETED,
+                1,
+                &task::oracle(&SMALL, &Inputs::default()).unwrap(),
+            ),
         ]
     });
     assert_eq!(rejected(&o), "COMPLETED_WITHOUT_RECEIPT");
diff --git a/crates/aien-hetjob/tests/tokenize_tests.rs b/crates/aien-hetjob/tests/tokenize_tests.rs
new file mode 100644
index 00000000..121dd2d5
--- /dev/null
+++ b/crates/aien-hetjob/tests/tokenize_tests.rs
@@ -0,0 +1,342 @@
+//! tokenize_batch over a socket pair: a toy tokenizer.json in our BPE's
+//! format, input files by digest from the worker's blob store, and every way
+//! an input can be wrong (missing, tampered, too big, unusable).
+
+use aien_bitnet_tokenizer::LLAMA3_SPLIT_PATTERN;
+use aien_hetjob::coordinator::{dispatch, Job, OracleCheck, Outcome, Policy};
+use aien_hetjob::receipt::Platform;
+use aien_hetjob::store::{self, Store};
+use aien_hetjob::task::{self, Control, Inputs, Limits, SpecError, TaskSpec};
+use aien_hetjob::wire::Ids;
+use aien_hetjob::worker::{Summary, Worker};
+use ed25519_dalek::SigningKey;
+use sha2::{Digest, Sha256};
+use std::os::unix::net::UnixStream;
+use std::path::{Path, PathBuf};
+use std::sync::atomic::AtomicBool;
+use std::time::{Duration, Instant};
+
+fn tmpdir(tag: &str) -> PathBuf {
+    let d = std::env::temp_dir().join(format!("aien-hetjob-tok-{tag}-{}", std::process::id()));
+    let _ = std::fs::remove_dir_all(&d);
+    std::fs::create_dir_all(&d).unwrap();
+    d
+}
+
+fn key() -> SigningKey {
+    SigningKey::from_bytes(&[1; 32])
+}
+
+fn worker(dir: &Path, limits: Limits) -> Worker {
+    Worker {
+        key: key(),
+        limits,
+        store: Store::open(dir).unwrap(),
+        platform: Platform {
+            os: "testos".into(),
+            arch: "testarch".into(),
+            cpus: 2,
+            memory_bytes: 1 << 30,
+            program_digest: [7; 32],
+            version: "0.1.0".into(),
+        },
+    }
+}
+
+fn ids(n: u8) -> Ids {
+    Ids {
+        cause_id: [0xC1; 32],
+        origin_run_id: [0; 32],
+        objective_id: [0x0B; 32],
+        subject_id: [0; 32],
+        task_id: [n; 16],
+        idempotence_key: [n; 16],
+    }
+}
+
+/// GPT-2's byte alphabet: printable bytes map to themselves, the rest to
+/// U+0100 upwards in byte order.
+fn byte_alphabet() -> Vec<char> {
+    let keep =
+        |b: u32| (33..=126).contains(&b) || (161..=172).contains(&b) || (174..=255).contains(&b);
+    let mut next = 256;
+    (0..256u32)
+        .map(|b| {
+            if keep(b) {
+                char::from_u32(b).unwrap()
+            } else {
+                next += 1;
+                char::from_u32(next - 1).unwrap()
+            }
+        })
+        .collect()
+}
+
+/// A toy tokenizer.json: the 256 bytes plus "ab", "abc", "Ä ab", "bc".
+fn toy_tokenizer() -> Vec<u8> {
+    let mut vocab = serde_json::Map::new();
+    for (b, c) in byte_alphabet().iter().enumerate() {
+        vocab.insert(c.to_string(), (b as u64).into());
+    }
+    vocab.insert("ab".into(), 256.into());
+    vocab.insert("abc".into(), 257.into());
+    vocab.insert("Ä ab".into(), 258.into());
+    vocab.insert("bc".into(), 259.into());
+    let special = |id: u32, s: &str| {
+        serde_json::json!({"id": id, "content": s, "special": true, "normalized": false,
+            "lstrip": false, "rstrip": false, "single_word": false})
+    };
+    serde_json::json!({
+        "normalizer": null,
+        "pre_tokenizer": {"type": "Sequence", "pretokenizers": [
+            {"type": "Split", "pattern": {"Regex": LLAMA3_SPLIT_PATTERN}, "behavior": "Isolated", "invert": false},
+            {"type": "ByteLevel", "add_prefix_space": false, "trim_offsets": true, "use_regex": false}]},
+        "post_processor": {"type": "Sequence", "processors": [{"type": "TemplateProcessing",
+            "special_tokens": {"<|begin_of_text|>": {"ids": [260]}}}]},
+        "added_tokens": [special(260, "<|begin_of_text|>"), special(261, "<|eot_id|>")],
+        "model": {"type": "BPE", "ignore_merges": true, "byte_fallback": false, "dropout": null,
+            "continuing_subword_prefix": null, "end_of_word_suffix": null,
+            "vocab": vocab, "merges": ["b c", "a b", "ab c", "Ä  ab"]}
+    })
+    .to_string()
+    .into_bytes()
+}
+
+const CORPUS: &str =
+    "abc ab abab\n\nüber 3½ ab<|eot_id|>abc\n12345 it's  ok \t\nlast line without newline";
+
+fn inputs(corpus: &str) -> Inputs {
+    Inputs {
+        tokenizer: toy_tokenizer(),
+        corpus: corpus.as_bytes().to_vec(),
+    }
+}
+
+fn spec_of(i: &Inputs, bos: bool) -> TaskSpec {
+    TaskSpec::TokenizeBatch {
+        tokenizer: Sha256::digest(&i.tokenizer).into(),
+        corpus: Sha256::digest(&i.corpus).into(),
+        bos,
+    }
+}
+
+/// Put both input files into the worker's blob store.
+fn provision(dir: &Path, i: &Inputs) {
+    store::put_blob(dir, &i.tokenizer).unwrap();
+    store::put_blob(dir, &i.corpus).unwrap();
+}
+
+fn run_job(w: &Worker, job: &Job, oracle: Option<[u8; 32]>) -> (Outcome, Summary) {
+    let p = Policy {
+        deadline: Duration::from_secs(20),
+        cancel_grace: Duration::from_secs(5),
+        oracle,
+    };
+    let roster = [key().verifying_key()];
+    let (c, s) = UnixStream::pair().unwrap();
+    std::thread::scope(|sc| {
+        let h = sc.spawn(|| {
+            let s2 = s.try_clone().unwrap();
+            w.serve(s2, s).unwrap()
+        });
+        let r = c.try_clone().unwrap();
+        let mut wr = c;
+        let (o, _) = dispatch(r, &mut wr, job, &roster, &p).unwrap();
+        wr.shutdown(std::net::Shutdown::Both).unwrap();
+        (o, h.join().unwrap())
+    })
+}
+
+fn failed(o: &Outcome) -> String {
+    match o {
+        Outcome::Failed(s) => s.clone(),
+        other => panic!("expected Failed, got {other:?}"),
+    }
+}
+
+fn hex(b: &[u8]) -> String {
+    b.iter().map(|x| format!("{x:02x}")).collect()
+}
+
+#[test]
+fn verified_tokenize_matches_the_recompute() {
+    let dir = tmpdir("happy");
+    let i = inputs(CORPUS);
+    provision(&dir, &i);
+    let w = worker(&dir, Limits::default());
+    for (n, bos) in [(1u8, false), (2, true)] {
+        let spec = spec_of(&i, bos);
+        let s = task::tokenize_summary(&spec, &i).unwrap();
+        assert_eq!(s.lines, 5);
+        assert_eq!(s.round_trips, 5, "every line decodes back to itself");
+        let job = Job { spec, ids: ids(n) };
+        let (o, sum) = run_job(&w, &job, Some(s.digest));
+        match o {
+            Outcome::Verified(v) => {
+                assert_eq!(v.oracle, OracleCheck::Matched);
+                assert_eq!(v.output, s.digest);
+                assert_eq!(v.receipt.kind, "tokenize_batch");
+            }
+            other => panic!("{other:?}"),
+        }
+        assert_eq!(sum.completed, 1);
+    }
+}
+
+/// Frozen: any change to the encoder, the line split or the digest layout
+/// shows up here (the worker and coordinator both use these bytes).
+#[test]
+fn golden_tokenize_digests() {
+    let i = inputs(CORPUS);
+    let plain = task::tokenize_summary(&spec_of(&i, false), &i).unwrap();
+    let bos = task::tokenize_summary(&spec_of(&i, true), &i).unwrap();
+    assert_eq!(
+        (plain.tokens, hex(&plain.digest)),
+        (
+            57,
+            String::from("0c06c2e7ee01712604c5271f30cf3e37c061e21d8f97b23a74d78a25f0c686ea")
+        )
+    );
+    assert_eq!(
+        (bos.tokens, hex(&bos.digest)),
+        (
+            62,
+            String::from("81abf962cd4d3c69d4199a1e67dc7c19c9bb01fc27807116b7c32faa68188679")
+        )
+    );
+}
+
+#[test]
+fn every_thread_count_gives_the_same_digest() {
+    let i = inputs(&CORPUS.repeat(9));
+    let spec = spec_of(&i, true);
+    let want = task::tokenize_summary(&spec, &i).unwrap().digest;
+    let cancel = AtomicBool::new(false);
+    for threads in [1, 2, 3, 7, 64] {
+        let ctl = Control {
+            cancel: &cancel,
+            deadline: Instant::now() + Duration::from_secs(30),
+            threads,
+        };
+        assert_eq!(
+            task::run(&spec, &i, &ctl).unwrap(),
+            want,
+            "threads={threads}"
+        );
+    }
+}
+
+#[test]
+fn missing_and_tampered_inputs_create_no_task() {
+    let dir = tmpdir("missing");
+    let i = inputs(CORPUS);
+    let spec = spec_of(&i, false);
+    store::put_blob(&dir, &i.tokenizer).unwrap();
+    let w = worker(&dir, Limits::default());
+    let (o, sum) = run_job(&w, &Job { spec, ids: ids(1) }, None);
+    assert_eq!(
+        failed(&o),
+        format!("MISSING_INPUT:{}", hex(&Sha256::digest(&i.corpus)))
+    );
+    assert_eq!((sum.denied, sum.completed), (1, 0));
+
+    // The corpus file exists under its digest, but its bytes were changed.
+    let corpus_digest: [u8; 32] = Sha256::digest(&i.corpus).into();
+    std::fs::write(store::blob_path(&dir, &corpus_digest), b"abc tampered").unwrap();
+    let (o, sum) = run_job(&w, &Job { spec, ids: ids(2) }, None);
+    assert_eq!(
+        failed(&o),
+        format!("INPUT_DIGEST_MISMATCH:{}", hex(&corpus_digest))
+    );
+    assert_eq!(sum.denied, 1);
+}
+
+#[test]
+fn oversize_inputs_are_refused_before_reading() {
+    let dir = tmpdir("big");
+    let i = inputs(CORPUS);
+    provision(&dir, &i);
+    let small_blobs = Limits {
+        max_blob_bytes: 1024,
+        ..Limits::default()
+    };
+    let w = worker(&dir, small_blobs);
+    let (o, _) = run_job(
+        &w,
+        &Job {
+            spec: spec_of(&i, false),
+            ids: ids(1),
+        },
+        None,
+    );
+    assert!(failed(&o).starts_with("OVER_BUDGET:MEMORY need="), "{o:?}");
+
+    let little_memory = Limits {
+        max_memory_bytes: 4096,
+        ..Limits::default()
+    };
+    let dir2 = tmpdir("mem");
+    provision(&dir2, &i);
+    let w = worker(&dir2, little_memory);
+    let (o, _) = run_job(
+        &w,
+        &Job {
+            spec: spec_of(&i, false),
+            ids: ids(1),
+        },
+        None,
+    );
+    assert!(failed(&o).starts_with("OVER_BUDGET:MEMORY need="), "{o:?}");
+}
+
+#[test]
+fn unusable_inputs_fail_with_the_reason() {
+    let dir = tmpdir("invalid");
+    let w = worker(&dir, Limits::default());
+    // Valid JSON, but not a tokenizer our BPE implements.
+    let wrong = Inputs {
+        tokenizer: br#"{"normalizer": null, "model": {"type": "WordPiece"}}"#.to_vec(),
+        corpus: b"abc\n".to_vec(),
+    };
+    provision(&dir, &wrong);
+    let (o, sum) = run_job(
+        &w,
+        &Job {
+            spec: spec_of(&wrong, false),
+            ids: ids(1),
+        },
+        None,
+    );
+    assert_eq!(failed(&o), "INVALID_INPUT:TOKENIZER_REFUSED");
+    assert_eq!((sum.failed, sum.denied), (1, 0));
+
+    let not_utf8 = Inputs {
+        tokenizer: toy_tokenizer(),
+        corpus: vec![b'a', 0xFF, b'\n'],
+    };
+    provision(&dir, &not_utf8);
+    let (o, _) = run_job(
+        &w,
+        &Job {
+            spec: spec_of(&not_utf8, false),
+            ids: ids(2),
+        },
+        None,
+    );
+    assert_eq!(failed(&o), "INVALID_INPUT:CORPUS_UTF8");
+}
+
+#[test]
+fn request_payload_round_trips_and_refuses_unknown_flags() {
+    let i = inputs(CORPUS);
+    for bos in [false, true] {
+        let spec = spec_of(&i, bos);
+        let p = spec.encode();
+        assert_eq!(p.len(), 66);
+        assert_eq!(TaskSpec::decode(&p), Ok(spec));
+        let mut bad = p.clone();
+        bad[65] = 2;
+        assert_eq!(TaskSpec::decode(&bad), Err(SpecError::BadFlags));
+        assert_eq!(TaskSpec::decode(&p[..65]), Err(SpecError::BadLength));
+    }
+}
diff --git a/crates/aien-inference-abi/Cargo.toml b/crates/aien-inference-abi/Cargo.toml
index 1131a028..57aef3a9 100644
--- a/crates/aien-inference-abi/Cargo.toml
+++ b/crates/aien-inference-abi/Cargo.toml
@@ -26,7 +26,7 @@ aien-omega-pf = { path = "../aien-omega-pf" }
 aien-omega-dgraph = { path = "../aien-omega-dgraph" }
 parking_lot = "0.12"
 sha2 = "0.10"
-regex-syntax = "0.8"
+aien-bitnet-tokenizer = { path = "../aien-bitnet-tokenizer" }
 
 
 
diff --git a/crates/aien-inference-abi/src/lib.rs b/crates/aien-inference-abi/src/lib.rs
index f9c52894..c684243c 100644
--- a/crates/aien-inference-abi/src/lib.rs
+++ b/crates/aien-inference-abi/src/lib.rs
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
 pub mod backend;
 pub mod bitnet_forward;
 pub mod bitnet_omega;
-pub mod bitnet_tokenizer;
+pub use aien_bitnet_tokenizer as bitnet_tokenizer;
 pub mod capsule;
 pub mod checkpoint;
 pub mod gb10_serving;