policy-training-inference
Select, configure, train, evaluate, and safely plan inference for LeRobot policies, processors, devices, checkpoints, and optional PEFT adapters.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- policy-training-inference
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Select, configure, train, evaluate, and safely plan inference for LeRobot policies, processors, devices, checkpoints, and optional PEFT adapters.
- disable-model-invocation
- true
02 资源文件 10
- 参考文档references/api-reference.md5.2 KB
- 参考文档references/cli-reference.md3.7 KB
- 参考文档references/configuration.md5.3 KB
- 参考文档references/model-overview.md4.2 KB
- 参考文档references/troubleshooting.md6.6 KB
- 参考文档references/workflows.md5.4 KB
- 脚本scripts/check_policy_environment.py6.8 KB
- 脚本scripts/eval_command_builder.py3.1 KB
- 脚本scripts/rollout_help.py2.7 KB
- 脚本scripts/train_command_builder.py5.1 KB
03 SKILL.md 正文
Policy training and inference
Use this sub-skill when the task names lerobot-train, lerobot-eval,
lerobot-rollout, a policy type or checkpoint, policy processors, CUDA/device
selection, PEFT, or rollout inference. This sub-skill covers model-side
configuration and safe command planning. Route dataset format, episode schema,
features, and statistics acquisition to dataset-workflows; route physical
robot/teleoperator operation and data collection to
robot-control-data-collection; route simulator installation, environment
configuration, and RL to simulation-and-rl.
Safety and operating boundary
- Treat training, Hub access, checkpoint downloads/uploads, W&B logging, and rollout as side effects. First inspect and validate; only execute after the user explicitly requests execution and all gates below pass.
- This skill can plan a rollout but does not authorize robot motion. Require a dry-run/help check, a bounded duration, a tested robot/camera/teleoperator handoff, an emergency stop, and a human at the controls before any hardware command.
- Never call a CPU import or CPU model construction proof a CUDA execution
proof. A requested
cudadevice must be checked withtorch.cuda.is_available()and the intended policy/dependencies must be importable. - Prefer local checkpoints with
local_files_onlyfor offline validation. Hub identifiers may trigger downloads when the real command runs; ask before that. - Do not invent a policy type. Confirm it is registered, its modeling module can be imported, and its scoped extra is installed.
Inputs and outputs
Collect: LeRobot version, policy type or checkpoint, dataset/environment handoff, feature keys/shapes, normalization statistics source, device/backend and VRAM, training or evaluation budget, output directory, resume source, optional PEFT settings, credentials/Hub consent, and whether real hardware is involved.
Produce one of:
- a validated, bounded training command plan and expected checkpoint layout;
- an evaluation plan with checkpoint, environment, episode, recording, and device gates; or
- a rollout plan that remains explicitly blocked until hardware safety gates pass.
Record unknown feature/stat/processor provenance as an unresolved validation item, not as a successful compatibility claim.
Fast routing workflow
- Choose policy. Start with
actfor a small/single-task baseline. Considerdiffusionfor action-distribution experiments;smolvla,pi0,pi05,pi0_fast, or other VLA policies only when the language/vision checkpoint, tokenizer, memory, and GPU budget are known. See model-overview.md. - Check the scoped extra. The base package supplies core policy machinery;
optional policies use extras such as
diffusion,pi,smolvla,groot,wallx,xvla,peft, ortraining. Missing dependencies must be fixed by the smallest relevant extra, notallby default. - Resolve the config. For a fresh policy, construct a registered config
with
make_policy_config(type, ...)and obtain input/output features from dataset metadata or an environment. For a checkpoint, load itsconfig.jsonthroughPreTrainedConfig.from_pretrained; preserve its type and processor contract unless a deliberate override is validated. - Build the model and processors.
make_policyrequires exactly one of dataset metadata or environment config. It infers action outputs and missing input features, validates visual consistency, places the model onconfig.device, and loads safetensors for a normal checkpoint. Build the matching pre/post pipelines withmake_pre_post_processors; for a checkpoint load the savedpolicy_preprocessor.jsonandpolicy_postprocessor.json. - Validate one synthetic batch. Confirm observation names, image channel/order
and shape, state/action dimensions, task/text fields, batch dimensions, finite
normalized values, model output shape, and postprocessed action shape before
launching a long run. Use
step_throughortransform_featuresto locate a processor mismatch. - Bound the run. Use a short smoke run first (
stepssmall, no Hub push, W&B disabled, fixed output directory). Then choose checkpoint frequency, evaluation split/episodes, workers, accumulation, mixed precision, and output policy. Do not reuse a non-empty output directory unlessresume=true. - Handoff. Dataset and simulator owners must confirm their contracts. A
real-robot owner must confirm robot, camera, teleop, calibration, and stop
controls before
lerobot-rolloutis considered runnable.
CLI decision points
lerobot-trainuses dotted draccus fields:--dataset.repo_id,--policy.type,--policy.device,--batch_size,--steps,--output_dir,--save_freq,--eval_steps,--parallelism.*,--accelerator.*,--peft.*, and--resume/--config_path.- For a pretrained policy, use
--policy.path=<local-dir-or-hub-id>in the current CLI contract. For a resume, use--resume=true --config_path=<checkpoint train_config.json, pretrained_model directory, or permitted Hub run source>. Do not confuse fine-tuning from--policy.pathwith restoring optimizer/RNG/ sampler state via--resume. lerobot-evalneeds--policy.path,--env.type, and bounded--eval.n_episodes;--eval.batch_size=1is the conservative first check. Recording is off unless explicitly enabled. Hub environments additionally require--trust_remote_code=trueconsent.lerobot-rolloutis the deployment engine.strategy.type=basedoes not record and must not receive a dataset; sentry/highlight/dagger/episodic need the appropriate recording dataset, and dagger needs a teleoperator.syncworks for all policies;rtcis for supported slow chunking policies and requires policy-specific queue/horizon validation.- Run the bundled probes/builders before copying a command into a shell: check_policy_environment.py, train_command_builder.py, eval_command_builder.py, and rollout_help.py. They print commands and checks but never start training, inference, downloads, simulators, or hardware.
Training and checkpoint rules
TrainPipelineConfig.validate() requires a policy or reward model, disallows
an existing output directory for a fresh run, applies the policy optimizer and
scheduler presets by default, and requires a nonzero dataset eval_split when
eval_steps > 0. A normal checkpoint contains a policy config and
model.safetensors; processor JSON/state files must accompany it for faithful
inference. Training checkpoints also contain train_config.json and training
state. Safetensors is the compatible default; DCP model artifacts require a
sharded run. Sharded training currently rejects PEFT, fp16, in-training env
rollouts, reward-model training, multiple optimizers, compile/activation
checkpointing placeholders, and context parallelism greater than one.
PreTrainedPolicy.from_pretrained puts the policy in eval mode; call
train() only for training. The base contract requires get_optim_params,
reset, forward, predict_action_chunk, and select_action. forward
returns (loss, logging_dict_or_none); inference calls reset() at episode
start and select_action() after preprocessing. Keep logging values native and
avoid passing gradient-bearing tensors into logs.
Final validation checklist
python -m ... --help/CLI help succeeds in the target environment.check_policy_environment.pyreports the registered choice, optional package status, policy class import, requested device, CUDA availability, and any import failure without claiming execution readiness when a gate is missing.- The exact checkpoint has
config.json, weights, and matching pre/postprocessor files; revision and local-only policy are explicit. - Dataset/environment feature names are mapped deliberately;
rename_mapis used only when the checkpoint contract requires it, and normalization stats are from the intended dataset or an explicitly approved override. - One bounded batch passes through preprocessor → policy → postprocessor with finite tensors and the expected action dimension.
- Training has a new/approved output directory, bounded steps, checkpoint policy, no unintended Hub/W&B side effects, and a resume source if applicable.
- Evaluation has bounded episodes and recording disabled unless requested.
- Rollout has hardware/safety approval, finite duration, correct device, tested
cameras, and emergency-stop readiness. Otherwise report
blocked, not ready.
Bundled reference map
- model-overview.md: registered policy catalog, scoped extras, and conditional selection guidance.
- configuration.md: config dataclasses, dotted fields, feature/device construction, and distributed restrictions.
- api-reference.md: verified factory, policy, processor, serialization, normalization, and device signatures.
- workflows.md: bounded training, resume, eval, PEFT, and rollout planning recipes.
- cli-reference.md: safe train/eval/rollout CLI fields and side-effect gates.
- troubleshooting.md: dependency, checkpoint, device, training, evaluation, and rollout recovery.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).