mix bb.add_nx_backend (bb v0.17.1)

Copy Markdown View Source

Configures an Nx backend for the project

BB uses Nx for kinematics and motion planning. Nx defaults to Nx.BinaryBackend — a pure-Elixir reference implementation that is fine for sanity checks but orders of magnitude slower than the native backends. This task prompts the user to pick a backend and applies the dep + config changes.

The config :nx, default_backend: … line is written to config/runtime.exs, not config/config.exs. BB performs compile-time tensor operations in its Spark transformer chain, and EXLA/Torchx aren't started during compilation — so a compile-time default crashes the robot module compile.

Skips itself entirely if :nx is already configured in runtime.exs or config.exs, or if :exla / :torchx is already declared in mix.exs.

Examples

# Interactive (prompts to choose a backend)
mix bb.add_nx_backend

# Non-interactive (defaults to exla)
mix bb.add_nx_backend --yes

# Explicit choice
mix bb.add_nx_backend --backend exla
mix bb.add_nx_backend --backend torchx
mix bb.add_nx_backend --backend binary

Options

  • --backend - One of exla, torchx, or binary. Skips the prompt.