Skip to content

NablaEngine 1.0.5

Latest

Choose a tag to compare

@OamIcs OamIcs released this 29 Nov 06:59
· 3 commits to main since this release

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_ffi runs the engine on the Mac's GPU with CPU tensors, selected automatically
    (DK_BACKEND=cuda|metal overrides); 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.check checks 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 with mx.grad / mx.vjp in qpos, qvel, ctrl) and forward,
    bitwise torch_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.kinematics and torch_ffi.step / forward / backward with
    kinematics ran those kernels anyway (wrong outputs, non-finite gradients). They now use
    nablaengine.dyn_query's kinematics, as jax_ffi does; an entry that cannot raises ValueError.
    nablaengine.dyn_query now takes PhysicsParams body_inertial. With per-world masses, a subtree lighter than
    mjMINVAL takes its body's COM as subtree_com (as MuJoCo) instead of NaN.
  • Fix: the PhysicsParams fields foot_offset and sole_thickness together 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_ENGINE selects.
  • Per-world actuator gains on the forest engine: the PhysicsParams fields actuator_kp and actuator_kv (one
    value per actuator, PhysicsParams(..., nu=model.nu)) set each position servo's kp and kv, as MuJoCo with
    gainprm / biasprm changed, 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=1 builds 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=1 also builds for models with mesh pairs (it raised ValueError): k_pre collides 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_JOBS still sets the count. A build killed by the system names
    DK_BUILD_JOBS in its error.
  • Experimental: DK_FOREST_BAM_C2=1 runs 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=1 re-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=auto uses 2 on the forest engine for models without contacts between two moving
    bodies (the same gradients bitwise, a smaller adjoint), else 3. The default stays 3.
  • 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=recip emits it with reciprocal pivots. Off by default.
  • Fix: scripts/orin/smoke.py runs from the public tree (it imported a script that is not included).
  • Docs: any nonzero normal also 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_terrain and the ray sensors default to this process's GPUs, so one process per GPU with
    jax.distributed works.
  • Fix: warp synchronisation at the entry of the tree-sparse Cholesky factor and solve (DK_FOREST_TREE_CHOL; a
    latent race, results unchanged).