Repository navigation
Conversation
Export `CBv2RequestTiming` on the terminal `CBv2Usage` (numerics only:
nanosecond offsets from the engine enqueue instant plus step-participation,
prefill-chunk, MTP, pause, detok-delay and prefix-cache counters), stamped
on `CBv2ScheduledRequest` from the step's existing clock reads:
- enqueue: one `DispatchTime` read is the origin of every offset
- launch (`executeMixed` / `executeMTPRound`): admission, KV allocation
and prefill-chunk stamps reuse `wallStartedNanos`; one-token prompts are
decode-shaped but still counted as the row's prefill chunk
- finalize: ONE new unconditional read (readback-done) serves every
per-row stamp (first token / prompt computed, batch rows, step latency,
decode steps), the MTP accept walk, `finishedNanos` for finishes driven
by that finalize, and the cumulative `stepWallNanosTotal`
- markAdmitted counts re-admissions; ensureKVState counts capacity
requeues; setPaused accumulates paused time on the injectable clock
- prefix lookup is timed on the submit thread and rides `CBv2PrefixLookup`
into enqueue; `applyAdoption` is timed once per adoption
- first-token detok delay is measured inside `CBv2OutputStream`'s own lock
(armed by `reserveEmission`, read by the deferred `emit`) and folded into
the usage at terminal delivery; the scheduler record is never written
from the detokenization queue
`CBv2CapacitySnapshot` gains monotonic `stepWallNanosTotal` and
`decodeRowsTotal`, published under the existing gauges lock. `engineStep`
is wrapped in an `OSSignposter` "step" interval guarded by `isEnabled`.
`CBv2Usage.timing` is stored boxed: the Swift 6.3 runtime frees `async let`
result buffers above a size threshold out of order ("freed pointer was not
the last allocation"), reproduced on the unmodified engine by padding a
test result struct; keeping `CBv2Usage` one pointer larger avoids it.
No new locks, evals or per-row clock reads on the step path; hostSyncs
unchanged. Tests: `CBv2RequestTimingTests` (B=1, B=4, chunked/striped
prefill, stop-string path, preemption, backpressure, prefix hit, monotonic
counters, Equatable + numeric-only shape).
…ookup, align MTP admission stamp
…turate counters, count host syncs
…acy core-test expectation
… clock read, one timing box per request, exact hasSpans
This was referenced Sep 5, 2026
Closed
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands the branch Darkbloom production has served since 2026-09-02. Layr-Labs/d-inference pins libs/mlx-swift-lm at c408987, the tip of this branch, which is 6 commits ahead of main and was never merged: per-request
CBv2RequestTiming, cumulative step counters, step signposts, host-sync counting, and their fixes. Commits and authorship are unchanged (Gajesh).Why now: every runner-stack branch (#131 scaffold, #133 runner, #134 n-gram, #135 loader seam, #132 audit) is off main, so Darkbloom cannot compile against them (
EngineV2Bridge+Profile.swiftconstructsCBv2RequestTiming; docs-check citesCBv2RequestTiming+Stamps.swift). Main must contain every production pin. This PR merges FIRST in the contract's order, ahead of #132 and #135.Already merged into feat/qwen4exp-ngram-table at a5d51f4 to unblock the Darkbloom lane; the one conflict (
EngineLoopV2+MTPFinalize.swift, timing block vs round-audit record at the same finalize point) was resolved by keeping both, and the runner, n-gram, loader-filter and round-audit suites pass there (62 tests, 0 failures).🤖 Generated with Claude Code
Dependencies
This PR: Land feat/cbv2-request-timing on main (Darkbloom production pin).
Depends on: nothing. It can merge first..
Needed by: mlx-swift-lm #134, d-inference #836.
Merge order in this repository: #136, #132, #135, #130, #131, #133, #134, #137.
Program map: see
work/darkbloom-runner-contract.mdsection 16 (Runner Program) in the layr-labs workspace.