moplayground.eval¶
Evaluating trained runs over many tradeoffs at once. Each function returns the
per-objective episode returns for every checkpoint, from which Pareto fronts and
their statistics (utils.pareto) are computed.
moplayground.eval.pareto
¶
Functions:
| Name | Description |
|---|---|
get_pareto_rollout |
Build a jit/vmapped rollout fn that sweeps a batch of (key, tradeoff, params). |
compute_fronts |
Run rollouts for every checkpoint in every run over a fixed batch of |
get_morlax_fronts |
Compute Pareto fronts for one or more MORLAX (hypernetwork) runs. |
get_amor_fronts |
Compute Pareto fronts for one or more AMOR (tradeoff-conditioned) runs. |
get_pareto_rollout
¶
Build a jit/vmapped rollout fn that sweeps a batch of (key, tradeoff, params).
The same scaffold works for any algorithm — algorithm-specific details live
inside make_policy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env
|
the brax/mjx environment to roll out in.
|
|
required |
N_STEPS
|
int, number of env steps per rollout.
|
|
required |
make_policy
|
callable with signature
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
run_rollouts |
jit-compiled fn ``(keys, tradeoffs, params) -> ((final_state, returns), None)``
|
vmapped over the leading axis of |
Source code in src/moplayground/eval/pareto.py
compute_fronts
¶
compute_fronts(run_dirs, num_objectives, rng, env, N_STEPS, NUM_ENVS, make_policy, load_params_fn, model_files_per_run, save_results)
Run rollouts for every checkpoint in every run over a fixed batch of randomly sampled tradeoffs, and return the resulting Pareto fronts.
Algorithm-agnostic: callers supply make_policy and load_params_fn to
plug in MORLAX, AMOR, or anything else with the right shapes. The rollout
JIT is built once and reused across every run in run_dirs — so multiple
runs that share an environment and network architecture amortize the
compile cost.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_dirs
|
list of run directories, all sharing the same environment.
|
|
required |
num_objectives
|
int, number of objectives.
|
|
required |
rng
|
PRNGKey used both to sample the (fixed) batch of tradeoffs and to
|
seed the per-rollout env reset keys. |
required |
env
|
environment to roll out in.
|
|
required |
N_STEPS
|
int, env steps per rollout.
|
|
required |
NUM_ENVS
|
int, number of tradeoffs sampled (== number of parallel rollouts
|
per checkpoint). |
required |
make_policy
|
callable with signature
|
|
required |
load_params_fn
|
callable ``file -> params`` mapping a checkpoint path to the
|
params pytree expected by |
required |
model_files_per_run
|
list of lists of checkpoint paths, aligned with
|
|
required |
save_results
|
if True, dump per-checkpoint returns to
|
|
required |
Returns:
| Name | Type | Description |
|---|---|---|
rewards_over_iters |
ndarray, shape ``(total_checkpoints, NUM_ENVS, num_objs)``,
|
per-objective episodic return. Files are concatenated in run order. |
tradeoffs_over_iters |
ndarray, same shape, the tradeoff used for each
|
rollout. Fixed across checkpoints (broadcast along axis 0). |
Source code in src/moplayground/eval/pareto.py
get_morlax_fronts
¶
get_morlax_fronts(run_dirs, network_params, num_objectives, rng, env, N_STEPS, NUM_ENVS, save_results=False, only_final=False)
Compute Pareto fronts for one or more MORLAX (hypernetwork) runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_dirs
|
run directory, or list of run directories. Every run must deploy
|
the same environment and network architecture; the rollout JIT is
built once and reused across all of them. Check this before calling
(see |
required |
network_params
|
dict, network-factory keyword arguments shared by all runs.
|
|
required |
num_objectives
|
int, number of objectives.
|
|
required |
rng
|
PRNGKey used both to sample the (fixed) batch of tradeoffs and to
|
seed the per-rollout env reset keys. |
required |
env
|
environment to roll out in.
|
|
required |
N_STEPS
|
int, env steps per rollout.
|
|
required |
NUM_ENVS
|
int, number of tradeoffs sampled (== number of parallel rollouts
|
per checkpoint). |
required |
save_results
|
if True, dump per-checkpoint returns to
|
|
False
|
only_final
|
if True, evaluate only the final checkpoint of each run.
|
|
False
|
Returns:
| Name | Type | Description |
|---|---|---|
rewards_over_iters |
ndarray, shape ``(total_checkpoints, NUM_ENVS, num_objs)``,
|
per-objective episodic return. Files are concatenated in run order. |
tradeoffs_over_iters |
ndarray, same shape, the tradeoff used for each
|
rollout. Fixed across checkpoints (broadcast along axis 0). |
Source code in src/moplayground/eval/pareto.py
get_amor_fronts
¶
get_amor_fronts(run_dirs, network_params, num_objectives, rng, env, N_STEPS, NUM_ENVS, save_results=False, only_final=False)
Compute Pareto fronts for one or more AMOR (tradeoff-conditioned) runs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_dirs
|
run directory, or list of run directories. Every run must deploy
|
the same environment and network architecture; the rollout JIT is
built once and reused across all of them. Check this before calling
(see |
required |
network_params
|
dict, network-factory keyword arguments shared by all runs.
|
|
required |
num_objectives
|
int, number of objectives.
|
|
required |
rng
|
PRNGKey used both to sample the (fixed) batch of tradeoffs and to
|
seed the per-rollout env reset keys. |
required |
env
|
environment to roll out in.
|
|
required |
N_STEPS
|
int, env steps per rollout.
|
|
required |
NUM_ENVS
|
int, number of tradeoffs sampled (== number of parallel rollouts
|
per checkpoint). |
required |
save_results
|
if True, dump per-checkpoint returns to
|
|
False
|
only_final
|
if True, evaluate only the final checkpoint of each run.
|
|
False
|
Returns:
| Name | Type | Description |
|---|---|---|
rewards_over_iters |
ndarray, shape ``(total_checkpoints, NUM_ENVS, num_objs)``,
|
per-objective episodic return. Files are concatenated in run order. |
tradeoffs_over_iters |
ndarray, same shape, the tradeoff used for each
|
rollout. Fixed across checkpoints (broadcast along axis 0). |