opentau.policies.factory

Factory functions for creating policy instances and configurations.

This module provides utility functions to instantiate policy classes and their corresponding configurations based on policy names and types. It handles the logic for creating fresh policies or loading pretrained ones, as well as parsing features from datasets or environments to properly configure the policies.

Functions

get_policy_class(name)

Get the policy's class given a name.

make_policy(cfg[, ds_meta, features, stats, ...])

Make an instance of a policy class.

make_policy_config(policy_type, **kwargs)

Creates a policy configuration object based on the policy type.

opentau.policies.factory.get_policy_class(name: str) type[PreTrainedPolicy][source]

Get the policy’s class given a name.

Parameters:

name – The name of the policy (e.g., “pi0”, “pi05”, “value”). Must match the policy class’s name attribute.

Returns:

The policy class corresponding to the given name.

Return type:

type[PreTrainedPolicy]

Raises:

NotImplementedError – If the policy with the given name is not implemented.

opentau.policies.factory.make_policy(cfg: PreTrainedConfig, ds_meta: LeRobotDatasetMetadata | None = None, features: dict[str, FeatureType] | None = None, stats: dict[str, dict[str, ndarray]] | None = None, execution_target: str | None = None) PreTrainedPolicy[source]

Make an instance of a policy class.

This function exists because (for now) we need to parse features from either a dataset or an environment in order to properly dimension and instantiate a policy for that dataset or environment.

Parameters:
  • cfg – The config of the policy to make. If pretrained_path is set, the policy will be loaded with the weights from that path.

  • ds_meta – Dataset metadata to take input/output shapes and statistics to use for (un)normalization of inputs/outputs in the policy. Defaults to None.

  • features – Input and output features. Defaults to None.

  • stats – Dictionary of statistics for normalization. Defaults to None.

  • execution_target – Target for execution. Can be “robot”, “cloud”, or None. None implies unified training. “robot” implies robot action decoder inference. “cloud” implies VLM on cloud inference. Defaults to None.

Returns:

An instance of the created policy.

Return type:

PreTrainedPolicy

Raises:
  • ValueError – If neither or both ds_meta and features are provided when features are not already set in config.

  • ValueError – If execution_target is invalid.

opentau.policies.factory.make_policy_config(policy_type: str, **kwargs) PreTrainedConfig[source]

Creates a policy configuration object based on the policy type.

Parameters:
  • policy_type – The type of the policy (e.g., “pi0”, “pi05”, “value”).

  • **kwargs – Keyword arguments to be passed to the configuration class constructor.

Returns:

An instance of the corresponding policy configuration class.

Return type:

PreTrainedConfig

Raises:

ValueError – If the policy type is not available.