Implementation:ARISE Initiative Robomimic FileUtils policy from checkpoint
| Knowledge Sources | |
|---|---|
| Domains | Robotics, Evaluation, Serialization |
| Last Updated | 2026-02-15 08:00 GMT |
Overview
Concrete tool for restoring a trained policy from a checkpoint file into a ready-to-use RolloutPolicy wrapper provided by the robomimic file utilities module.
Description
The policy_from_checkpoint function implements the full checkpoint restoration chain: load checkpoint dict, recover algorithm name and config, initialize observation utils, reconstruct the model architecture via algo_factory, deserialize weights, apply normalization stats, and wrap as RolloutPolicy. It accepts either a file path or a pre-loaded dictionary to avoid redundant disk reads.
Usage
Call this function at the start of evaluation scripts (run_trained_agent.py) or when deploying trained policies. The returned RolloutPolicy can be directly called with observations to produce actions.
Code Reference
Source Location
- Repository: robomimic
- File: robomimic/utils/file_utils.py
- Lines: L373-444
Signature
def policy_from_checkpoint(device=None, ckpt_path=None, ckpt_dict=None, verbose=False):
"""
Restores a trained policy from a checkpoint file or loaded model dictionary.
Args:
device (torch.device): if provided, put model on this device
ckpt_path (str): Path to checkpoint file. Only needed if not providing @ckpt_dict.
ckpt_dict (dict): Loaded model checkpoint dictionary. Only needed if not providing @ckpt_path.
verbose (bool): if True, include print statements
Returns:
model (RolloutPolicy): policy wrapper ready for rollouts
ckpt_dict (dict): loaded checkpoint dictionary
"""
Import
import robomimic.utils.file_utils as FileUtils
# Call as:
policy, ckpt_dict = FileUtils.policy_from_checkpoint(ckpt_path="model.pth")
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| device | torch.device | No | Compute device. Default: auto-detected from config |
| ckpt_path | str | No | Path to .pth checkpoint file (provide this or ckpt_dict) |
| ckpt_dict | dict | No | Pre-loaded checkpoint dictionary (provide this or ckpt_path) |
| verbose | bool | No | Print loading info. Default: False |
Outputs
| Name | Type | Description |
|---|---|---|
| model | RolloutPolicy | Ready-to-use policy wrapper with loaded weights, observation normalization, and action normalization |
| ckpt_dict | dict | Loaded checkpoint dictionary for reuse (e.g., by env_from_checkpoint) |
Usage Examples
Load and Evaluate Policy
import robomimic.utils.file_utils as FileUtils
import torch
# Load policy from checkpoint
policy, ckpt_dict = FileUtils.policy_from_checkpoint(
ckpt_path="/path/to/model_epoch_100.pth",
device=torch.device("cuda:0"),
verbose=True,
)
# Use policy in rollout
obs = env.reset()
policy.start_episode()
action = policy(ob=obs)
Reuse Checkpoint Dict
import robomimic.utils.file_utils as FileUtils
# Load policy
policy, ckpt_dict = FileUtils.policy_from_checkpoint(ckpt_path="model.pth")
# Reuse ckpt_dict for environment creation (avoids re-loading from disk)
env, _ = FileUtils.env_from_checkpoint(ckpt_dict=ckpt_dict, render_offscreen=True)