Skip to content

perf(simple-agent): build verification payloads once - #3339

Closed
HuiyingLi wants to merge 2 commits into
mainfrom
huiyingli/simple-agent-verify-payload
Closed

HuiyingLi wants to merge 2 commits into
mainfrom
huiyingli/simple-agent-verify-payload

Conversation

@HuiyingLi

@HuiyingLi HuiyingLi commented Sep 13, 2026 •

Copy link
Copy Markdown

What does this PR do?

When verification is enabled, SimpleAgent.run dumps the run request, merges the model response, validates the entire verify model, and dumps it again before sending it to the resources server. Large token arrays are traversed and allocated again even though the resources server validates its typed /verify request on ingress.

Build the verify wire dictionary with one run-request dump and attach the already serialized response directly. Keep resources-server ingress validation and final SimpleAgentVerifyResponse validation. Copy the response's top-level dictionary before extracting the internal trajectory so caller-owned data is not mutated.

Closes #3011.

Validation

  • 299 related tests pass on this branch; the 27 simple-agent tests give 96.15% coverage of simple_agent/app.py.
  • pre-commit run --all-files passes in a clean worktree at this commit.
  • Started Gym with its head/Ray, simple-agent, model-adapter, and string-match resources servers. Local GPU inference with Qwen/Qwen2.5-0.5B-Instruct completed three tasks at concurrency 1 and again at concurrency 3. All rewards were 1.0; the run with full observation capture had 3/3 healthy rollouts. Inspected generated token IDs/log probabilities, response IDs, trajectories, and captured model calls.
  • A separate live-HTTP check using deterministic model replies and Gym's stateful counter resources server completed 32 concurrent, isolated sessions with two model turns and a tool call each. Checked wire equivalence, extras, trajectories, skipped verification, and error propagation. Malformed verify payloads still return HTTP 422 at resources ingress.

Focused benchmark

A local benchmark compared payload construction and a real ServerClient HTTP hop to a typed resources server in a separate process. Decoded request bodies were equal in all three cases; object-key order was ignored. Each HTTP request was checked against the fingerprint of its expected wire body. The benchmark script is kept locally and is not included in this PR.

Local run with 128 requests per variant/concurrency (1 and 32):

Payload Construction CPU/request, before → after Peak traced allocation, before → after
Small 23.34 → 3.70 µs 14,896 → 2,136 bytes
64K prompt and 64K generation token IDs 5,140.84 → 3.55 µs 3,160,240 → 2,136 bytes
Large verifier metadata 471.81 → 214.90 µs 801,486 → 395,454 bytes

The benchmark reports client CPU, retained allocation blocks, peak traced bytes, requests/s, and p50/p99 latency. Allocation sampling is separate from timing. The HTTP measurement includes construction, transport, resources validation, an echoed verify response, and final response validation; it excludes model inference and session seeding. The construction benchmark uses the old/new expressions; actual SimpleAgent.run behavior is covered separately by regression tests and live rollouts.

These are focused measurements on a shared local machine, not a general rollout-throughput claim. In this short run, 64K HTTP throughput changed from 19.77 to 23.96 requests/s at concurrency 1 and 32.52 to 32.93 at concurrency 32; small and large-metadata cases at concurrency 32 had lower throughput after the change.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format/copyright pass).
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

@copy-pr-bot

copy-pr-bot Bot commented Sep 13, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub

Copy link
Copy Markdown
Contributor

deduping - closing in favor of #3048

@ananthsub ananthsub closed this Sep 28, 2026
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.

Build simple_agent verification payloads without duplicate dump and validation passes

2 participants