Imitation learning

This guide collects demonstrations from an RL expert, trains ACT, and evaluates the resulting policy on regular_insert with sb3/default. DP, RDP, ViTacFormer, and π0.5 follow the same steps, with their own data conversion and training code.

Before you start

Have these ready:

  • The CPU/SB3 environment and a compatible, trained RL expert checkpoint.

  • The ACT environment.

  • External data and output directories, exported in each terminal.

  • A working renderer for front and wrist camera observations.

Use the same task, backend, and profile at every step. The expert run, dataset, and IL checkpoint each record these settings in a manifest, which is checked when they are loaded.

1. Collect demonstrations

For exploratory demonstrations, train the expert with perturbed target-pose observations so that it learns to probe and correct errors using force feedback. The collector runs that expert and keeps complete successful episodes, including the corrections.

To compare direct and exploratory demonstrations, train separate experts with the intended observation perturbations and keep their datasets separate. See exploratory demonstrations for fixed-bias and per-step-noise settings. The default profile below illustrates the workflow; choose matched experiment profiles for a paper comparison.

bash collect_data.sh regular_insert sb3/default 0 \
  --checkpoint /absolute/path/to/compatible/expert.zip

The third positional argument is the GPU/render-device selection. The launcher reads the expert manifest to select the CPU or MJLab environment. Override CPU_CONDA_ENV or GPU_CONDA_ENV if your environments have different names.

The default collection configuration requests 300 successful episodes and records front/wrist RGB, time-aligned observations, actions and episode metadata. Before launching, review config/benchmark/collect.yaml, especially num_workers and egl_device_ids; select device IDs that exist on your machine.

For a custom collection configuration, use the Python entrypoint in the matching simulation environment:

python -m script.collect_data \
  --config /absolute/path/to/collect.yaml \
  --task regular_insert --profile sb3/default \
  --checkpoint /absolute/path/to/compatible/expert.zip

Raw episodes for this example live under <data root>/regular_insert/sb3/default/. Collection can resume the configured dataset. Use a trained expert with suitable performance before requesting a large successful-episode count.

2. Convert for ACT

bash policy/ACT/process_data.sh regular_insert sb3/default 300

Conversion reads the raw episodes and writes ACT’s processed dataset without changing the source data. The episode-count argument identifies the workflow’s processed-data path; ensure the intended episodes have actually been collected.

Append --validate-config to inspect the configuration without converting data. It does not verify that a dataset has been collected.

3. Train and package

bash policy/ACT/train.sh regular_insert sb3/default 300 42 0

The arguments are task, backend/profile, episode count, training seed, GPU ID. The ACT wrapper defaults to finest-act; use CONDA_ENV to select a different environment. Review policy/ACT/configs/train.yaml for the training budget, device, pretrained backbone and experiment logging settings before a full run.

Training saves the native weights and packages the last checkpoint with policy_manifest.json. Use that packaged directory to start the server; loading checks the files, input fields, action format, and task settings.

For this example, the locations are:

Artifact

Path relative to its root

Raw demonstrations

<data root>/regular_insert/sb3/default/

ACT conversion

<data root>/processed/ACT/regular_insert/sb3/default/300/

ACT training run

<output root>/policy/ACT/regular_insert/sb3/default/300/42/run/

For a native checkpoint such as <run>/checkpoints/step_000100000.ckpt, training creates the service package at <run>/step_000100000/. Pass this directory to the server and check that it contains policy_manifest.json.

Add --resume to the training command to continue a compatible existing run.

4. Start the policy service

In one terminal:

bash policy/ACT/serve_policy.sh \
  --checkpoint /absolute/path/to/packaged/checkpoint --gpu-id 0

ACT’s default service listens on 127.0.0.1:10093. Its deployment configuration is policy/ACT/deploy_policy.yaml. The service manages action chunks, temporal execution, and recurrent or reactive state; the evaluator receives one selected action per control step.

5. Evaluate in a second terminal

CONDA_ENV=finest bash eval_policy.sh \
  regular_insert sb3/default 200000 --check-server

CONDA_ENV=finest bash eval_policy.sh \
  regular_insert sb3/default 200000

200000 is the starting evaluation seed. The first command checks the connection and protocol handshake. The second runs evaluation, including task/profile/asset compatibility checks, and writes the report. See evaluation for output files and metric definitions.

When using an MJLab profile, select CONDA_ENV=finest-mjlab for the evaluator. The policy service can remain in its own environment.

Use another policy

Each policy has conversion, training and serving instructions in its component README under policy/. The task and profile stay the same, while data preparation and inference differ:

Adapter

Main distinction

ACT

Action chunks with service-side execution

DP

Diffusion-policy data conversion and inference

RDP

Latent diffusion with reactive decoding in the service

ViTacFormer

Dual RGB, Cartesian proprioception and a wrist force/torque proxy by default

π0.5

Dual RGB plus task prompt; compatible external base weights for fine-tuning

ViTacFormer’s force branch uses processed wrist wrench, not tactile images. Disabling model.use_force retains proprioception. π0.5 receives neither proprioception nor wrist wrench.

Modes and action semantics

insert_only is the standard mode. For experimental grasp_then_insert, select a profile that explicitly declares that mode; it is part of the checkpoint identity. Its grasp planner uses privileged simulator poses and geometry.

The five IL adapters use seven action values in both modes: six Cartesian pose increments and an absolute gripper width in metres. Native insertion RL experts use six pose increments; collection adds the recorded gripper width. Preserve these semantics during conversion and serving rather than padding or truncating actions.

See supported features for task coverage and test results for completed checks. Train and evaluate each checkpoint on its matching task.