Repository navigation
NablaEngine 1.0.5: the PyTorch and MLX interfaces on Apple GPUs (Metal, experimental), per-world actuator gains on the forest engine, and fixes. Install: pip install nablaengine; on an Apple silicon Mac, pip install "nablaengine[torch,dmc]" or "nablaengine[mlx]".
- Experimental: the PyTorch interface on Apple GPUs (Metal). On macOS 14 or later on arm64,
nablaengine.torch_ffiruns the engine on the Mac's GPU with CPU tensors, selected automatically
(DK_BACKEND=cuda|metaloverrides); the engine's source is translated to Metal and compiled on first use, no CUDA
toolkit or Xcode needed (the Command Line Tools are).python -m nablaengine.metal.checkchecks an installation
against MuJoCo C. On an M4 Pro, the G1 at 4096 worlds: 138k env-steps/s forward, 103k forward + backward. The JAX
interface stays CUDA only.docs/api_torch.md, "Apple GPUs (Metal)". - Experimental:
nablaengine.mlx_ffi, the engine's step on MLX arrays on Apple GPUs (pip install "nablaengine[mlx]",
no PyTorch):init,step(differentiable withmx.grad/mx.vjpinqpos,qvel,ctrl) andforward,
bitwisetorch_ffi's results on Metal. examples/train_bptt.py: a DMC policy learned by backpropagation through time, on either backend.- Fix: on forest models the library's kinematics kernels do not cover (several trees, free bodies other than body 1,
slides:info["kinematics_error"]),torch_ffi.kinematicsandtorch_ffi.step/forward/backwardwith
kinematics ran those kernels anyway (wrong outputs, non-finite gradients). They now use
nablaengine.dyn_query's kinematics, asjax_ffidoes; an entry that cannot raisesValueError.
nablaengine.dyn_querynow takesPhysicsParamsbody_inertial. With per-world masses, a subtree lighter than
mjMINVAL takes its body's COM assubtree_com(as MuJoCo) instead of NaN. - Fix: the
PhysicsParamsfieldsfoot_offsetandsole_thicknesstogether failed to build (RuntimeError). - Fix:
torch_ffi.init()without a model loaded the cached library of the default model even when$DK_ENGINE
selected the other engine; it now uses (or builds) the library of the engine$DK_ENGINEselects. - Per-world actuator gains on the forest engine: the
PhysicsParamsfieldsactuator_kpandactuator_kv(one
value per actuator,PhysicsParams(..., nu=model.nu)) set each position servo's kp and kv, as MuJoCo with
gainprm/biasprmchanged, with gradients. Against float64 MuJoCo C (a hand scene with saturated servos, the
G1), median relative error: forward 4.2e-7 / 5.4e-7, kp gradients 5.8e-7 / 1.8e-6, kv gradients 7.2e-7 / 2.7e-6. - Experimental:
DK_FOREST_FUSED=1builds the forest engine's FFI forward as one kernel per control step
(k_substep) instead of two kernels per substep, for small batches. RTX 3090, ms per control step: G1 0.45 ->
0.41 at 1 world, Allegro hand + cube 1.41 -> 1.25 at 64 worlds and 1.94 -> 1.62 at 256; slower from a few hundred
worlds on (G1 at 4096: 2.65 -> 8.60). Not bitwise with the default forward on every model (float32 rounding).
Refused with the tree engine,DK_FOREST_LATENCY=1, noslip and more than 64 dofs. Off by default. DK_FOREST_LATENCY=1also builds for models with mesh pairs (it raisedValueError):k_precollides them itself.
Revo3 hand + cube on a V100: forward -6% at 1 world, -31% at 16, -27% at 64; the same bits.- The FFI library build runs at most one nvcc job per 3 GB of available host memory by default (it used every
CPU, which could exhaust host memory);DK_BUILD_JOBSstill sets the count. A build killed by the system names
DK_BUILD_JOBSin its error. - Experimental:
DK_FOREST_BAM_C2=1runs the forest engine's BAM adjoint pass through M(q) as channel-2-only sweeps
(a faster backward). Off by default. - Experimental:
DK_FOREST_REUSE_SMALL=1re-uses the forest engine's Newton factor for models with at most 32
dofs (chol_solve_small), with results bitwise those without the re-use. Off by default. - Experimental:
DK_ADJ_STAGE=autouses2on the forest engine for models without contacts between two moving
bodies (the same gradients bitwise, a smaller adjoint), else3. The default stays3. - Experimental:
DK_FOREST_TREE_CHOL=mass|1, the tree-sparse Cholesky in the forest engine (one-tree models,
at most 64 dofs);DK_TREE_CHOL_EMIT=recipemits it with reciprocal pivots. Off by default. - Fix:
scripts/orin/smoke.pyruns from the public tree (it imported a script that is not included). - Docs: any nonzero
normalalso freezes near-parallel capsule-capsule contacts' segment parameters (docs/api.md). - The PyPI workflow also runs when a GitHub release is published.
- Cleanup of docstrings, comments and example output paths.
- Fix:
set_terrainand the ray sensors default to this process's GPUs, so one process per GPU with
jax.distributedworks. - Fix: warp synchronisation at the entry of the tree-sparse Cholesky factor and solve (
DK_FOREST_TREE_CHOL; a
latent race, results unchanged).