Skip to content

nav: per-agent physics on the CUDA drive (device twin of #395) - #396

Merged
transfix merged 1 commit into
masterfrom
feat/nav-stats-per-agent-cuda
Sep 22, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/nav-stats-per-agent-cuda

Conversation

@transfix

Copy link
Copy Markdown
Owner

Wires the per-agent physics columns (rr/body_rr/vmax/a_max/L) into the GPU drive, so a heterogeneous fleet runs on CUDA too and matches the CPU rollout. Device twin of #395 (which did the CPU path).

What

  • dev_veh gains the 5 borrowed device column pointers; null = the scalar, so the homogeneous path is bit-for-bit the legacy kernel. Mass isn't here — the kinematic drive never reads it.
  • d_veh_for(v, i) substitutes the columns into a per-thread copy before d_bicycle, so every use site (incl. the L-derived dmax/tan_dmax/v_creep_cap and vmax-derived sp_min) becomes per-agent with no change to d_bicycle — the device mirror of the CPU loop's shadowing.
  • upload_cols copies each set host column to the device in both batch entry points (bicycle_rollout_cuda / drive_step_cuda) and frees them. The persistent sim_world_cuda path keeps the scalar for now (a follow-up).

Validation

  • New test CudaMatchesCpuWithPerAgentColumns: a heterogeneous fleet (distinct rr/vmax/a_max/L per agent) matches the CPU bicycle_rollout within the ~1e-5 float-equivalence contract. Verified on a GTX 1650 — both this and the existing scalar-path CUDA parity test pass.
  • The null-column path leaves the existing CPU/CUDA parity gate byte-identical.

Small, additive; completes the per-agent physics set across CPU + CUDA. (CI ubuntu builds without a GPU and skips the CUDA test via GTEST_SKIP; it runs on a CUDA runner / dev box, as the other *_cuda tests do.)

Wire the per-agent columns (rr/body_rr/vmax/a_max/L) into the GPU drive so a
heterogeneous fleet runs on CUDA too, matching the CPU rollout.

- dev_veh gains the 5 borrowed device column pointers (null = the scalar, so the
  homogeneous path is bit-for-bit the legacy kernel). Mass is not here — the kinematic
  drive never reads it.
- d_veh_for(v, i) substitutes the columns into a per-thread copy before d_bicycle, so
  every use site (incl. the L-derived dmax/tan_dmax/v_creep_cap and the vmax-derived
  sp_min) becomes per-agent with no change to d_bicycle — the device mirror of the CPU
  loop's shadowing.
- upload_cols copies each set host column [n] to the device in both batch entry points
  (bicycle_rollout_cuda / drive_step_cuda) and frees them after. The persistent
  sim_world_cuda path keeps the scalar for now (a follow-up).

Test: nav_drive_refinements_test CudaMatchesCpuWithPerAgentColumns — a heterogeneous
fleet (distinct rr/vmax/a_max/L per agent) matches the CPU bicycle_rollout within the
~1e-5 float-equivalence contract. Verified on a GTX 1650 (both this and the existing
scalar-path CUDA parity test pass); the null-column path leaves the CPU/CUDA parity gate
byte-identical.
@transfix
transfix merged commit 7bb1abd into master Sep 22, 2026
13 checks passed
@transfix
transfix deleted the feat/nav-stats-per-agent-cuda branch September 22, 2026 09:04
transfix added a commit that referenced this pull request Sep 22, 2026
Gap-analysis cleanup over the just-landed base (#394-#397). Correctness + doc-accuracy
+ test coverage in one module; no behavior change to the drive.

- Sentinel leak (major): min_clearance_m and min_sep_m sit at the 1e30 "unmeasured"
  sentinel until a sampler / second vehicle lowers them; num() only nulls non-finite, so
  the base JSON record emitted "min_clearance_m":1e+30 — read by a trainer as *enormous*
  clearance, the inverse of "missing". Add a num_sentinel() helper that nulls >=1e29 and
  apply it to both fields in episode_nav_stats::to_json() (aggregate_nav already guarded
  min_sep_m; the per-episode record now matches).
- Unit contract (major, root of the cvcdbg #113 bug): document nav_samplers.min_clearance_m
  as METRES and that sim_world::min_clearance() is NORMALIZED, so the caller must convert
  (/cfg.scale) before pointing it here.
- Stale comments (minor): drive.h still said the CUDA twin ignores the per-agent columns;
  #396 wired rr/body_rr/vmax/a_max/L into the batch CUDA entry points. Correct both blocks
  (only the persistent sim_world_cuda path still scalars; mass stays CPU/downstream-only).
- Mirror comment (minor): the header claimed field-parity with grl_snam.metrics.NavStats
  "pinned in cross-language parity tests" — neither true (veh_nav_stats is a superset; the
  match is grl_snam.scorecard, and parity is held by independent hand-computed corpora, not
  a gate). Correct it.
- Tests: SentinelFieldsSerializeAsNull (the sentinel->null fix); BudgetEtaAndFuelBounds
  (the eta_multiple + fuel_budget bounds, previously only time_budget_s was exercised); and
  ScriptedTrajectoryAccumulators now calls e.to_json() to pin the base record shape +
  goals_reached. 5/5 pass locally.
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