synthetic_rollout
synthetic_rollout
¶
Rollout and evaluation utilities for synthetic benchmark policies.
Provides open-loop and closed-loop rollout functions that load a trained policy checkpoint, generate position trajectories via the policy, and evaluate them against expert demonstrations using mode coverage and goal success metrics.
load_policy_from_checkpoint
¶
Load a trained policy and config from a checkpoint directory.
Follows the same loading pattern as the production inference clients: instantiate config, create policy, load weights via LightningPolicy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
checkpoint_path
|
str
|
Directory containing config.yaml and the .ckpt file. |
required |
device
|
str
|
Torch device string. |
'cuda'
|
checkpoint_name
|
str
|
Checkpoint filename inside checkpoint_path. |
'last.ckpt'
|
Returns:
| Type | Description |
|---|---|
tuple[Policy, MainConfig]
|
Tuple of (policy in eval mode, resolved MainConfig). |
Source code in src/versatil/inference/synthetic_rollout.py
run_rollouts
¶
run_rollouts(policy, task_name, num_rollouts, image_size=DEFAULT_IMAGE_SIZE, context_mode=None, temporal_aggregation=False, exponential_decay=0.01, output_dir=None)
Re-render and re-predict at each timestep with temporal aggregation.
At each step, the policy predicts a full action trajectory. With temporal aggregation enabled, overlapping predictions for the current timestep are averaged with exponential weights favoring more recent queries. Without it, the policy executes the full predicted chunk before replanning.
Policy-input frames intentionally render without any goal marker.
Per-mode expert goals are still drawn in the user-facing rollout
visualization via layout.goals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
policy
|
Policy
|
Trained policy in eval mode. |
required |
task_name
|
str
|
SyntheticTaskName.value string. |
required |
num_rollouts
|
int
|
Number of independent rollouts. |
required |
image_size
|
int
|
Side length for rendered images. |
DEFAULT_IMAGE_SIZE
|
context_mode
|
int | None
|
Context mode index for conditional tasks (None to omit). |
None
|
temporal_aggregation
|
bool
|
Average overlapping action predictions with exponential weighting. Matches the production inference clients. |
False
|
exponential_decay
|
float
|
Decay factor for temporal aggregation weights. Smaller values produce more uniform weighting across queries. |
0.01
|
output_dir
|
str | None
|
Optional directory for saving PNG + GIF visualizations of the rollout trajectories. If None, no visualizations are saved. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Position trajectories, shape (num_rollouts, prediction_horizon + 1, 2). |
Source code in src/versatil/inference/synthetic_rollout.py
78 79 80 81 82 83 84 85 86 87 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 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 | |
evaluate_rollouts
¶
evaluate_rollouts(rollout_trajectories, task_name, num_expert_episodes=1000, expert_seed=42, trajectory_length=MULTIPATH_DEFAULT_TRAJECTORY_LENGTH, noise_std=MULTIPATH_DEFAULT_NOISE_STD, num_modes=MULTIPATH_DEFAULT_NUM_MODES, num_styles=CORRIDOR_DEFAULT_NUM_STYLES, image_size=DEFAULT_IMAGE_SIZE)
Evaluate rollout trajectories against regenerated expert demonstrations.
Generates expert data with the given parameters, then computes mode coverage and obstacle-aware success rate. The "reach" threshold used by the synthetic success metrics is derived from the expert endpoint spread (mean plus five standard deviations of distances from the per-mode endpoint mean), so it scales with the task's intrinsic noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rollout_trajectories
|
ndarray
|
Generated position trajectories. Shape (num_rollouts, num_timesteps, 2). |
required |
task_name
|
str
|
SyntheticTaskName.value string. |
required |
num_expert_episodes
|
int
|
Number of expert episodes for reference. |
1000
|
expert_seed
|
int
|
Seed for reproducible expert generation. |
42
|
trajectory_length
|
int
|
Expert trajectory length. |
MULTIPATH_DEFAULT_TRAJECTORY_LENGTH
|
noise_std
|
float
|
Expert noise standard deviation. |
MULTIPATH_DEFAULT_NOISE_STD
|
num_modes
|
int
|
Number of modes for expert generation. |
MULTIPATH_DEFAULT_NUM_MODES
|
num_styles
|
int
|
Number of styles (trajectory_style task only). |
CORRIDOR_DEFAULT_NUM_STYLES
|
image_size
|
int
|
Image size for expert generation. |
DEFAULT_IMAGE_SIZE
|
Returns:
| Type | Description |
|---|---|
dict[str, float | dict[int, int]]
|
Dict with raw mode coverage metrics, valid mode coverage metrics, |
dict[str, float | dict[int, int]]
|
success_rate, collision_rate, endpoint_reach_rate, and path_length_rate. |
Source code in src/versatil/inference/synthetic_rollout.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |