unilab.training¶
Shared training helpers for entrypoint scripts.
Deprecated compatibility layer: the re-exports below are kept for existing
callers only. New code should import from the canonical locations instead
(unilab.utils.* for layer-0 helpers, unilab.base.config_adapter /
unisim.backend.base for base-layer helpers).
- class unilab.training.BackendAdapter[source]¶
Bases:
objectBuild env/play overrides from the final composed config.
- Parameters:
- __init__(cfg, *, root_dir, algo_name=None, scene_materializer=<function materialize_scene_visual_override>)[source]¶
- class unilab.training.ExperimentTracker[source]¶
Bases:
objectTracks experiment metadata locally and optionally in Weights & Biases.
- Parameters:
- __init__(*, root_dir, log_dir, algo_name, task_name, sim_backend, training_cfg, full_cfg, device=None, collector_device=None, seed_info=None)[source]¶
- unilab.training.algo_config_dict(cfg)[source]¶
Resolve the composed
cfg.algosubtree into a plain mutable dict.
- unilab.training.apply_env_nan_guard(env, training_cfg)[source]¶
Attach a
NanGuardtoenvwhentraining.nan_guardis enabled.
- unilab.training.assert_offpolicy_task_choice_matches_algo(cfg, *, algo_name=None)[source]¶
Reject off-policy configs whose cfg.algo.algo does not match the requested algo.
- unilab.training.build_run_dir_name(timestamp, sim_backend, *, world_size=1)[source]¶
Return the canonical run directory name shared by all training entries.
- unilab.training.create_env(cfg, *, num_envs, env_cfg_override=None, sim_backend=None, task_name=None)[source]¶
Construct an environment via the registry using the current Hydra config.
- unilab.training.ensure_registries()[source]¶
Import env modules so registry-based entrypoints can instantiate tasks.
- Return type:
- unilab.training.format_play_checkpoint_error(cfg, *, task_log_root, load_path, load_path_dir)[source]¶
Build the user-facing diagnostic for an unresolvable play checkpoint.
- unilab.training.get_entrypoint_log_root(root_dir, *, algo_log_name, log_root=None)[source]¶
Resolve the log root for non-Hydra entrypoints using training helper semantics.
- unilab.training.get_hydra_runtime_choice(cfg, group)[source]¶
Return a selected Hydra config-group choice when runtime metadata is available.
- unilab.training.get_latest_checkpoint(run_dir, *, suffix='.pt')[source]¶
Return the latest model checkpoint inside a run directory.
- unilab.training.get_latest_run(log_dir)[source]¶
Return the lexicographically latest run directory under a task log root.
- unilab.training.get_log_root(root_dir, cfg)[source]¶
Resolve the algorithm log root, honoring optional training.log_root overrides.
- unilab.training.log_playback_plan(plan, *, prefix='')[source]¶
Print user-facing playback status for a resolved backend plan.
- unilab.training.parse_checkpoint_path(cfg, *, root_dir, load_run=None, task_name=None, checkpoint=None, suffix='.pt')[source]¶
Resolve a checkpoint path from Hydra config and repository root.
- unilab.training.resolve_checkpoint_path(base_log_dir, load_run, *, suffix='.pt')[source]¶
Resolve a latest or explicit checkpoint path from a task log root.
- unilab.training.resolve_nan_guard_cfg(training_cfg)[source]¶
Build the shared
NanGuardCfgfromtraining.nan_guard, orNone.- Parameters:
training_cfg (
Any)- Return type:
- unilab.training.resolve_task_checkpoint_path(root_dir, *, task_name, load_run, algo_log_name, checkpoint=None, suffix='.pt', log_root=None)[source]¶
Resolve checkpoint paths for auxiliary entrypoints through shared training semantics.
- unilab.training.should_run_playback(*, play_only, no_play, play_render_mode)[source]¶
Return whether train/eval should enter playback for the configured mode.
- class unilab.training.TrainingSeedInfo[source]¶
Bases:
objectConfigured and effective seed metadata for a training run.
- Parameters:
- unilab.training.apply_configured_training_seed(cfg, *, torch_runtime=True, cuda=True)[source]¶
Resolve and apply the configured training seed before runtime construction.
- Parameters:
- Return type:
- unilab.training.apply_training_seed(seed, *, torch_runtime=True, cuda=True)[source]¶
Apply a seed to the runtimes used by training entrypoints.
- unilab.training.derive_worker_seed(base_seed, worker_index=0)[source]¶
Derive deterministic subprocess seeds from the effective run seed.
- unilab.training.resolve_appo_checkpoint_path(base_log_dir, load_run)[source]¶
Resolve an APPO checkpoint under a task log root, returning string paths.
- unilab.training.resolve_offpolicy_checkpoint_path(root_dir, algo_log_name, task, load_run)[source]¶
Resolve an off-policy checkpoint from the repo-rooted log tree.
- unilab.training.resolve_training_seed(cfg)[source]¶
Resolve the configured seed, preferring the algorithm-level contract.
- Parameters:
cfg (
Any)- Return type:
- unilab.training.setup_logger(log_dir, algo_name, *, echo=True, filename='train.log')[source]¶
Create a simple file-backed logger for script-local progress messages.
Modules
Shared helpers for training entrypoints. |
|
Shared experiment tracking utilities for local files and W&B. |
|
ONNX export and onnxruntime numeric verification helpers for play entrypoints. |
|
Run directory and checkpoint resolution helpers. |