Skip to content

nav: the GPU drive applies material, terrain, slope and lam policies, with telemetry and Python - #786

Merged
transfix merged 2 commits into
masterfrom
feat/nav-gpu-material-parity
Oct 24, 2026
Merged

transfix merged 2 commits into
masterfrom
feat/nav-gpu-material-parity

Conversation

@transfix

@transfix transfix commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Follows #785 (merged): the risk column reads terrain risk as material risk, as #785 makes the CPU drive do.

What

drive_step_cuda refused any net with risk or slope look-ahead columns or lam heads, because the fused kernel was geometry-only. The GPU drive now mirrors the CPU drive:

  • Material: a device sampler for the 6-channel material_stack (material_sample_point), and the soft and hard material force (F = -lam_soft grad r - lam_hard db grad phi) into F and the steering bias.
  • Columns: coef_feats' risk column (the worse of material risk and the terrain's grade cost at each probe) and slope column, in the CPU's column order.
  • Lam heads: the two-head sigmoid columns in the device MLP; a lam-head net's lam_soft / lam_hard (times lam_soft_scale / lam_hard_scale) replace the fixed columns.
  • Terrain: veh_params::terrain (grade force, infeasible-slope barrier) and the slope governors (veh_params::slope), in the fused and the unfused (bicycle_rollout_cuda) kernels.
  • Telemetry: both GPU drives take the CPU drives' optional drive_telemetry * and fill it the same way, U_nav's terms included (mrisk = max(material, terrain)).
  • New entry point: drive_step_material_cuda, the GPU twin of drive_step_material.
  • Python: pycvc.nav_drive_step_material_cuda (the twin of nav_drive_step_material without map_id, with optional grip, terrain, slope, lam scales and telemetry=1) and pycvc.nav_drive_cuda_available(). New symbols; no existing signature changes.

Still refused, with messages saying so: the plant arm (veh_params::plant) on the GPU; risk/slope nets with nothing to read; a material drive with a null lam column for a net with no head for it; risk/slope nets in sim_world_cuda, which holds no material or terrain. The precise-math flags (-fmad=false, IEEE div/sqrt, no ftz) are unchanged.

Tests

  • nav_drive_cuda_parity_test (new, 9 cases): CUDA == CPU tick by tick with a material stack, a terrain, the slope governors, a risk net, a slope net, a v1 lam-head net and a two-head sigmoid net reading grip, risk and slope; every drive_telemetry field; the refusals (host-side, run without a device). Worst state difference 4.8e-7 and worst telemetry difference 2.5e-6 (relative) on an RTX 3050 Ti (sm_86), against 1e-5. Removing the terrain from the GPU risk probe fails the three risk cases.
  • test_pycvc_nav_cuda.py (new, 25 checks): the binding against nav_drive_step_material within 1e-5, telemetry, terrain, slope, refusals. Self-skips without CUDA or a device, so on the pycvc-linux lane (CUDA off) it only proves the binding compiles and imports.
  • DriveStepCudaRefusesRiskLamNet is removed: that net now runs.
  • Locally also green: nav_drive_refinements_test, nav_material_rollout_cuda_test, nav_material_deploy_test, nav_terrain_test, nav_test (NavSimWorldCuda).

CUDA parity is not a CI gate (CI has no GPU); the numbers above are from one sm_86 device.

drive_step_cuda refused any net with risk/slope look-ahead columns or lam
heads, because the fused kernel was geometry-only. It now mirrors the CPU
drive:

- a device material-stack sampler (material_sample_point's six channels)
  and the soft/hard material force, into F and the steering bias;
- coef_feats' risk column (the worse of material risk and the terrain's
  grade cost at each probe) and slope column, in the CPU's column order;
- the two-head sigmoid lam columns in the device MLP, and the learned
  lam_soft / lam_hard (times lam_soft_scale / lam_hard_scale) in place of
  the fixed columns;
- veh_params::terrain (grade force, infeasible-slope barrier) and the
  slope governors (veh_params::slope), in the fused and unfused kernels.

drive_step_material_cuda is the GPU twin of drive_step_material. The GPU
drive still refuses the plant arm (not ported); sim_world_cuda, which
holds no material or terrain, refuses risk and slope nets.

nav_drive_cuda_parity_test holds both entry points to the CPU drive tick
by tick (worst 4.8e-7 on sm_86 against a 1e-5 contract) with a material
stack, a terrain, a risk net, a slope net, a v1 lam-head net and a
two-head sigmoid net reading grip, risk and slope.
drive_step_cuda and drive_step_material_cuda take the optional
drive_telemetry the CPU drives take and fill it the same way: the
coefficients, the applied lams, mu, mrisk (the worse of material and
terrain risk; the terrain's alone, with its weights, without a material
stack), steer, curvature, clearance and binding, and U_nav with its terms
and the conservative force at the tick's start pose (nav_potential.h is
host and device). The parity test compares every field (worst relative
2.5e-6 on sm_86).

pycvc.nav_drive_step_material_cuda is nav_drive_step_material's twin on
the GPU, without map_id (the GPU drive reads plane 0), with optional grip,
terrain, slope, lam authority scales and telemetry (a dict of (N,) arrays);
mat_field None runs drive_step_cuda. A refusal from the drive is caught
with the GIL released and raised once it is back.
pycvc.nav_drive_cuda_available() reports a device. test_pycvc_nav_cuda.py
checks the binding against the CPU binding and self-skips without CUDA.
@transfix
transfix force-pushed the feat/nav-gpu-material-parity branch from 7d7d2be to 4e7f0e0 Compare October 24, 2026 05:03
@transfix
transfix changed the base branch from feat/nav-soft-slopes to master October 24, 2026 05:03
@transfix transfix closed this Oct 24, 2026
@transfix transfix reopened this Oct 24, 2026
@transfix
transfix enabled auto-merge (squash) October 24, 2026 15:49
@transfix
transfix merged commit 7c09f1d into master Oct 24, 2026
30 of 32 checks passed
transfix added a commit that referenced this pull request Oct 24, 2026
Carries the master merge (#779 squash, #786, #787) up the H1 stack.
@transfix
transfix deleted the feat/nav-gpu-material-parity branch October 29, 2026 20:52
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