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

branch main Branches Tags History

aien-sovereign-core-mv / docs / campaigns / dual / 2026-10-04-serve-observer-receipt.md

251 lines · 16153 bytes Raw Blame History Rendered
1# Receipt: DUAL `serve.admit_preempt` read-only observer (DUAL-3a instrumentation)
2
3Program: ARCH-0031 "DUAL, Constraint Pricing for Soft Resource Budgets", §7.3
4(decision sites observed through a read-only tap), gate DUAL-3 prerequisite
5"at least one registered decision site with a read-only tap".
6Site: `serve.admit_preempt` (DUAL_CURRENT_STATE §4), production owner
7`aien-scheduler::AienScheduler::build_scheduled_batch`.
8
9**Gate verdict: none claimed.** This receipt records instrumentation
10(DUAL-3a). `DUAL_ADVISORY_SCHEDULER` is NOT claimed PASS: no
11`DualRecommendation` is produced, no pre-registered workload set with
12recommendation-versus-actual analysis exists yet, and no prediction-quality
13claim is made. The tap changes no production decision; the evidence below is
14that it changes none.
15
16## 1. Identity
17
18| Field | Value |
19|---|---|
20| Repository | `aien-dev/aien-sovereign-core` |
21| Base commit (GitHub `main`) | `91fba8fc0f00fd09fc3e9a6137522af3ae79c4e1` |
22| Branch | `dual/serve-observer` |
23| Candidate commit | filled in §9 after the final commit |
24| Tree | clean at each recorded command (`git status --short` empty) |
25| Compiler | `rustc 1.98.1 (48a229cea 2026-09-01)`, `cargo 1.98.1 (797e8a9bc 2026-08-05)` |
26| Build config | `dev` profile for tests (as CI), `release` profile for the benchmark only |
27| Host | NVIDIA DGX Spark, GB10, aarch64, Linux 7.0.0-1019-nvidia, 20 CPUs |
28| GPU exercised | **No.** Every test and the benchmark run `MockInferenceBackend` on the host CPU. No GB10 kernel, no NVRM call, no model. |
29| Workspace path | fresh clone `~/workspace/dual/sc-observer` |
30
31## 2. What changed (code)
32
33- `crates/aien-scheduler/src/dual_observer.rs` (new): `DecisionObserver` trait
34 (`fn observe_admit_preempt(&self, &AdmitPreemptRecord)`, returns `()`), the
35 immutable `AdmitPreemptRecord` (site id, step counter, limits, KV readings at
36 entry and exit, arena active count, ranked preemption victims, every running
37 sequence examined with its verdict, every queue head examined with the exact
38 numbers compared, the chosen preempted / decode / prefill-chunk sets, the
39 batch outcome), `RecordingObserver`, `CountingObserver`.
40- `crates/aien-scheduler/src/lib.rs`: `AienScheduler.observer:
41 Option<Arc<dyn DecisionObserver>>` (default `None`),
42 `set_decision_observer`, `decision_observer_installed`;
43 `build_scheduled_batch` is now a thin wrapper around
44 `build_scheduled_batch_traced(&mut Option<AdmitPreemptTrace>)`, which is
45 the former body with `if let Some(t) = trace` inserts. No arithmetic,
46 ordering, lock, allocation or KV call of the decision moved or changed.
47- `crates/aien-scheduler/Cargo.toml`: dev-dependencies `async-trait`, `sha2`
48 (both already in `Cargo.lock`); mutant feature
49 `dual_observer_mutant_changes_decision` (off; negative control, §5).
50- Tests: `tests/dual_common/mod.rs` (deterministic workload set + canonical
51 trace), `tests/dual_decision_golden.rs`, `tests/dual_observer_parity.rs`,
52 `tests/dual_observer_overhead_bench.rs` (ignored, manual),
53 `tests/fixtures/dual_serve_admit_preempt.golden.json`.
54
55Untouched: `aien-kv-cache` (refcounts, copy-on-write, allocation failure
56paths, watermark enforcement), `aien-runtime`, `aien-abi-core`. No pressure
57or metric authorizes anything; the hook has no return value.
58
59## 3. Pre-registered workload set
60
61Thirteen scripted scenarios in `tests/dual_common/mod.rs::scenarios()`, run
62on `MockInferenceBackend` (fixed tokens, no sleep), timing fields excluded
63from every trace:
64
65| Scenario | Exercises |
66|---|---|
67| `admission_basic` | admission of four requests, run to length limit, drain |
68| `no_admission_empty_queues` | `Ok(None)` steps, nothing touched |
69| `chunked_prefill_continuation` | 300-token prompt, 64-token chunks, 100-token budget, beside a decoding sequence |
70| `preemption_watermark` | 6-block pool, watermark 3: lower priority preempted, readmitted |
71| `preemption_tie_equal_priority` | equal priorities: stable sort, first in running order is the victim |
72| `no_preemption_sufficient_pool` | same requests, 256-block pool, no victim ranked |
73| `queue_exhaustion_batch_limit` | 12 requests, batch of 4, admission stops on the batch limit each step |
74| `capacity_one_below` | 7 of 8 blocks needed: admitted |
75| `capacity_exactly_at` | 8 of 8: admitted |
76| `capacity_one_above_refused` | 9 of 8, nothing running: `KV_POOL_EXHAUSTED` error, request stays queued, nothing allocated |
77| `capacity_wait_while_running` | shortfall while something runs: waits without error |
78| `fanout_32_way` | 32 children share a prefilled parent's blocks, admitted straight into decode |
79| `fanout_500_way` | same with 500 children |
80
81Counter wrap: `step_id` is a `u64` incremented with `+=` (unchanged, would
82panic in debug at 2^64 steps); the record copies it, nothing else. Not
83exercised: no test crosses the wrap because the production code does not
84either. The record's `step_id` equals the batch's `step_id` in every test.
85
86## 4. Tests and results
87
88Commands run from the repository root on the candidate tree. Results are
89filled in §9 from the actual runs.
90
91| # | Command | Purpose |
92|---|---|---|
93| T1 | `DUAL_WRITE_GOLDEN=1 cargo test -p aien-scheduler --test dual_decision_golden decisions_match_golden` on a worktree at the base commit, with `tests/dual_common`, `tests/dual_decision_golden.rs` and the two dev-dependencies copied in | before/after: produce per-scenario sha256 of every decision on the base commit |
94| T2 | `cargo test -p aien-scheduler --test dual_decision_golden` | candidate decides identically to the base commit; workload deterministic run to run; drained scenarios hold zero KV blocks, zero tables, zero arena records, empty queues |
95| T3 | `cargo test -p aien-scheduler --test dual_observer_parity` | observer absent vs `RecordingObserver`: canonical trace bytes identical, KV accounting identical per step, one record per decision, records agree with the batches, preemption / tie / capacity / fan-out / queue-exhaustion / empty-step records carry the right facts |
96| T4 | `cargo test -p aien-scheduler --doc` | two `compile_fail` doctests: an observer cannot mutate the record or return a choice |
97| T5 | `cargo test -p aien-scheduler -p aien-kv-cache -p aien-runtime -- --test-threads=1` | existing scheduler, KV mutation / copy-on-write / incremental-blocks, runtime World lifecycle, spine, swarm, 500-branch tests |
98| T6 | `cargo clippy -p aien-scheduler --all-targets -- -D warnings`; `cargo fmt --all -- --check` | CI invariants |
99| T7 | `crumb verify .` | Crumb protocol |
100
101Sanitizers / miri: not used; the repository does not run them.
102
103## 5. Negative control
104
105Two layers.
106
107**By type.** `DecisionObserver::observe_admit_preempt(&self, record:
108&AdmitPreemptRecord)` returns `()`. The observer holds no reference to the
109scheduler, KV manager or arena. Two `compile_fail` doctests in
110`dual_observer.rs` show that (a) mutating the record and (b) returning a
111different `AdmitPreemptChoice` do not compile (T4).
112
113**By injected mutant.** Cargo feature `dual_observer_mutant_changes_decision`
114makes the admission loop stop after one grant whenever an observer is
115installed (a decision change that only the tap's presence triggers). With it
116on, the parity test must fail:
117
118```
119cargo test -p aien-scheduler --features dual_observer_mutant_changes_decision --test dual_observer_parity observer_presence_changes_no_decision
120test observer_presence_changes_no_decision ... FAILED
121thread 'observer_presence_changes_no_decision' panicked at crates/aien-scheduler/tests/dual_observer_parity.rs:46:9:
122scenario admission_basic: decisions differ with the observer installed
123test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 12 filtered out
124exit=101
125```
126
127Full parity file under the mutant: 4 failed (`observer_presence_changes_no_decision`,
128`kv_accounting_identical_with_and_without_observer`,
129`queue_exhaustion_records_show_the_batch_limit_stopping_admission`,
130`fanout_children_enter_decode_on_existing_tables`), 9 passed. The feature is
131off by default and never enabled in CI; the mutant code stays in the tree,
132disabled, so the control can be rerun (same convention as
133`prefill_mutant_no_check`).
134
135## 6. Benchmark: pre-registered threshold (written and committed BEFORE the run)
136
137Command (release profile, host CPU, mock backend, whole workload set per
138round, 7 rounds per arm, median reported):
139
140```
141cargo test -p aien-scheduler --release --test dual_observer_overhead_bench -- --ignored --nocapture
142```
143
144Arms: `absent` (no observer; production configuration), `counting`
145(`CountingObserver`: serializes each record to count bytes, keeps nothing),
146`recording` (`RecordingObserver`: clones and keeps every record),
147`absent_repeat` (noise reference).
148
149Pre-registered acceptance (frozen here, commit before the run):
150
151| Id | Measure | Threshold | Why |
152|---|---|---|---|
153| B1 | `median(counting) / median(absent)` | **≤ 1.25** | The tap must be cheap enough to stay installed through the DUAL-3 observation period. On the mock backend the step has no model compute, so this ratio is a strict upper bound on the production fraction (real steps are dominated by the forward pass). No prior threshold exists in the repository for this tap; 25 % is the author's choice and it is not moved after the run. |
154| B2 | `records` emitted (counting and recording arms) | **== decisions** exactly | one record per decision, no drops, no duplicates |
155| B3 | `absent` arm decision count | **== counting arm decision count** | the tap adds or removes no scheduling step |
156| B4 | `median(absent_repeat) / median(absent)` | reported, informational | machine noise reference for reading B1 |
157| B5 | bytes emitted, heap allocations and bytes (global allocator counter) per arm | reported, no threshold | observer cost in memory terms for the DUAL-3 design |
158
159Not measured here: absent-arm wall time on the candidate against the base
160commit. UNVERIFIED by timing; the before/after identity is proven by T1/T2
161(decisions) and by reading the diff (the absent path adds one
162`Option::is_some()` and passes `None` through).
163
164If B1 fails the receipt says FAIL and the threshold stays.
165
166## 7. Results
167
168Filled in §9.
169
170## 8. Limits
171
172- Mock backend only. No real model, no GPU, no NVRM.
173- The tap records the admission / preemption / chunk decision. It does not
174 record the `step()` post-processing (token append, finish, KV free on
175 finish), which is not a DUAL decision site.
176- `RunningVerdict::GateRefusedReprefill`, `DecodeNoTable`, `NoRecord` and
177 `AdmissionVerdict::MissingRecord` are reachable only through internal state
178 manipulation; the pre-registered workloads do not reach them. UNVERIFIED
179 by test in this receipt (the code paths are plain copies of the
180 scheduler's own branches).
181- Timing of the absent path versus the base commit: UNVERIFIED by
182 measurement (see §6).
183
184## 9. Run log (appended after the runs, nothing above this line edited)
185
186### 9.1 Test results (candidate tree, first commit `a2640c7` plus this appendix and the exploratory benchmark below)
187
188| # | Result |
189|---|---|
190| T1 | Base worktree at `91fba8fc0f00fd09fc3e9a6137522af3ae79c4e1` (`git worktree add /tmp/sc-base origin/main`, `tests/dual_common`, `tests/dual_decision_golden.rs` and the two dev-dependencies copied in, nothing else): `test decisions_match_golden_fixture_from_base_commit ... ok` with `DUAL_WRITE_GOLDEN=1`; wrote 13 per-scenario digests (1346 bytes). Regenerated once more after the final edit of `dual_common`; byte-identical. |
191| T2 | `cargo test -p aien-scheduler --test dual_decision_golden`: 3 passed, 0 failed (golden digests match on the candidate; deterministic run to run; drained scenarios hold 0 KV blocks, 0 tables, 0 arena records, empty queues; the refusal scenario allocates nothing). |
192| T3 | `cargo test -p aien-scheduler --test dual_observer_parity`: 13 passed, 0 failed. |
193| T4 | `cargo test -p aien-scheduler --doc`: 2 passed (both `compile_fail`). |
194| T5 | `cargo test -p aien-scheduler -p aien-kv-cache -p aien-runtime -- --test-threads=1`: 29 suites, 91 passed, 0 failed, 4 ignored (the ignored ones are the pre-existing real-checkpoint runtime tests and this benchmark). Exit 0. |
195| T6 | `cargo fmt --all -- --check`: exit 0. `cargo clippy -p aien-scheduler --all-targets -- -D warnings`: exit 0. |
196| T7 | `crumb compile .` then `crumb verify .` immediately before the commit: `OK: 13 crumbs current`. After the commit `crumb verify .` reports the root crumb STALE because `generated_at_commit` names the previous HEAD; pristine `main` at `91fba8f` reports the same (`crumb verify` in `/tmp/sc-base`: `FAIL: 1 of 13 crumbs stale`). This repository's CI runs no `crumb verify` step (grep of `.github/workflows/*.yml`). Recorded, not worked around. |
197
198Negative control: as §5 (mutant feature on: 4 of 13 parity tests FAIL, exit 101; feature off: 13 pass).
199
200### 9.2 Benchmark results, pre-registered protocol (§6)
201
202Command as pre-registered, release profile, run once after the threshold was committed:
203
204```
205DUAL serve.admit_preempt observer overhead, 7 rounds per arm, whole workload set per round
206arm median_ms min_ms decisions records bytes allocs alloc_bytes ratio
207absent 1.520 1.516 53 0 0 16537 2511522 1.000
208counting 2.033 1.952 53 53 329492 17059 3757374 1.337
209recording 1.182 1.177 53 53 329492 17253 3904970 0.778
210absent_repeat 0.903 0.899 53 0 0 16537 2511522 0.594
211```
212
213| Id | Measured | Threshold | Verdict |
214|---|---|---|---|
215| B1 | `counting / absent` = **1.337** | ≤ 1.25 | **FAIL** (pre-registered; the threshold is not moved) |
216| B2 | records = 53 = decisions, both tapped arms | == | PASS |
217| B3 | decisions absent = 53 = counting | == | PASS |
218| B4 | `absent_repeat / absent` = **0.594** | informational | the noise between two identical arms (41 %) is larger than the effect B1 tries to resolve; the pre-registered protocol (arms run back to back, 7 rounds, ~1.5 ms per round) cannot measure a 25 % bound on this host |
219| B5 | bytes emitted 329,492 for 53 records (6.2 KB per record on average, dominated by the 500-way fan-out scenario's id lists); heap allocations absent 16,537, counting 17,059 (+522, about 10 per record), recording 17,253 (+716); alloc bytes 2.51 MB, 3.76 MB, 3.90 MB | reported | reported |
220
221**B1 is recorded as FAIL.** The protocol was under-powered (B4), which is a
222defect of the pre-registration, not a reason to change the verdict.
223
224### 9.3 Exploratory measurement, NOT pre-registered (added after 9.2)
225
226Added after the run above: `dual_observer_overhead_interleaved` (same file),
227arms interleaved absent / counting / recording in every round, 50 rounds,
228one warm-up round per arm discarded, medians:
229
230```
231arm median_ms min_ms decisions records bytes allocs ratio
232absent 0.909 0.901 53 0 0 16537 1.000
233counting 1.128 1.122 53 53 329492 17059 1.241
234recording 1.135 1.127 53 53 329492 17253 1.249
235```
236
237Reading: about 4 µs of tap cost per decision on the mock backend
238((1.128 − 0.909) ms / 53), where a mock step itself costs about 17 µs. This
239is post-hoc and does not turn B1 into a pass. A future pre-registration
240should use the interleaved protocol and state the absolute per-decision cost
241beside the ratio, because the ratio on a compute-free mock backend overstates
242the production fraction (a real step is milliseconds of forward pass).
243
244### 9.4 Verdict
245
246- Instrumentation delivered: read-only tap at `serve.admit_preempt`, decision
247 parity proven byte-for-byte against the base commit and between tap on/off,
248 negative control killed by type and by mutant.
249- Benchmark B1: FAIL against the pre-registered 1.25 ratio; B2, B3 PASS;
250 exploratory interleaved 1.24 to 1.25 reported, not claimed.
251- `DUAL_ADVISORY_SCHEDULER`: **not claimed** (see the top of this receipt).