Skip to content

test(sensors): share the lidar model between tests of a parameterization - #211

Merged
janickm merged 2 commits into
NVIDIA:mainfrom
janickm:dev/janickm/lidar-test-reuse
Oct 16, 2026
Merged

janickm merged 2 commits into
NVIDIA:mainfrom
janickm:dev/janickm/lidar-test-reuse

Conversation

@janickm

@janickm janickm commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Every test of the parameterized TestRowOffsetStructuredSpinningLidarModel classes created a new lidar model, so the angles to columns map (a KD-tree query over all elements, the most expensive part of these tests) was computed per test rather than per parameterization.

  • Create the model and the element grid once per test class (setUpClass).
  • test_model_parameters_roundtrip moves the model between devices, so it creates its own.
  • test_angles_to_columns_map_values reuses the map if it was already computed.

Stacked on #210 (single OpenMP thread for tests); only the last commit belongs to this PR.

Measurements

All 4 python versions of pytest_lidar in parallel, restricted to 16 cores, with OMP_NUM_THREADS=1: slowest target 82s -> 39s.

On CI (build-and-test, all 71 tests), compared to #210 alone:

#210 this PR
bazel test ... 120s 49s
slowest test 58s (pytest_lidar) 31s (pytest_lidar)
build-and-test job 7m37s 5m34s

Testing

  • All 123 lidar tests pass on CPU and GPU, python 3.8 / 3.11 / 3.12 / 3.13.
  • Mutating the shared model in one test (offsetting row_elevations_rad) makes the subsequent tests of that parameterization fail, so tests do not silently pass on stale shared state.
  • Sharding of the target was evaluated too: with OMP_NUM_THREADS=1 it brings no further gain (26s vs 23s for the lidar targets alone, at 4x the processes), so it is not included.

Bazel runs tests in parallel, and torch / numpy start one OpenMP / BLAS
thread per core in every test process, so the processes oversubscribe
the CPU. With the 4 python versions of the lidar test running at once on
16 cores, each run took ~390s instead of ~50s with a single thread, and
the full test suite took ~530s instead of ~175s.
Every test of the parameterized row-offset lidar model tests created a
new model, so the angles to columns map (a KD-tree query over all
elements, the most expensive part of these tests) was computed once per
test instead of once per parameterization. Create the model and the
element grid once per test class instead, and give the test that moves
the model between devices a model of its own.

This halves the run time of the lidar tests (82s -> 39s with all python
versions in parallel on 16 cores).
@janickm
janickm merged commit c490c63 into NVIDIA:main Oct 16, 2026
5 checks passed
@janickm
janickm deleted the dev/janickm/lidar-test-reuse branch October 16, 2026 20:03
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