(WIP) Fix silent agent attrition when spawn positions can't fit goals - #531
Open
eugenevinitsky wants to merge 1 commit into
Open
(WIP) Fix silent agent attrition when spawn positions can't fit goals#531eugenevinitsky wants to merge 1 commit into
eugenevinitsky wants to merge 1 commit into
Conversation
eugenevinitsky
force-pushed
the
ev/spawn-goal-retry
branch
from
July 21, 2026 19:56
dfc2704 to
ed70af4
Compare
eugenevinitsky
force-pushed
the
ev/spawn-goal-retry
branch
from
July 21, 2026 21:36
ed70af4 to
488e968
Compare
On small maps (e.g. nuPlan bins), goal generation regularly fails for spawn positions on short or dead-end lanes. spawn_agent computed the route and goals only after the position rejection loop had accepted a position, so such failures were never resampled: agents were silently excluded from the batch at env creation (8/32 on the nuplan test map) and left as permanently removed, terminal-masked slots after every episode reset (8/24). The init-time goal re-roll could additionally strand a removed agent inside the active set. - spawn_agent: move state commit + route + goal generation inside the rejection loop, so a position whose routes can't hold the goals is rejected and resampled like a collision. - generate_new_goals_from_route: return failure without mutating removal state; every caller now decides explicitly (resample at spawn, remove with a warning at replay init/reset and mid-episode regen). - init: skip the redundant goal re-roll for gigaflow agents, which already received goals inside spawn_agent. - test_drive_env_smoke: assert gigaflow spawns every requested agent and that no active agent is ever removed. Fails with "active_agent_count == 24, expected 32" before this fix. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
eugenevinitsky
force-pushed
the
ev/spawn-goal-retry
branch
from
July 22, 2026 15:20
488e968 to
ded51ba
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.
What
Fixes gigaflow spawn silently dropping agents whose sampled position can't fit a route + goals, and adds tests that fail on any agent attrition.
spawn_agent: the state commit, route computation, and goal generation now live inside the position rejection loop — a position on short/dead-end lanes is rejected and resampled exactly like a colliding or offroad one. This extends the same retry principle the map goal source already uses (generate_new_goals_from_map's fresh-cell retry, covered bytest_map_goal_source_no_attrition).generate_new_goals_from_route: returns failure without invalidating/removing the agent; each caller now handles failure explicitly (resample at spawn, remove with a warning at replay init/reset, remove at mid-episode regen as before).spawn_agent); the re-roll could fail and strand aremoved=1agent inside the active set.test_drive_goals: newtest_route_goal_source_no_attrition— on the nuPlan map, all 32 requested agents must spawn live with full goal sets, both at env creation and through the episode-boundary respawn path. Also updates thetest_route_goals_full_set_or_removedcontract comment to the new caller-owns-removal semantics.test_drive_env_smoke: asserts gigaflow spawns every requested agent and that no active agent is everremoved(checked after creation and at every step, which covers the mid-run episode reset).Why
On the nuPlan test map, 8 of 32 requested agents were silently dropped at env creation (25% batch shrinkage), one agent sat in the active set already removed with re-rolled goals, and after the first episode reset 8 of 24 active agents (33%) spent the whole episode as dead, terminal-masked observation slots. The only traces were
[GIGAFLOW ERROR]printfs — no test failed and no metric moved. The failures are position-specific (nuPlan bins are cropped scenario-local maps whose lane graph dead-ends at the crop boundary), so resampling fixes them: with this change all 32 agents spawn and survive on the same map/seed.Notes
active_agent_count == 24, expected 32(verified against the unfixed header); after it, the full C suite and the Python unit tests (81 passed) are green, and the[GIGAFLOW WARNING/ERROR]spam in the smoke test output is gone.spawn_agent); its total-failure paths keep the previous remove-the-agent semantics, now with explicit call-site handling and a single warning.🤖 Generated with Claude Code