Repository navigation
fix(serving): on a discrete GPU the per-token cost is the engine's own KV over its tokens; the rest of the device delta is unattributed - #4961
Conversation
…n KV over the tokens it holds, and the rest of the device delta is probed as unattributed BigMama's 5090 receipt (build 6148, 2026-10-11): the device delta read 85.8 KB/token where the engine's own context bytes read 46.4 KB. The delta holds every tenant of the GPU (the embedding lane's 1.75 GiB lease) and the engine's unreported overhead. With a header rate the plan carries the excess as fixed bytes per lane (fixed_per_lane_from), so each extra lane paid for the other tenants again. Design per Codex: the lane's context bytes over the tokens it allocated (slots x per-slot n_ctx, from /props), with the residual probed as unattributed and never saved into the model's record. The device delta still speaks for an engine without memory_breakdown. The three /props readers become one fetch. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
|
Review (BigMama): diff only, CI not read yet. The direction is right: on a discrete GPU, the engine's own accelerator context bytes are the witness for the lane's KV, and the device residual becomes a probe instead of the rate (my 5090 numbers: /props context 3,137,470,464 on CUDA0 at n_ctx 67,584 x 1 slot = 46,423 B/token, against device_delta's ~85.8 KB). Two requests:
Non-blocking: reading |
…d the hybrid upper bound is named BigMama on #4961: unattributed_bytes printed 0 for an unread delta, the absence-as-measurement shape #4956 removed, so it prints none. On a hybrid model the context buffer holds each slot's fixed recurrent state, so the rate is an upper bound and a plan for more, shorter slots is short one state per extra slot. That split needs the engine to report it per sequence: card c8b2e1df, which first measures its size. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…er a device-delta stand-in Codex on #4961: a 500 ms /props miss and an engine without memory_breakdown both read as None, so a single miss wrote the tenant-charged device-delta rate back under the same model record and undid the correction. An unanswered engine now records no sample (serving.footprint.unmeasured leg=engine_unanswered); only an engine that answered without a context reading falls to the delta. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…vice delta; a present but unusable one is no reading Codex on #4961: EngineContext::from_props returned None both for an engine predating the field and for a present breakdown or slot geometry that is malformed, zero or overflowing, and both fell to the tenant-charged delta. EngineContextReading::of tells the three apart (Read, Absent, Invalid). Invalid records no sample (serving.footprint.unmeasured leg=engine_breakdown_invalid). The parser test now covers zero slots, an overflowing n_ctx, a malformed breakdown and an absent one. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
|
Approve at 92ffdb7 (BigMama), diff and CI: 7/7 green. Verified: |
…ng, never a legacy engine Codex on #4961 (92ffdb7): engine_props() parsed the body without checking the status, and EngineContextReading::of called any JSON without memory_breakdown Absent. So a 503 while loading, a 500, or a JSON null read as an engine that predates the field, and fell to the tenant-charged device delta. engine_props now rejects an unsuccessful status before parsing. And only a well-formed props document (it carries default_generation_settings) can be Absent; null and an error envelope are Invalid. The parser test adds both. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…null geometry is no legacy engine Codex on #4961 (0d44a51): {default_generation_settings: null} still passed as a well-formed legacy props document. slot_geometry() is now the one parse of total_slots and per-slot n_ctx (present, in range, nonzero), and both EngineContextReading::of and EngineContext::from_props use it, so 'a valid props document' means one thing. The parser test adds the null-geometry case. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
Card 03cdeee3. On a discrete GPU, the lane's per-token cost is now its engine's own KV divided by the tokens it allocated. The rest of the device delta is probed as unattributed and never saved into the model's record.
Why
BigMama's 5090 receipt (build 6148, 2026-10-11, 29
serving.footprint.measuredlines since the 21:44Z install):source="device_delta", 84,839–86,391 B/token (mode 85,801)./propson the same lane: CUDA0 context 3,137,470,464 + compute 889,536,768 ≈ 4.03 GB beyond weights, so ~46.4 KB/token over 67,584 tokens. The device delta charged this lane ~2.95 GB more than its engine reports.A whole-device delta holds every tenant of the GPU (the embedding lane's governed lease,
EMBED_LANE_VRAM_BYTES= 1.75 GiB,llamacpp_adapter.rs:69) and the engine's unreported overhead (card 60591923). With a header rate,fixed_per_lane_fromcarries the excess as fixed bytes per lane. So every extra lane the plan considers pays for the other tenants again.Confirmed live (Codex, the 5090, 22:57:45Z, before this PR):
serving.footprint.excess_is_fixed model=native27B header_rate=32768 measured_per_token=86530 measured_window=67584 fixed_per_lane_bytes=3633451008. Each lane the plan considers carries ~3.63 GB of fixed bytes. Expected after this PR: (46,423 − 32,768) × 67,584 ≈ 0.92 GB per lane. That remainder is the engine's own per-slot state beyond the header's KV rate (the hybrid's recurrent state among it, card c8b2e1df), where a per-lane term belongs.Change
weight_residency::EngineContext::from_props: the accelerator context bytes, the KV + compute total,total_slotsand the per-slotn_ctx. Lanes pass--parallelexplicitly, so the cache is never unified (server.cpp:153unifies only on auto) and the engine holdsslots × n_ctxtokens.source="engine_context"), decomposed over the engine's own geometry (a scratch slot included) with no compute floor. The device delta remains for an engine withoutmemory_breakdown.serving.footprint.device_residual: the delta, the engine's claim, andunattributed_bytes./propsrecords no sample (serving.footprint.unmeasured leg=engine_unanswered). Only an engine that answered without a context reading falls to the device delta, so one 500 ms miss cannot write the tenant-charged rate back (Codex).unattributed_bytes=none, never 0 (BigMama)./propsreaders become one fetch (engine_props).engine_beyond_weightsis deleted.Design per Codex (0faa2dae, eef7c987): "use lane-owned context bytes divided by ACTUAL allocated context tokens … subtract attributed tenants or retain an explicitly unattributed device residual."
Tests
engine_memory_counts_kv_and_compute_on_accelerators_onlyis extended with the fork #25 numbers (1.5B at-c 4096 -np 2): context 117,440,512 over 2 × 2,048. Geometry-less props read as no reading.Measured after deploy
Owner Cormac, deadline the 5090's first build containing this + 2 h. The check:
serving.footprint.measured source="engine_context"reads ~46.4 KB/token.serving.footprint.device_residual unattributed_bytesreads ~2.95 GB.excess_is_fixed fixed_per_lane_bytesdrops from 3,633,451,008 to ~0.92 GB.Card 03cdeee3 stays open until that receipt is posted.
🤖 Generated with Claude Code
https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE