Skip to content

fix(train): pick the local training device instead of assuming cuda - #130

Open
nicolas-rabault wants to merge 1 commit into
mainfrom
fix/training-device
Open

nicolas-rabault wants to merge 1 commit into
mainfrom
fix/training-device

Conversation

@nicolas-rabault

Copy link
Copy Markdown
Member

Problem

Training defaulted policy.device to cuda, so every local run on a Mac logged Device 'cuda' is not available. Switching to 'mps'.

Fix

  • Local runs pass the device LeRobot's auto_select_torch_device picks (cuda, mps, xpu or cpu). Inference uses the same function in place of its own cuda/mps/cpu probe, so XPU hosts get XPU there too.
  • Accelerate ignores policy.device except to force the CPU (lerobot_train.py), so the Device select offers Auto and CPU only.
  • HF Jobs runs no longer send a device: submit_to_hf resets policy.device so the pod picks its own, and the select is hidden for that target.

Not fixed here

On HF Jobs the pod still logs Device 'None' is not available. Switching to 'cuda'. LeRobot stages policy.device = None for the pod and PreTrainedConfig.__post_init__ warns on None. That fix belongs in LeRobot: only warn when a requested device is unavailable.

Testing

  • pytest 268 passed, tsc shows only the 5 errors already on main, eslint clean on the changed files.
  • A 2-step local training on an Apple Silicon Mac: the warning before, --policy.device mps and no warning after.

Related: #30 and #32 (the opposite case: an NVIDIA GPU with a CPU-only torch).

Copilot AI balanced review requested due to automatic review settings October 7, 2026 14:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

馃煛 Changes recommended

HF Job resumes can retain a checkpoint鈥檚 CPU device and consequently ignore an available cloud GPU.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Updates training and inference to use LeRobot鈥檚 automatic device selection across CUDA, MPS, XPU, and CPU.

Changes:

  • Auto-selects devices for local training and inference.
  • Limits local device choices to Auto/CPU and hides them for HF Jobs.
  • Updates tests and the committed frontend bundle.
File Description
lelab/鈥媡rain.py Selects local devices and omits cloud device flags.
lelab/鈥媟ollout.py Uses LeRobot鈥檚 shared device selection.
frontend/鈥媠rc/鈥媝ages/鈥婽raining.tsx Removes the CUDA default.
frontend/鈥媠rc/鈥媍omponents/鈥媡raining/鈥媍onfig/鈥婣dvancedCard.tsx Adds Auto/CPU selection for local runs.
tests/鈥媡est_train.py Tests local and cloud device arguments.
tests/鈥媡est_rollout.py Removes obsolete detector tests.
frontend/鈥媎ist/鈥媔ndex.html References the rebuilt frontend bundle.

馃挕 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lelab/train.py
Comment on lines 156 to +158
is_cloud = job_target is not None and job_target.runner == "hf_cloud"
if not is_cloud:
cmd.extend(["--policy.device", request.policy_device or auto_select_torch_device().type])
TrainingRequest and the training form defaulted policy.device to "cuda",
so every local run on a Mac logged LeRobot's "Device 'cuda' is not
available. Switching to 'mps'." warning. Local runs now pass the device
LeRobot's auto_select_torch_device picks (cuda, mps, xpu or cpu), which
inference uses too in place of its own cuda/mps/cpu probe.

Accelerate ignores policy.device except to force the CPU, so the form
offers "Auto" and "CPU" only. HF Jobs runs no longer send a device:
submit_to_hf resets policy.device so the pod picks its own, and the form
hides the field for that target.
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