Repository navigation
Attribute inference worker time to every batch and agent rollout - #498
Merged
Merged
Conversation
This was referenced Oct 17, 2026
Each inference worker now keeps a ShareClock: while k batches or agent rollouts are in flight, each second of worker time is credited 1/k to each. A batch's share is split across its requests by token share when the provider's request metrics line up, and evenly otherwise. This fills in attributed_inference_seconds for scaffold tasks, which never recorded it, and for runs without metrics (any run without --harness). It also stops streaming runs from crediting each overlapping request its full latency. Failed batches keep their share instead of nulling the task total. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Split a batch's share of worker time by the token counts on its results' outputs, counted the same way as the task's token totals, instead of by the provider's flushed batch metrics. Those stop lining up one to one when chat rollouts or concurrent flushes share the collector, which silently fell back to an even split. Say in the contract and TASK_COST_KEYS that the value is worker occupancy, not GPU time. Build the strategies inside their test, and drop an unrelated fixtures comment change. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
gregorybchris
force-pushed
the
chrisg/attribute-chat-inference
branch
from
October 26, 2026 19:59
db03cac to
11a0dab
Compare
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.
Per-task
attributed_inference_secondsis now each task's share of its inference worker's busy time, recorded for every batch and every scaffold rollout.Why
On
main, the field is still wrong or missing in three cases:process_chat_requestnever sets it. Other tasks in the same run are nulled too, because the rollouts' metrics land in the shared collector and the batch metrics no longer line up one to one with the batch.The only consumer is the dashboard's
derive_runtime, which uses this field for the per-task runtime of multi-task runs. For these cases it falls back to a token estimate, which misses sandbox time and gives nothing for agent tasks, whose results don't report tokens.Mock runs with 0.3 s of latency injected per provider call,
mainagainst this branch:main-H multi_turn_chat,multi_if(20) +arc_easy(20), 1.26 s processingmulti_if0.75 s,arc_easy0.15 s-H multi_turn_chat,arc_easy(40) +gsm8k(40), 0.32 s processing-H default,arc_easy(20) +gsm8k(20), batchedThe batched rows come from separate runs, so only each total against its own processing time is comparable: both match it, as before.
What changed
ShareClock(runners/asynq/share_clock.py): while k units of work are in flight, each second of wall time is credited 1/k to each. Shares sum to the time at least one unit was in flight.BatchingStrategy. Every batch (process_batch) and every scaffold rollout (process_chat_request) is a unit.request_token_usage). When any request's count is unknown, or the batch has no tokens, it is split evenly. It no longer depends on provider metrics being enabled or lining up with the batch.ingest-types.ts(schema regenerated) and theTASK_COST_KEYScomment.What the number means. It is the worker's occupancy, not GPU time. A rollout waiting on a tool, a sandbox, a judge or a user simulator is credited 1/k while the GPU serves other work, and a straggler rollout running alone gets the full wall time. The value is summed over workers, so a run with N workers attributes up to N times its processing time; the dashboard divides by the worker count (#493). The field name says "inference" and is kept to avoid churn.
Affected specs: none. No requests, scores or task hashes change; only runtime telemetry. Values from before and after this change can only be told apart by commit or upload date.
docs/result-compatibility.mdcovers measured results, so it has no entry.#499 stacks on this branch.
Validation
uv run ruff check src/ tests/,uv run ruff format --check src/ tests/,uv run ty check src/uv run pytest tests/ --ignore=tests/integration -q: 4,204 passed, 36 skippedagentsandlitellmextras:uv run --extra agents --extra litellm pytest tests/core/harness tests/harness tests/runners tests/providers: 622 passed, 20 skippednpm --prefix dashboard/ui run contract:check,typecheckandtestmain.mainand before the batch split moved to output tokens. Both succeeded with no task errors.-H default: arc_easy (1,000) 33.0 s, gsm8k (300) 5.5 s, mmlu_pro_law (300) 170.0 s. The sum, 208.4 s, is 98.1% of 2 workers × 106.2 s processing.-H multi_turn_chat: multi_if (60) 59.4 s, mt_bench (20, GPT judge) 39.1 s. Both are null onmain. The sum, 98.4 s, is 75% of 2 × 65.2 s; the rest is mt_bench's judge-scoring tail after inference finished.🤖 Generated with Claude Code