Skip to content

runtime: make rollout seeds selectable and reproducible via RolloutSpec - #149

Merged
mwatson-nvidia merged 1 commit into
NVlabs:mainfrom
amtellezfernandez:pr/rollout-seed
Aug 17, 2026
Merged

runtime: make rollout seeds selectable and reproducible via RolloutSpec#149
mwatson-nvidia merged 1 commit into
NVlabs:mainfrom
amtellezfernandez:pr/rollout-seed

Conversation

@amtellezfernandez

Copy link
Copy Markdown
Contributor

Follow-up to #128.

force_determinism and the inference_seed hookup (session.seed + session.inference_count) have shipped since that discussion, so per-inference seeds already derive deterministically from the session seed. What was still missing is choosing or recovering the session seed itself: driver_service.py and traffic_service.py draw it from random.randint at session creation, and RolloutSpec has no seed field, so no rollout can be re-run.

This adds fixed64 random_seed = 5; to RolloutSpec, with 0 (default) meaning the runtime picks a random seed per session, the same convention start_time_offset_us already uses in that message. Rollout k of a spec gets random_seed + k as its session seed, mirroring the additive derivation inference_seed already uses, so a single rollout is reproducible on its own. Existing callers see no change.

The value travels the exact path start_time_offset_us takes: RolloutSpec to PendingRolloutJob to AssignedRolloutJob to UnboundRollout to the session configs to the session request. Both services fall back to random.randint when it's unset.

Out of scope on purpose: making trafficsim consume its seed. Today request.random_seed only appears in a log line (trafficsim/grpc/servicer.py:213), and how much reproducibility is realistically achievable there needs its own discussion. The video-model renderer path also has its own sampling, so this is about re-running a rollout and getting the same policy behaviour, not bit-exact replay, which matches the NuRec caveat in #128 anyway.

Tests: seed derivation and the unset default in test_daemon_request_plumbing.py; both services honouring a configured seed, plus the random fallback, in tests/services/. Targeted suites pass 30/30, and the full runtime suite is unaffected beyond failures that reproduce identically without this change.

@copy-pr-bot

copy-pr-bot Bot commented Aug 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.

Follow-up to NVlabs#128. force_determinism and the inference_seed hookup
(session.seed + inference_count) shipped since that discussion, so
per-inference seeds already derive deterministically from the session
seed. What was still missing is choosing or recovering the session seed
itself: driver_service.py and traffic_service.py draw it from
random.randint at session creation and RolloutSpec has no seed field,
so no rollout can be re-run.

Add RolloutSpec.random_seed (fixed64, field 5), following the same
0-means-default convention start_time_offset_us already uses in that
message. Rollout k of a spec gets random_seed + k as its session seed,
mirroring the additive derivation the driver already uses for
inference_seed, so any individual rollout is reproducible on its own.
0 keeps today's behaviour: every service picks a random seed.

The seed travels the exact path start_time_offset_us takes:
RolloutSpec -> PendingRolloutJob -> AssignedRolloutJob ->
UnboundRollout -> Driver/TrafficSessionConfig -> the session request.
Both services fall back to random.randint when no seed is supplied.
The traffic service currently only logs its seed downstream; wiring
trafficsim to consume it is deliberately out of scope here.

Tests: seed derivation and the unset default in
test_daemon_request_plumbing.py; both services honouring a configured
seed (and the random fallback) in tests/services. Targeted suites pass
30/30; the full runtime suite passes except three test_with_mocks
failures that reproduce identically with pristine sources under the
same containerized proto-regeneration harness, i.e. a harness artifact,
plus the pre-existing test_route_generator_map failure.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mwatson-nvidia

Copy link
Copy Markdown
Collaborator

/ok to test c5f5d6b

@mwatson-nvidia
mwatson-nvidia merged commit 9a3832b into NVlabs:main Aug 17, 2026
19 checks passed
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