Skip to content

feat(newton): skeleton NewtonSimulation(SimEngine) + config + factory registration#99

Open
cagataycali wants to merge 2 commits intostrands-labs:mainfrom
cagataycali:feat/newton-backend-stub
Open

feat(newton): skeleton NewtonSimulation(SimEngine) + config + factory registration#99
cagataycali wants to merge 2 commits intostrands-labs:mainfrom
cagataycali:feat/newton-backend-stub

Conversation

@cagataycali
Copy link
Copy Markdown
Member

@cagataycali cagataycali commented Apr 21, 2026

Summary

Add Newton GPU simulation backend skeleton — the first PR in a 7-PR series to land the Newton/Warp physics engine as a SimEngine backend.

This PR adds only the foundation: the class skeleton, config dataclass, factory registration, and 81 tests. No GPU dependencies are imported at module level.

Depends on: #84 (SimEngine ABC) — this PR branches from feat/simulation-foundation.

What's Included

New files (5)

File LOC Purpose
simulation/newton/__init__.py 47 Lazy loading, no warp import at module level
simulation/newton/config.py 105 NewtonConfig dataclass — 7 solvers, 5 render backends, 3 broad-phase options
simulation/newton/simulation.py 412 NewtonSimulation(SimEngine) skeleton — all 12 ABC methods + Newton extensions
tests/simulation/newton/test_*.py 490 4 test files, 81 tests

Modified files (2)

File Delta Change
simulation/factory.py +16/-11 Register "newton" backend + aliases ("warp", "wp")
pyproject.toml +9/-0 Add [newton] extras, warp.*/newton.* in mypy ignore

Key Design Decisions

  1. Lazy imports: import strands_robots.simulation.newton does NOT trigger import warp or import newton. Heavy deps load only on first method call via _lazy_init().

  2. Factory kwargs → config: create_simulation("newton", num_envs=4096, solver="xpbd") flows kwargs directly to NewtonConfig.

  3. Fail-fast config validation: Invalid solver, render_backend, broad_phase, physics_dt, or num_envs raise ValueError immediately in __post_init__.

  4. All ABC methods stubbed: Each raises NotImplementedError with a clear message indicating which subsequent PR will implement it.

  5. Newton extensions as public methods: replicate(), run_diffsim(), solve_ik(), add_cloth(), etc. are NOT in the ABC — they're Newton-only capabilities.

  6. send_action() + step(n_steps): The ABC separates action buffering from physics stepping. send_action() buffers in _pending_actions, step() applies.

  7. reset_envs(env_ids): Newton extension beyond the ABC's reset() — enables selective per-env resets for RL training.

Tests (81 passed, 0 failures, 0.56s)

File Tests What it covers
test_config.py 30 Defaults, all 7 solvers, all render backends, all broad-phase options, invalid values, edge cases
test_factory.py 15 Registration, alias resolution (newton/warp/wp), create_simulation() round-trip, kwargs passthrough
test_lazy_import.py 4 Verify no warp/newton import at module level
test_simulation.py 32 Instantiation, context manager, cleanup idempotency, all 27 stub methods verified
✅ ruff check — 0 errors
✅ ruff format — all files formatted
✅ mypy — 0 issues in 3 source files
✅ pytest — 81 passed in 0.56s

7-PR Roadmap

  1. ✅ This PR — skeleton, config, factory, 81 tests
  2. World lifecycle + robot loading (create_world, destroy, reset, add_robot, procedural builders)
  3. Step / action / observation (step, send_action, get_observation, get_state)
  4. Object management + rendering (add/remove_object, render)
  5. Multi-env + soft bodies (replicate, add_cloth/cable/particles)
  6. Advanced features (run_diffsim, solve_ik, sensors, CUDA graphs)
  7. Documentation + examples

Ref: cagataycali/strands-gtc-nvidia#314 | Roadmap: #94


🤖 AI agent response. Strands Agents. Feedback welcome!

@cagataycali cagataycali moved this from Backlog to In review in Strands Labs - Robots Apr 21, 2026
@cagataycali cagataycali force-pushed the feat/newton-backend-stub branch from 7aa29dc to 4e218b5 Compare April 21, 2026 17:51
@cagataycali cagataycali changed the title feat(newton): stub NewtonSimulation(SimEngine) — config, registry, lazy-import feat(newton): skeleton NewtonSimulation(SimEngine) + config + factory registration Apr 21, 2026
@cagataycali
Copy link
Copy Markdown
Member Author

This is the canonical Newton-stub PR. Closed duplicates: #102, #104.

Tracking issue: #96 (feat(newton): NVIDIA Warp/Newton simulation backend)

cagataycali and others added 2 commits April 23, 2026 00:27
… registration

Add Newton GPU simulation backend stub that implements SimEngine ABC.
No GPU dependencies at import time — warp/newton are lazy-loaded.

New files:
- simulation/newton/__init__.py — lazy loading, no warp import
- simulation/newton/config.py — NewtonConfig dataclass (7 solvers)
- simulation/newton/simulation.py — NewtonSimulation(SimEngine) skeleton

Modified files:
- simulation/factory.py — register newton + aliases (warp, wp)
- pyproject.toml — add [newton] extras (warp-lang, newton-sim)

All 12 required SimEngine methods stubbed with NotImplementedError.
Newton-specific extensions (replicate, diffsim, IK, cloth, etc.) stubbed.
Factory kwargs flow through to NewtonConfig.

Tests: 81 passed (config validation, factory round-trip, lazy import,
ABC conformance, all stub methods verified).

Part 1 of 7-PR Newton backend series (issue #314).
Depends on PR strands-labs#84 (SimEngine ABC).
The [newton] extra references newton-sim which is not published on PyPI
yet. CI installs .[all,dev] which pulls all extras, causing pip to fail.

Keep the [newton] extra defined for future use but exclude it from the
[all] aggregate until newton-sim is published.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants