Skip to content

rollout: subtract agent-reported tool time from throughput accounting#1663

Merged
Shi-Dong merged 1 commit into
mainfrom
shi/rollout-non-generation-time
Jul 15, 2026
Merged

rollout: subtract agent-reported tool time from throughput accounting#1663
Shi-Dong merged 1 commit into
mainfrom
shi/rollout-non-generation-time

Conversation

@Shi-Dong

Copy link
Copy Markdown
Contributor

Summary

Adds a small, env-agnostic hook to the generic agentic generate function (miles/rollout/generate_hub/agentic_tool_call.py) so that wall-clock time an agent spends outside policy generation (environment steps, tool calls, sandbox exec/eval) is surfaced on Sample.non_generation_time.

Why

agentic_tool_call.generate is the shared generate function used by every agent-environment RL path (Harbor/swe-agent-v2 and OpenEnv alike). The throughput/perf metrics in miles/ray/rollout/metrics.py derive per-sample tokens/sec from the total rollout wall-clock. In a multi-turn agentic rollout a large fraction of that wall-clock is env/tool latency, not decoding — so the reported tokens/sec is badly understated and not comparable across envs with different tool latencies. This hook lets the perf accounting subtract non-generation time and report a generation-only throughput.

How

If the agent function returns agent_metrics.total_tool_time, that value is written to non_generation_time on every turn-sample of the episode. The value must be identical across turn-samples because merge_samples collapses them with _merge_equal_value, which asserts equality. Agent functions that don't report the metric are unaffected (non_generation_time stays at its 0.0 default).

Notes

This was the only core-miles change previously bundled in #1487 (the OpenEnv tbench2 example). It is peeled out here as a standalone, generic change; #1487 now stacks on top of this branch.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds logic to extract total_tool_time from the agent's metadata and assign it to each sample's non_generation_time attribute to account for non-generation time in throughput calculations. The review feedback suggests defensively verifying that agent_metrics is a dictionary before calling .get() and validating that total_tool_time is a non-negative number to prevent runtime errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread miles/rollout/generate_hub/agentic_tool_call.py
@Shi-Dong
Shi-Dong merged commit a472996 into main Jul 15, 2026
36 checks passed
@Shi-Dong
Shi-Dong deleted the shi/rollout-non-generation-time branch July 15, 2026 12:30
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.

2 participants