Skip to main content
The rfx.hub module provides the main entry points for working with saved policies. It supports both local paths and HuggingFace Hub models.

Functions

load_policy

Load a self-describing policy from a local path or HuggingFace Hub.
loaded = rfx.load_policy("runs/go2-walk-v1")
loaded = rfx.load_policy("hf://rfx-community/go2-walk-v1")
source
str | Path
Local directory path, or "hf://org/repo" for Hub models.
Returns: LoadedPolicy with .policy, .robot_config, .normalizer, .config

push_policy

Push a saved policy directory to HuggingFace Hub.
url = rfx.push_policy("runs/go2-walk-v1", "rfx-community/go2-walk-v1")
print(url)  # https://huggingface.co/rfx-community/go2-walk-v1
path
str | Path
required
Local directory containing the saved policy.
repo_id
str
required
HuggingFace repo ID (e.g. "rfx-community/go2-walk-v1").
private
bool
default:"False"
Whether to create a private repo.
Returns: str - The URL of the uploaded model.

inspect_policy

Read rfx_config.json without loading weights. Useful for quick inspection.
config = rfx.inspect_policy("runs/go2-walk-v1")
print(config["policy_type"])  # "MLP"
print(config["rfx_version"])  # "0.1.0"
source
str | Path
Local directory path, or "hf://org/repo" for Hub models.
Returns: dict[str, Any] - The parsed rfx_config.json dict.

Classes

LoadedPolicy

A loaded policy with all its metadata. Callable — accepts the obs dict that robot.observe() returns and handles torch↔tinygrad conversion automatically.
loaded = rfx.load_policy("runs/go2-walk-v1")

# Use with rfx.run()
rfx.run(robot, loaded)

# Or call directly
obs = robot.observe()
action = loaded(obs)

Attributes

policy
Policy
The policy network (e.g. MLP, JitPolicy, TorchJitPolicy).
robot_config
RobotConfig | None
Robot configuration bundled with the policy.
normalizer
ObservationNormalizer | None
Observation normalizer (mean/std scaling).
config
dict[str, Any]
Full policy metadata from rfx_config.json.

Properties

policy_type
str
Policy class name (e.g. "MLP", "TorchJitPolicy").
training_info
dict[str, Any]
Training metadata (steps, rewards, etc.).

Methods

__call__(obs) Run inference on observations.
obs
dict[str, torch.Tensor] | Tensor
Observations from robot.observe() or raw tinygrad tensor.
Returns: torch.Tensor - Action tensor.

Build docs developers (and LLMs) love