Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/docs/design/gb10-weight-ownership.md # 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 Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / docs / design / gb10-weight-ownership.md` 350 lines ยท 28432 bytes Raw Blame History Rendered 1 # GB10 weight ownership and serving-time memory (design, for #277, not a fix) 2 3 ## In plain words 4 5 On the GB10 the graphics chip has no memory of its own. It uses ordinary system memory that the 6 driver pins for it. Today the Qwen3-4B model takes that memory twice: a full 32-bit copy of every 7 weight stays in the program (about 15 GiB), and a second, smaller 16-bit copy is handed to the 8 driver (about 7.5 GiB). When the machine is busy and its "free" memory is low, the driver 9 sometimes cannot get the pinned memory it asks for, even though plenty of memory could be freed 10 by dropping cached files. That is the failure in #277 and omega#327. This note does two things. 11 First, it lists every place the program asks the driver for memory, and shows that some requests 12 happen while the model is serving, not only at start-up (so just opening the GPU earlier, as 13 draft PR #278 does, cannot cover them). Second, it proposes the longer-term fix: send each weight 14 straight from the model file to the GPU, never keep the big 32-bit copy, and ask the driver for 15 all serving memory once, at start-up. That would cut the machine's memory use from about 22 GiB to 16 about 9 GiB and remove the late requests. Nothing here changes runtime code, and nothing is 17 proven on the chip. The default refusal of Qwen3 on the GB10 stays in place. 18 19 ## Status and evidence labels 20 21 - Source facts below were read at: omega main ``01f6a74`` (equal to `omega.lock`), sovereign-core 22 main ``cad36d9``, physics ``6d7cf0d`` (the repo that holds `nvrm/nvrm.c`). These are the commits read; both mains have since moved. 23 - OBSERVED = read in source or in a recorded receipt. COMPUTED = arithmetic from the model's 24 `config.json` and the source formulas. INFERRED = follows from source, never run. UNVERIFIED = 25 not checked. 26 - No GPU was used for this note. The #277 chip attempt is INVALID CONDITION (baseline passed in a 27 scripted cache fill); the trigger of the failure is still UNKNOWN. This design assumes the 28 working theory of #277 (RM system-memory allocations fail at low MemFree) and does not prove it. 29 30 Model numbers used (Qwen3-4B-Instruct-2507, `config.json`): hidden 2560, intermediate 9728, 36 31 layers, 32 query heads, 8 KV heads, head_dim 128, vocab 151936, tied embeddings, declared context 32 262144. 33 34 35 ## Update 2026-10-07 (after omega#332 and omega#333; still no chip run) 36 37 - Cut B is done, on omega's fake GB10 layer (CPU only, no chip). omega#332 (merged `7894abb`) counted 38 458 driver allocations and 456 frees after warm-up over 428 tokens: the per-length attention pool 39 reallocation and the matmul code-cache thrash (21 shapes, 8 slots) are real, OBSERVED on the fake 40 layer. This confirms section 1(c): serving-time allocations exist, so #278 alone cannot fix #277. 41 - omega#333 (merged `b980783`) adds an opt-in up-front reservation, `omega_gpu_reserve_serving` 42 with `OmegaGpuServingBounds`: attention pool sized from the KV block size, matmul scratch, and a 43 deeper matmul kernel cache (32 slots of storage, 21 needed by Qwen3-4B). Opted in, the same test 44 counts 0 allocations and 0 frees after warm-up; a request past the reservation is refused with a 45 named error before any driver call. Not covered: elementwise scratch, the attention kernel cache 46 (8 slots), prebuilding matmul shapes at reserve time. 47 - Wired in (draft PR "Part of #277", not yet proven on the chip): `omega.lock` is `b980783` and the 48 daemon, on the opt-in Qwen3 GB10 path only, calls the reservation once after the session opens and 49 before the first request (`aien-inference-abi/src/gb10_serving.rs`), logging a 50 `GB10_SERVING_RESERVATION` line and refusing to serve by name if omega refuses. Its chip attempt 51 under the #277 protocol is still to be declared and run. Cuts A and C are not started. The default 52 refusal of Qwen3 on the GB10 stays. 53 - The #277 chip attempts so far: attempt 1 (06:33Z) and attempt 2 (21:45Z) are both INVALID CONDITION: 54 the baseline did not reproduce the failure, so the fix runs were skipped by the rule fixed in advance. 55 In attempt 2 the low-memory state was present at launch, but the scripted cache fill reclaimed 56 memory before the baseline ran. A protocol amendment that 57 skips the fill when the trigger already holds is proposed on #277 and not applied. 58 ## Update 2026-10-07 (cut C written, host-measured, not run on the chip) 59 60 - Cut C is in draft PR "Part of #277 (cut C), stacked on #311": `MatrixWeight` (host f32 or a device handle) replaces the seven per-layer f32 matmul weights and the output head; `aien-inference-abi/src/resident.rs` streams each matrix from the bf16 shard (positioned reads, one tensor at a time, `checkpoint.rs` `StreamedCheckpoint`) into `omega_gpu_tensor_upload_bf16`, and the daemon does it only on the native, production-strict, opted-in GB10 Qwen3 path, after opening the GPU session. Every other load is the unchanged host f32 load. 61 - Numerics: bf16 widened to f32 and narrowed again by omega (`(__bf16)f`, omega_blackwell_matmul.c:98 at omega.lock) is exact for 65410 of 65536 patterns and quiets the 126 signaling NaNs; the loader applies the same quieting, so the uploaded bits equal today's for every pattern. 62 - Host measurement (stub uploader, real Qwen3-4B checkpoint): peak 22.479 GiB before, 2.176 GiB after; steady 14.988 GiB before, 1.452 GiB after. The chip effect on #277 is NOT measured. 63 64 ## 1. Allocation audit 65 66 All GPU-side allocations go through `omega_gpu_session_alloc` (omega `src/omega_gpu_session.c:78-82`) 67 which calls `nvrm_alloc_gpu_uncached` (physics `nvrm/nvrm.c:473-475`, body `:477-`). The size is 68 rounded up to 4 KiB (`nvrm.c:480`), so any growth of even one page is a new request. A refused 69 request sets `rm->faulted = 1` (`nvrm.c:506-509`) and later requests then fail in the same 70 function (`nvrm.c:478`): one refused allocation ends the GPU session for the rest of the process. 71 OBSERVED. 72 73 ### (a) Daemon and session start-up 74 75 | What | Size | When | Freed | 76 |---|---|---|---| 77 | Channel and its context buffers (`m16_native_create_channel`, session.c:125) | driver decides (the `kgrctxAllocMainCtxBuffer` that failed in #274) | first chip call, or the probe in `open_gpu_session_with_retry` (omega_backend.rs:968-) | at session close only; nothing in the daemon calls close | 78 | Session buffers: pushbuffer 64 KiB, cbank 4 KiB, marker 4 KiB, QMD 64 KiB (session.c:127-128) | 136 KiB | at open | at close | 79 80 Daemon order on main (commands.rs, `run_daemon_server`): weights loaded (`build_native_daemon_backend`, 81 :1332), KV pool built (:1508), then the session opened by the probe (:1528). Draft #278 moves the 82 open before the load. The session never reopens after a success. 83 84 ### (b) First forward pass (warm-up turn, server.enable_warm_up, commands.rs:1554) 85 86 | What | Size formula | Notes | 87 |---|---|---| 88 | Resident weight matrix, one per matrix (`omega_gpu_tensor_upload_bf16`, matmul_api.c:210) | kp * np * 2 bytes, kp = k rounded to 16, np = n rounded to 8 | layers: 36 x (q 2560x4096, k 2560x1024, v 2560x1024, o 4096x2560, gate 2560x9728, up 2560x9728, down 9728x2560) = 3.63 B values = 6.76 GiB COMPUTED. Plus lm_head: `compute_logits` goes through `chip_matmul` with the tied embedding (omega_backend.rs:833-848), 151936x2560 = 0.72 GiB COMPUTED. Total resident 7.48 GiB. #277 quotes about 6.8 GiB, which matches the layers only; the lm_head copy is extra (INFERRED, check at the next run). | 89 | Matmul kernel code, one per (kp, np, grid_x) shape (matmul_api.c:163) | about one to a few pages each (code + 2048 B tail, rounded to 4 KiB, code_alloc.h) | see (c): the cache has 8 slots | 90 | Elementwise kernel code (rmsnorm, rope, swiglu) | pages each | elementwise_api.c:930, cache of 8 | 91 | Attention kernel code (one shape for Qwen3) | pages | attention_api.c:553, cache of 8 | 92 | Scratch first sizes | see (c) | all scratch starts at 0 and is created by the first call that needs it | 93 94 Today these resident uploads happen lazily on the first call that touches each weight, which is 95 the warm-up turn when a tokenizer is loaded (otherwise the first real request). Each upload also 96 makes transient host copies: a transposed f32 copy of the whole matrix (`wt`, omega_backend.rs:205-212), 97 a bf16 copy (matmul_api.c:`omega_gpu_tensor_upload_f32`), and a packing buffer (64 column tiles). 98 For lm_head that is 1.45 GiB + 0.72 GiB of ordinary memory at once. 99 100 ### (c) Per-request serving 101 102 The key finding: scratch buffers are **grow-only with exact size, freed and re-requested from the 103 driver on every increase**. `omega_gpu_session_scratch` (session.c:97-105): if the request is 104 larger than the current capacity, free the old buffer and allocate a new one of exactly the new 105 high-water size. No headroom, no geometric growth, no pre-reservation. OBSERVED. 106 107 | Buffer | Size formula | Grows with | Reallocated mid-serving? | Freed | 108 |---|---|---|---|---| 109 | Attention staging pool `g_pool` (attention_api.c:600, run_launch :609) | f32 path: 2 * seq_len * kv_heads * head_dim * 4 = 8 KiB per token for Qwen3 (attention_api.c:711-714) | context length | **Yes.** Each new context length is 8 KiB more than the last, which is more than the 4 KiB rounding, so every generated token (and every prefill chunk) triggers one free plus one new driver allocation, first layer of the step only; the other 35 layers reuse it | at session close | 110 | Attention q / out | q_heads * head_dim * 4 = 16 KiB each, times number of sequences in the call | batch size | only when the number of sequences rises | at close | 111 | Attention table | a few bytes | batch | tiny | at close | 112 | Matmul activations `a_buf` | round16(m) * kp * 2 | rows per call m | when m or kp exceeds the previous maximum | at close | 113 | Matmul results `c_buf` | round16(m) * np * 4; logits step: m = number of decoding sequences, np = 151936 (9.3 MiB at m <= 16, 37 MiB at 64, about 148 MiB at 256) | concurrent decodes, prefill chunk (128 rows) | when m rises past the previous maximum, or a bigger np appears | at close | 114 | Elementwise a/b/c (`run_abc`, elementwise_api.c:978, :1074) | each launch is split to at most 64 CTAs (EW_MAX_CTAS), so at most 64 rows x 2560 x 4 = 640 KiB per buffer, independent of context | nothing past the first full-size call | no (after the first 64-row call) | at close | 115 | Kernel code, matmul (matmul_api.c:144-167) | pages | (kp, np, grid_x) | **INFERRED yes; since OBSERVED on the fake layer, see Update.** The key includes grid_x, which depends on rows (grid_x = budget / ceil(m/16), capped by np/8). With the daemon CTA budget of 256: decode (m = 1) and prefill chunk (m = 128) give 6 shapes each (12 distinct, k and v share one), and the cache has 8 slots, evicted round-robin (`cache_next`). Alternating prefill and decode, or different decode batch sizes, therefore frees and re-allocates code buffers during serving | at close | 116 | Pushbuffer, cbank, marker, QMD | fixed (session.c:127) | none | no (each launch rewrites the same buffers) | at close | 117 | Resident weights | fixed after (b) | none | no | when the `ResidentTensor` drops | 118 | KV cache pool (`UnifiedKvTensorPool`, Fp32, shared_kv.rs:44-57) | 288 KiB per token (36 layers x 8 heads x 128 x 2 x 4 B) COMPUTED; declared context 262144 would be 72 GiB, so `AIEN_KV_CONTEXT_TOKENS` must lower it | context | n/a: **host memory, not driver memory** | daemon exit | 119 | Per-call host gather of K and V for the f32 attention kernel (omega_backend.rs:464-490) | 2 * n * 4096 B host vectors | context | host only | per call | 120 121 Bound on the attention scratch: the f32 attention kernel refuses `seq_len > 4096` 122 (`OMEGA_GPU_ATTN_MAX_GQA_CTX`, attention_api.c:703, header :83). A longer context is a chip error, 123 which is a fatal fallback in a production build (strict.rs). So on this path the pool is at most 124 2 * 4096 * 8 * 128 * 4 = 32 MiB COMPUTED, and Qwen3 serving above 4096 tokens is not possible 125 natively today regardless of memory. That makes a pre-reserved envelope small and cheap. 126 127 ### Answer to #277's open question 128 129 Yes. Anything else allocates driver memory per call later: the attention staging pool grows by 130 one request per generated token, matmul scratch grows with batch rows and decode batch size, and 131 matmul kernel code buffers are probably evicted and rebuilt when prefill and decode alternate. 132 OBSERVED for the scratch rule, INFERRED for the code-cache thrash. Opening the session first 133 (#278) only guarantees the channel context and the first allocations happen early. It cannot by 134 itself cover these later requests. Candidate 1 is therefore incomplete unless start-up also 135 reserves every scratch at its maximum, and only candidate 2 (smaller footprint) keeps MemFree high 136 for the whole run. The comment on #277 (source check at omega `8887454`) reached the same 137 conclusion; this table re-checks it at `01f6a74` and adds the 4 KiB per-token rule, the 4096 token 138 bound, the lm_head resident copy and the code-cache thrash. 139 140 ## 2. Ownership design (candidate 2) 141 142 ### Goal 143 144 On the GB10 production path, the process never holds an f32 copy of a matmul weight. Each matrix 145 goes from the checkpoint's bf16 bytes to the GPU, and the host keeps only what the host really 146 reads. 147 148 ### What the host still needs as f32 149 150 | Tensor | Used by | Plan | 151 |---|---|---| 152 | `embed_tokens` (1.45 GiB f32) | token embedding row gather (transformer_backend.rs:733, :1036) | keep as f32 in the first cut. Later cut: keep bf16 (0.72 GiB) and decode a row on demand | 153 | norm weights (`input_layernorm`, `post_attention_layernorm`, `final_norm`, `q_norm`, `k_norm`) | the rmsnorm ops take `&[f32]` and stage them to the GPU every call | keep as f32, about 1 M values, negligible | 154 | lm_head (tied) | `compute_logits` | resident only (shares the embedding's values, own transposed device copy) | 155 | q/k/v/o/gate/up/down | matmuls | resident only | 156 157 ### Storage type 158 159 In `aien-inference-abi/src/weights.rs`: 160 161 ``` 162 pub enum MatrixWeight { 163 Host(Vec), // CPU reference, dev builds, tests, non-GB10 models 164 Resident(ResidentWeight), // GB10 production: owns the device copy, no host values 165 } 166 pub struct ResidentWeight { id: WeightId, k: usize, n: usize, tensor: ResidentTensor } 167 ``` 168 169 `TransformerLayerWeights` fields `q_proj .. down_proj` become `MatrixWeight`; `lm_head` becomes 170 `Option`; `embed_tokens` and the norms stay `Vec`. `TensorBackend::matmul_vec`, 171 `matmul_batch` and `compute_logits` take `&MatrixWeight` instead of `&[f32]`. The 23 call sites in 172 transformer_backend.rs change mechanically. `ReferenceCpuBackend` accepts only `Host`; given a 173 `Resident` it returns a loud error (it has no host values to compute with), which is consistent 174 with strict.rs (a production build refuses CPU fallback anyway). The dev build with 175 `AIEN_DEV_FALLBACK` keeps working by loading `Host` (no residency) or by a documented 176 "resident plus host" load mode that keeps both for parity tests. 177 178 ### Backend resident cache 179 180 `OmegaGb10Backend` today keys its cache on (pointer, length, in, out) plus a sampled fingerprint 181 (omega_backend.rs:52, :194-199) because it cannot tell when a borrowed slice changes. With 182 `ResidentWeight` the device copy is owned by the weight and immutable, so no cache and no 183 fingerprint is needed for it: the backend calls `matmul_f32` on the handle. A `Host` weight on the 184 Omega backend keeps the existing lazy path (tests, TinyLlama, Llama-3.2-1B continue to pass 185 unchanged until they are migrated). Dropping `TransformerWeights` drops each `ResidentTensor`, 186 which calls `omega_gpu_tensor_free` (aien-omega-gpu lib.rs:306-311). Ownership becomes one-way and 187 visible in the type. 188 189 ### Upload straight from the checkpoint 190 191 - A new safe wrapper `ResidentTensor::upload_bf16(k, n, &[u16])` over the already declared FFI 192 `omega_gpu_tensor_upload_bf16` (ffi.rs:107; omega matmul_api.h:88). A bf16 value widened to f32 193 and rounded back by omega is bit-identical, so the resident data equals today's. COMPUTED from 194 the conversion definition; the parity test checks it. 195 - Safetensors stores W as `[out][in]` (so `[n][k]`); the engine wants `[k][n]`. Cut 1 transposes in 196 Rust into a bf16 buffer per matrix (largest 9728x2560x2 = 47.5 MiB; lm_head 0.72 GiB), then 197 uploads. Option for a later omega change: accept `[n][k]` input and transpose while fragment 198 packing, removing the transient (omega_matmul_frag_pack_b already walks the matrix in tiles). 199 - Loading becomes streaming: for each tensor, read from the shard (memory-mapped, so the pages 200 are clean reclaimable page cache, not process memory), convert or upload, move on. The whole-file 201 `fs::read` (checkpoint.rs:501, :581) that made the 7.49 GiB raw copy disappears for this path; 202 the existing path stays for non-GB10 loads. Release is automatic: nothing holds the bytes after 203 the loop. 204 - Order at daemon start: open the GPU session and run the probe first, then stream-load and 205 upload. Every large driver allocation then happens during load while the host holds almost 206 nothing, and the lazy-upload-on-first-prefill step disappears. This subsumes the ordering change 207 in #278 (which then becomes a one-line no-op for GB10 Qwen3 and can stay for the other models). 208 - Non-bf16 checkpoints (f16 or f32 shards) go through a one-matrix-at-a-time convert to bf16 and 209 upload; never a whole-model f32 copy. 210 211 ### Serving-time reservation (no driver allocation after start-up) 212 213 Two parts, because scratch and code buffers behave differently. 214 215 1. Scratch, no omega change (first cut): after the session opens and the weights are resident, 216 run a "serving envelope" warm-up that calls the backend once at the maximum of each dimension: 217 attention at seq_len 4096 (32 MiB pool), matmul at the largest planned rows for each shape 218 (prefill chunk 128 rows; decode rows = the scheduler's `max_batch_size`, 256 in the daemon, 219 commands.rs:1478) including the logits shape, and elementwise at 64 rows. Because scratch only 220 grows and never shrinks (session.c:97-105), every later call fits and no realloc happens. 221 Envelope size COMPUTED: about 32 MiB attention + about 150 MiB matmul results at 256 decode rows 222 + about 20 MiB matmul inputs + under 3 MiB elementwise, roughly 0.2 GiB. The envelope limits 223 come from startup configuration (context cap, scheduler limits), logged, and a request beyond it 224 is refused with a clear message instead of reaching the driver. 225 2. Kernel code, needs a small omega change: raise `CACHE_SLOTS` in matmul_api.c:28 from 8 to 16 226 (covers 12 shapes with headroom), so no code buffer is evicted. Before relying on it, confirm 227 the thrash with a CPU-only test on omega's fake native layer (`tests/fake_m16_native.c` already 228 counts `uncached_calls` and `free_calls`): replay one prefill chunk, one decode and one more 229 prefill and assert the allocation counters. If the thrash is not real, skip the change. 230 3. Guard (omega, optional): a "seal" call after warm-up so that any later allocation attempt 231 returns a named error (`ENVELOPE_EXCEEDED`) instead of an opaque NV_ERR_NO_MEMORY, and a pair of 232 counters (allocs, frees since seal) exposed through the Rust crate for the receipts. 233 234 ### Peak memory estimate (COMPUTED, Qwen3-4B bf16, to be measured) 235 236 | | Today (measured / computed) | After cut 1 and 2 | 237 |---|---|---| 238 | Process memory at load peak | 22.48 GiB measured (f32 14.98 + raw bf16 7.49) | about 2.2 GiB (embedding 1.45 f32 + largest transient 0.72 for lm_head bf16 transpose); shard pages are reclaimable cache | 239 | Process memory in steady state | 14.98 GiB f32 | about 1.5 GiB (embedding + norms) | 240 | Pinned driver memory, steady | about 6.8 GiB quoted, 7.48 GiB computed | 7.48 GiB resident + about 0.2 GiB envelope + session | 241 | Total the machine must find | about 22.5 GiB | about 9.2 GiB | 242 | Transient at each upload | up to 2.2 GiB (lm_head f32 transpose + bf16) | up to 0.72 GiB | 243 244 Saved: about 13.5 GiB of ordinary memory for the layer matrices, 14.2 GiB if the embedding is 245 later kept as bf16. The KV pool (host) is unchanged and is set by `AIEN_KV_CONTEXT_TOKENS`. 246 247 ### Failure modes and how the design handles them 248 249 - Driver refuses an allocation during load: the daemon fails to start with the stage text and 250 MemFree, as in #239, before serving. Fine; this is the safest place to fail. 251 - Driver refuses an allocation during serving: should not happen inside the envelope. If it does, 252 the session is dead (`faulted`), the strict build refuses to fall back, the request fails loudly. 253 Not recoverable without a restart; the counters and the sealed guard make it visible. 254 - Request exceeds the envelope (context above 4096, batch above the declared maximum): refused with 255 a message naming the envelope, before any chip call. 256 - Non-bf16 or non-Qwen3 models: keep `Host` path until migrated; the old behaviour is untouched. 257 - A `Resident` weight handed to the CPU reference backend: loud error by construction. 258 - Parity regression: guarded by the existing Qwen3 forward parity test (max abs logit difference 259 bound 0.15, same top token) run on the new load path. 260 - Idle GPU memory is no longer reclaimable once pinned: unchanged from today, and the point of the 261 budget. 262 - Memory fragmentation at start-up (UNKNOWN whether it matters, see #277 amendment 1): the design 263 allocates large buffers first, early, which is the best available mitigation but is not a proof. 264 265 ## 3. Declared test conditions and acceptance criteria 266 267 These follow the conventions of `~/workspace/hive/WQWEN/c277/run-277.sh` (sealed script, written 268 declaration before any run, one variable, base first, fixed run order, camera, no kills, receipts 269 with `SHA256SUMS`). They are written now and must be frozen in a DECLARATION file before the first 270 run. 271 272 Question: with the weight-ownership change, does the Qwen3-4B GB10 path pass in the organic 273 low-MemFree state where the unchanged baseline fails, without dropping the page cache? 274 275 - Condition (must hold, measured and recorded before every run, run refused if not met): organic 276 state from normal use, `MemFree <= 25 GB` and `Cached >= 80 GB` (as #277 defines). No 277 `drop_caches`, no setting change, and no scripted cache fill as the qualifying state (the 278 #277 attempt shows a scripted fill did not reproduce the failure). The script reads 279 `/proc/meminfo` and `/proc/buddyinfo` first and exits without taking the GPU hold if the numbers 280 are not met, writing `STATE NOT MET` to the receipts. Waiting for the state is allowed; creating 281 it artificially is not. 282 - Arms (one variable: weight ownership and reservation): base = unchanged main binary; fix = the 283 implementation PR binary. Both built from sealed commits and checksummed in 284 `receipts/binaries.txt`; same omega pin, same model revision (`cdbee75f`), same test 285 (`real_qwen3_4b_instruct_2507_on_gb10_matches_transformers`) with 286 `AIEN_GB10_QWEN3_DECLARED_ATTEMPT=1`. 287 - Order: base once, then fix three times (at least 3). The condition is valid only if base FAILS 288 in the same organic state (expected signature: `RM_ALLOC ... status 0x51`, stage 289 `m16_native_create_channel` or an upload). If base passes, the state did not reproduce the 290 failure, the fix runs are skipped, nothing is claimed (INVALID CONDITION again). 291 - Camera: 1 s `/proc/meminfo` sampler for the whole run, `buddyinfo` and `dmesg | grep NVRM` 292 captured before and after each run, process peak RSS (`/usr/bin/time -v` or `/proc/PID/status` 293 VmHWM), session allocation and free counters before warm-up, after warm-up and at the end. 294 - One GPU hold under the quietlock procedure; no test is killed; the camera is stopped last. 295 - A serving leg, because the load-time leg alone would repeat #277's stated limit: after the 296 parity prompt, decode at least 256 tokens in one sequence and run one second prompt of at least 297 1024 tokens, with context reaching at least 2048, and one change of batch size if the harness 298 can. Allocation counters must show zero driver allocations and zero frees between the end of 299 warm-up and the end of the run. 300 - PASS = baseline FAIL in the same state, and fix 3 of 3 runs satisfy all of: test assertions 301 (max abs logit difference <= 0.15, same top token), `chip_errors = 0`, `fallbacks = 0`, all ops 302 native, serving-leg counters show 0 driver allocations after warm-up, process peak RSS below 303 12 GiB (vs 22.5 GiB measured today; threshold set before any run), no `NVRM` allocation error in 304 dmesg. Any fix failure is a FAIL; no reruns. 305 - Limits to state in the verdict: one model, one hardware unit, one driver (580.173.02), batch size 306 coverage as run, context only up to what the serving leg reached (and never above 4096 on this 307 path). 308 - The default refusal in `omega_model_refusal_with` stayed until the verdict was PASS and merged. 309 Declared attempt 3 passed (sovereign-core#277), and the follow-up PR flipped the default: 310 `AIEN_GB10_QWEN3_DECLARED_ATTEMPT` set to `1` enables the path; unset enables it only on a 311 production-strict run (no `AIEN_DEV_FALLBACK=1`), with the native engine and streamed resident 312 weights; `0` (or any other value, including non-UTF8) refuses it by name. 313 Evidence limits: the pass is [#277 comment `6059774846`](https://github.com/aien-spark/aien-sovereign-core/issues/277#issuecomment-`6059774846`), 314 on a Linux-hosted GB10 only (not native Aienux), one prompt, context 4096, no endurance run, 315 no failing baseline, cache partly scripted. 316 - Do not drop caches to qualify. If the organic state never recurs, the answer is "not 317 qualified", not a staged state. 318 319 ## 4. CPU-side changes that are safe to land now (behind the existing refusal) 320 321 | Change | Diff estimate | Risk | Notes | 322 |---|---|---|---| 323 | MemFree, Cached and MemAvailable in the start-up log and in each session-open attempt line (#277 item 3): extend `read_mem_available` into a small meminfo reader, add a second closure or a struct to `open_gpu_session_with_retry` | about 60 lines plus 2 unit tests (parse, missing field) | none: logging only, stub-testable | touches the same function as #278; land after or rebase on it | 324 | Print the planned resident total and the planned serving envelope at start-up (computed from the config, like `KvPoolPlan`), and the expected pinned total next to MemFree | about 80 lines plus tests | none: no allocation behaviour changes | gives the operator the numbers the declaration needs | 325 | `OmegaGb10Backend::resident_bytes()` and a count of uploads | about 25 lines | none | feeds receipts | 326 | Safe wrapper `ResidentTensor::upload_bf16` and its stub/native tests | about 50 lines | low: not called by default | prepares cut 1 | 327 | Streaming checkpoint reader that yields one tensor at a time from a memory map (new function, old one unchanged) | about 120 lines plus tests | low: unused until wired | prepares cut 1 | 328 329 Not safe to land now without a chip run: the serving-envelope warm-up (it launches kernels at new 330 sizes on models that are accepted today, so it needs chip qualification), the `MatrixWeight` type 331 change (cross-crate, about 700 to 900 lines changed across abi, inference-runtime, runtime, cli 332 and tests; it needs its own reviewed PR and the parity test), and the omega `CACHE_SLOTS` / seal 333 changes (separate omega PR, then an `omega.lock` bump). 334 335 ## 5. Recommended implementation order 336 337 1. Cut A (CPU, small, safe now): MemFree log plus resident and envelope plan lines plus resident 338 byte counters. Gives the next declared attempt its numbers and costs no chip time. 339 2. Cut B (DONE, see Update: omega#332 measured, omega#333 reserves) (CPU test on omega's fake layer): confirm or refute the matmul code-cache thrash and the 340 per-token pool reallocation with allocation counters, no GPU. This decides whether the omega 341 changes are needed. 342 3. Cut C (the real change): `MatrixWeight`, streaming bf16 upload, session-first order, envelope 343 warm-up; stub parity tests on CPU first, then one declared chip attempt as in section 3. 344 4. Cut D: flip the default refusal, only after a PASS verdict. 345 346 Open items I could not settle from source: why the baseline passed in the scripted state (trigger 347 UNKNOWN); whether the driver needs physically contiguous pages for the failing buffers (DOCS 348 SILENT per #277); how many rows a real mixed prefill and decode step puts into one matmul in the 349 daemon (the 256-row envelope is a bound from `max_batch_size`, not a measurement); the exact 350 resident total (7.48 GiB computed against about 6.8 GiB quoted; the gap is about the lm_head: 6.76 GiB is the layers alone, the lm_head adds 0.72 GiB, so the quote likely omits it).