Skip to content

Attribute inference worker time to every batch and agent rollout - #498

Merged
gregorybchris merged 4 commits into
mainfrom
chrisg/attribute-chat-inference
Oct 26, 2026
Merged

gregorybchris merged 4 commits into
mainfrom
chrisg/attribute-chat-inference

Conversation

@gregorybchris

@gregorybchris gregorybchris commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

Per-task attributed_inference_seconds is 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:

  • Chat tasks under a scaffold (mt_bench, multi_if, multichallenge, agent tasks): process_chat_request never 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.
  • Non-chat tasks under a streaming preset (every scaffold preset): each overlapping request is credited its own full latency, so totals exceed worker time by the concurrency factor.
  • Any failed batch: its results carry None, and one None nulls the task's total.

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, main against this branch:

Run main This branch
-H multi_turn_chat, multi_if (20) + arc_easy (20), 1.26 s processing both tasks missing multi_if 0.75 s, arc_easy 0.15 s
-H multi_turn_chat, arc_easy (40) + gsm8k (40), 0.32 s processing 24.4 s in total, about 75× 0.32 s in total
-H default, arc_easy (20) + gsm8k (20), batched 1.20 s in total, against 1.22 s processing 0.60 s in total, against 0.61 s processing

The 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.
  • Each inference worker owns one clock through its BatchingStrategy. Every batch (process_batch) and every scaffold rollout (process_chat_request) is a unit.
  • A batch's share is split across its requests by the prompt and completion tokens on each result's outputs, counted the same way as the task's token totals (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.
  • A rollout's share goes to its one result.
  • Failed batches keep their share, split evenly. They are still not reported to the metrics reporters (unchanged).
  • Docs: the field description in ingest-types.ts (schema regenerated) and the TASK_COST_KEYS comment.

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.md covers 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 skipped
  • With the agents and litellm extras: uv run --extra agents --extra litellm pytest tests/core/harness tests/harness tests/runners tests/providers: 622 passed, 20 skipped
  • npm --prefix dashboard/ui run contract:check, typecheck and test
  • New tests cover the clock (overlap, idle time, cancellation), the batch split by output tokens with its even fallback, concurrent rollouts and overlapping batches splitting worker time, failed batches and rollouts keeping their time, and both strategies sharing one clock per worker. The concurrency and rollout tests fail on main.
  • The mock runs in the table above.
  • Beaker trial on Holmes, 2 inference workers each, at commit 3b17b83. That is this branch plus Record per-task judge, sandbox and scoring-code time #499 before the rebase onto main and before the batch split moved to output tokens. Both succeeded with no task errors.
    • Batched, -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.
    • Chat scaffold, -H multi_turn_chat: multi_if (60) 59.4 s, mt_bench (20, GPT judge) 39.1 s. Both are null on main. 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

gregorybchris and others added 3 commits October 26, 2026 12:49
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]>
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
gregorybchris force-pushed the chrisg/attribute-chat-inference branch from db03cac to 11a0dab Compare October 26, 2026 19:59
@gregorybchris
gregorybchris merged commit 6306bb8 into main Oct 26, 2026
11 checks passed
@gregorybchris
gregorybchris deleted the chrisg/attribute-chat-inference branch October 26, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant