Skip to content

feat: make torch an optional dependency for the batched simulator - #38

Merged
spencerfolk merged 3 commits into
spencerfolk:mainfrom
Tuxliri:feat/torch-optional-dep
Apr 22, 2026
Merged

feat: make torch an optional dependency for the batched simulator#38
spencerfolk merged 3 commits into
spencerfolk:mainfrom
Tuxliri:feat/torch-optional-dep

Conversation

@Tuxliri

@Tuxliri Tuxliri commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • torch>=1.11.0, torchdiffeq, roma, and opt-einsum moved out of
    core dependencies into a new batched optional extra in pyproject.toml
  • 11 files that mix batched and non-batched classes now wrap their top-level
    torch/roma/torchdiffeq imports in try/except ImportError: pass, so those
    modules remain importable without the extra installed
  • The all extra is updated to include the batched deps

Motivation

PyTorch (~2 GB) is only needed for the batched simulator. Users who only need
the standard single-drone simulate() workflow were forced to install it.
With this change:

pip install rotorpy            # standard simulator only
pip install rotorpy[batched]   # + batched simulator
pip install rotorpy[all]       # everything

Test plan

  • All non-batched imports (simulate, Multirotor, SE3Control, etc.)
    work without torch installed
  • All batched imports (simulate_batch, BatchedMultirotor, etc.)
    continue to work with rotorpy[batched]
  • 15/15 non-batched tests pass; 4 pre-existing failures unchanged

torch, torchdiffeq, roma, and opt-einsum are only required for the
batched simulator (BatchedMultirotor, simulate_batch, BatchedSE3Control,
etc.). Moving them to an optional extra avoids forcing all users to
install PyTorch (~2 GB) when they only need the standard single-drone
simulator.

- pyproject.toml: remove the four packages from core dependencies and
  add a new `batched` extra; also include them in `all`
- Wrap top-level torch/roma/torchdiffeq imports with try/except in
  every file that mixes batched and non-batched classes, so those
  modules remain importable without the extra installed

Install the batched simulator with: pip install rotorpy[batched]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Davide iafrate added 2 commits April 16, 2026 22:44
- Relax batched sim tolerance from 2e-2 to 5e-2 to account for
  numerical divergence between batched and sequential ODE integration
- Wrap filterpy imports in wind_ukf.py with try/except so the
  estimators module loads without the filter extra
- Skip example scripts in test_examples.py when they fail due to
  missing optional dependencies (ModuleNotFoundError/NameError)
The testing workflow runs `pip install -e .[testing]`, which no longer
includes torch/torchdiffeq/roma/opt-einsum after they were moved to the
batched extra. Add them to the testing extra so test_batched_sims and
test_gymenv can run in CI.
@Tuxliri
Tuxliri marked this pull request as ready for review April 16, 2026 23:00
@spencerfolk
spencerfolk merged commit 550ffce into spencerfolk:main Apr 22, 2026
7 of 8 checks passed
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.

2 participants