Summary
Currently all numerical computation in the project (EKF-SLAM, particle filter gas-source estimation, gas distribution map, linear consensus, wind/gas dispersion model) runs on NumPy/SciPy, i.e. CPU-only. Several of these components — especially the per-robot particle filter (large particle counts, repeated likelihood evaluation) and the gas distribution map (grid-based accumulation) — are good candidates for GPU acceleration via CuPy, which mirrors the NumPy API almost 1:1.
Motivation
- Particle filter and GDM updates run per-robot, per-timestep, and scale with particle count / grid resolution — a natural fit for GPU parallelism.
- CuPy is (mostly) a drop-in replacement for NumPy, minimizing the amount of code that needs to be rewritten.
- With multiple robots simulated concurrently (and MPI-based V2V communication via
mpi4py), offloading the heaviest array ops to GPU could meaningfully cut simulation wall-clock time.
Proposed Scope
Proposed Approach
- Add
cupy as an optional dependency in requirements.txt (CUDA-version-specific wheel, e.g. cupy-cuda12x), guarded so CPU-only installs still work.
- Introduce a thin array-module abstraction (e.g.
xp = cupy if GPU_ENABLED else numpy, or use cupy.get_array_module) so code paths stay agnostic and testable on machines without a GPU.
- Start with the particle filter and GDM (highest particle/grid-size, most parallelizable), benchmark before/after.
- Handle host↔device transfers carefully at module boundaries (e.g. before Matplotlib rendering in
viz/, before MPI sends in V2V communication, since mpi4py needs host — or CUDA-aware MPI — buffers).
- Add a config flag (e.g. in
config/) to toggle GPU usage on/off at runtime.
Acceptance Criteria
Summary
Currently all numerical computation in the project (EKF-SLAM, particle filter gas-source estimation, gas distribution map, linear consensus, wind/gas dispersion model) runs on NumPy/SciPy, i.e. CPU-only. Several of these components — especially the per-robot particle filter (large particle counts, repeated likelihood evaluation) and the gas distribution map (grid-based accumulation) — are good candidates for GPU acceleration via CuPy, which mirrors the NumPy API almost 1:1.
Motivation
mpi4py), offloading the heaviest array ops to GPU could meaningfully cut simulation wall-clock time.Proposed Scope
estimation/— EKF-SLAM (prediction/update, occupancy grid log-odds updates)estimation/— Particle filter gas-source estimation (likelihood evaluation, resampling)estimation/— Gas Distribution Map (coverage map, weighted-readings map)estimation/— Linear consensus (information-form updates)sim/— Wind model / LBM-based gas dispersion (evaluate whetherpylbminternals can be bypassed or complemented with CuPy arrays)controllers/— APF navigation/formation control math (lower priority, likely small vectors)viz/— leave on CPU/NumPy (rendering needs host memory anyway)Proposed Approach
cupyas an optional dependency inrequirements.txt(CUDA-version-specific wheel, e.g.cupy-cuda12x), guarded so CPU-only installs still work.xp = cupy if GPU_ENABLED else numpy, or usecupy.get_array_module) so code paths stay agnostic and testable on machines without a GPU.viz/, before MPI sends in V2V communication, sincempi4pyneeds host — or CUDA-aware MPI — buffers).config/) to toggle GPU usage on/off at runtime.Acceptance Criteria
requirements.txt/ installation docs updated with CUDA/CuPy setup instructions.test/pass on both code paths.