inference_client
inference_client
¶
Inference client connecting trained policies to environments via transports.
EpisodeStatus
¶
Bases: StrEnum
Status values controlling the episode loop.
EnvironmentState
dataclass
¶
Per-environment observation buffer and temporal aggregator.
InferenceClient
¶
InferenceClient(policy_runtime, observation_transport, action_transport, temporal_aggregation=False, action_execution_horizon=None, favor_more_recent=True, exponential_decay=0.01, compression_type=value, max_timesteps=800, timing_log=False, update_rate_hz=None, online_explanation_source=None)
Connects a trained policy to a simulation or real-world robot environment via custom transport protocols.
Initialize the inference client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy_runtime
|
PolicyRuntime
|
Runtime providing policy inference and metadata. |
required |
observation_transport
|
ObservationTransport
|
Protocol for receiving observations from the environment. |
required |
action_transport
|
ActionTransport
|
Protocol for sending actions to the environment. |
required |
temporal_aggregation
|
bool
|
Whether to use temporal ensemble. When enabled, the policy is queried every step and the overlapping action predictions from consecutive chunks are averaged with exponential weighting. When disabled, the policy predicts a chunk of actions and all of them are sent to the environment before re-querying. |
False
|
action_execution_horizon
|
int | None
|
How many actions from each predicted chunk to execute when temporal_aggregation is False. Defaults to prediction_horizon. |
None
|
favor_more_recent
|
bool
|
In temporal ensemble, weight predictions from later inference calls higher than earlier ones for the same timestep. |
True
|
exponential_decay
|
float
|
Exponential decay rate for the temporal ensemble weights. Higher values discount older predictions more aggressively. |
0.01
|
compression_type
|
str
|
Compression type for image data transfer. |
value
|
max_timesteps
|
int
|
Maximum episode length for temporal aggregation. |
800
|
timing_log
|
bool
|
Whether to log per-step timing breakdown. |
False
|
update_rate_hz
|
float | None
|
Target action-send frequency in Hz. |
None
|
online_explanation_source
|
OnlineExplanationSource | None
|
Optional source that converts the exact ready observation batch used for policy inference into explanations. |
None
|
Source code in src/versatil/inference/inference_client.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
run_episode
¶
Run a full inference episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_steps
|
int
|
Maximum number of steps in the episode. |
required |
Source code in src/versatil/inference/inference_client.py
step
¶
Execute a single step: receive, predict, send.
Returns:
| Type | Description |
|---|---|
str
|
Status string indicating episode state. |
Source code in src/versatil/inference/inference_client.py
reset
¶
Reset all environment states for a new episode.
Source code in src/versatil/inference/inference_client.py
shutdown
¶
Close transport connections.
Source code in src/versatil/inference/inference_client.py
infer_rotate_images
¶
Whether incoming simulator images must be rotated 180 degrees.
The LIBERO simulator emits images flipped relative to the lerobot dataset orientation the policy was trained on, so the mismatch is a property of the training data source, derived from the checkpoint's dataset schema.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
DictConfig
|
Full training config saved with the checkpoint, either as the composed DictConfig or as an instantiated MainConfig whose schema node is a real DatasetSchema. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True for policies trained on LIBERO lerobot datasets. |