tensor-optix 2.0.5__tar.gz → 2.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/PKG-INFO +2 -1
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/README.md +1 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/pyproject.toml +1 -1
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/pytorch/torch_evaluator.py +13 -2
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/tensorflow/tf_evaluator.py +13 -2
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/config.py +1 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/backoff_scheduler.py +15 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/loop_controller.py +72 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/reward_shape.py +55 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/aec_pipeline.py +11 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/multi_agent_runtime.py +48 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/parallel_pipeline.py +11 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizer.py +3 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/pipeline/batch_pipeline.py +8 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/pipeline/vector_pipeline.py +10 -1
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/PKG-INFO +2 -1
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/setup.cfg +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/jax/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/jax/flax_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/jax/flax_evaluator.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/pytorch/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/pytorch/torch_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/tensorflow/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/adapters/tensorflow/tf_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/flax_ppo.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/tf_dqn.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/tf_ppo.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/tf_ppo_continuous.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/tf_sac.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/tf_td3.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_dqn.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_ppo.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_ppo_continuous.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_rainbow_dqn.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_recurrent_ppo.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_sac.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/algorithms/torch_td3.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/callbacks/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/callbacks/rich_dashboard.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/callbacks/tensorboard_callback.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/callbacks/wandb_callback.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/cli.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/async_callback.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/base_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/base_evaluator.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/base_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/base_pipeline.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/checkpoint_confirmation.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/checkpoint_registry.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/device.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/diagnostic_controller.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/ensemble_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/her_buffer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/meta_controller.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/noisy_linear.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/normalizers.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/obs_utils.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/policy_manager.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/regime_detector.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/replay_buffer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/resume_state.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/trajectory_buffer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/core/types.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/distributed/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/distributed/async_learner.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/distributed/vtrace.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/encoders/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/encoders/obs_encoder.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/encoders/obs_encoder_tf.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/exploration/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/exploration/rnd.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/factory.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/callback.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/provenance.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/records.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/schema.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ledger/store.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml/dataset_pipeline.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml/loss_registry.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml/ml_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/adapters/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/adapters/flax_model.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/adapters/tf_model.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/adapters/torch_model.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/base_model.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/lr_schedules.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/metrics.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/metrics_impl/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/metrics_impl/classification.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/metrics_impl/regression.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/trainer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/ml_core/transfer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/multi_agent_episode.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/multi_agent/seat_env.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/abstention.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/features.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/pooling.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/selector.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/nanonets/smalln.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/agent/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/agent/graph_agent.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/brain_network.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/controller/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/controller/topology_callback.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/controller/topology_controller.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/graph/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/graph/neuron.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/graph/neuron_graph.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/graph/topology_ops.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/hebbian.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/neuromodulator.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/optimizer/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/neuroevo/optimizer/topology_aware_adam.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/adaptive_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/backoff_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/momentum_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/pbt_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/optimizers/spsa_optimizer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/orchestrator.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/pipeline/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/pipeline/live_pipeline.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/baseline.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/experiment_stage.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/live_runtime.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/observer.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/runtime/promote.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/_mp_common.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/budget.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/dedup.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/isolation.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/pool.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/retry.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/scheduler/worker.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/selection/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/selection/backfill.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/selection/selector.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/selection/uncertainty.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/simple.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/candidate.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/comparator.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/grammar.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/promotion.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/runner.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/strategy/worker.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/utils/__init__.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/utils/console.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix/utils/window_size.py +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/SOURCES.txt +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/dependency_links.txt +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/entry_points.txt +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/requires.txt +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tensor_optix.egg-info/top_level.txt +0 -0
- {tensor_optix-2.0.5 → tensor_optix-2.0.6}/tests/test_ml.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tensor-optix
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
4
4
|
Summary: Autonomous training loop for any sequential learning model — PPO, DQN, SAC, TD3, Rainbow DQN, Recurrent PPO for TensorFlow, PyTorch, and JAX/Flax; distributed async actor-learner (IMPALA + V-trace)
|
|
5
5
|
Author: sup3rus3r
|
|
6
6
|
License-Expression: MIT
|
|
@@ -337,6 +337,7 @@ opt.best_snapshot # -> PolicySnapshot: best weights + EvalMetrics + Hyperparam
|
|
|
337
337
|
|
|
338
338
|
Loop state transitions: `ACTIVE` -> `COOLING` -> `DORMANT` -> watchdog shutdown or policy spawn.
|
|
339
339
|
|
|
340
|
+
- Scores are full episode returns, tracked across windows. A window in which no episode finished trains the agent but is not evaluated, and the loop cannot plateau before `min_completed_episodes_before_dormant` (default 10) episodes have finished (`0` for continuing tasks).
|
|
340
341
|
- Every non-improving eval counts toward `COOLING`/`DORMANT`, for on-policy and off-policy agents alike. While the score is flat the eval interval backs off (`backoff_factor`, default 2.0); set `backoff_factor=1.0` to evaluate every window.
|
|
341
342
|
- At `DORMANT` the loop stops by default. A `PolicyManagerCallback` with spawn budget remaining spawns a variant instead and training continues.
|
|
342
343
|
- `rollback_on_degradation=True` restores the best checkpoint when a degradation is confirmed (`min_consecutive_degradations` consecutive evals below `degradation_threshold x best`), for on-policy agents only - off-policy agents keep their weights because their replay buffer would immediately pull a restored policy back.
|
|
@@ -266,6 +266,7 @@ opt.best_snapshot # -> PolicySnapshot: best weights + EvalMetrics + Hyperparam
|
|
|
266
266
|
|
|
267
267
|
Loop state transitions: `ACTIVE` -> `COOLING` -> `DORMANT` -> watchdog shutdown or policy spawn.
|
|
268
268
|
|
|
269
|
+
- Scores are full episode returns, tracked across windows. A window in which no episode finished trains the agent but is not evaluated, and the loop cannot plateau before `min_completed_episodes_before_dormant` (default 10) episodes have finished (`0` for continuing tasks).
|
|
269
270
|
- Every non-improving eval counts toward `COOLING`/`DORMANT`, for on-policy and off-policy agents alike. While the score is flat the eval interval backs off (`backoff_factor`, default 2.0); set `backoff_factor=1.0` to evaluate every window.
|
|
270
271
|
- At `DORMANT` the loop stops by default. A `PolicyManagerCallback` with spawn budget remaining spawns a variant instead and training continues.
|
|
271
272
|
- `rollback_on_degradation=True` restores the best checkpoint when a degradation is confirmed (`min_consecutive_degradations` consecutive evals below `degradation_threshold x best`), for on-policy agents only - off-policy agents keep their weights because their replay buffer would immediately pull a restored policy back.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tensor-optix"
|
|
7
|
-
version = "2.0.
|
|
7
|
+
version = "2.0.6"
|
|
8
8
|
description = "Autonomous training loop for any sequential learning model — PPO, DQN, SAC, TD3, Rainbow DQN, Recurrent PPO for TensorFlow, PyTorch, and JAX/Flax; distributed async actor-learner (IMPALA + V-trace)"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from typing import Callable, Optional
|
|
3
3
|
from tensor_optix.core.base_evaluator import BaseEvaluator
|
|
4
|
-
from tensor_optix.core.reward_shape import split_episode_returns
|
|
4
|
+
from tensor_optix.core.reward_shape import completed_episode_returns, split_episode_returns
|
|
5
5
|
from tensor_optix.core.types import EpisodeData, EvalMetrics
|
|
6
6
|
|
|
7
7
|
|
|
@@ -41,7 +41,13 @@ class TorchEvaluator(BaseEvaluator):
|
|
|
41
41
|
primary = float(self._primary_score_fn(episode_data, train_diagnostics))
|
|
42
42
|
else:
|
|
43
43
|
n_envs = int((episode_data.metadata or {}).get("n_envs", 1))
|
|
44
|
-
|
|
44
|
+
# Full returns of the episodes that finished in this window
|
|
45
|
+
# (tracked across windows by the pipeline when it supports it).
|
|
46
|
+
episode_returns = completed_episode_returns(episode_data, n_envs)
|
|
47
|
+
primary = (
|
|
48
|
+
float(np.mean(episode_returns)) if episode_returns
|
|
49
|
+
else float(rewards.mean()) if len(rewards) else 0.0
|
|
50
|
+
)
|
|
45
51
|
|
|
46
52
|
metrics = {
|
|
47
53
|
"primary_score": primary,
|
|
@@ -50,6 +56,11 @@ class TorchEvaluator(BaseEvaluator):
|
|
|
50
56
|
"reward_std": float(rewards.std()) if len(rewards) > 1 else 0.0,
|
|
51
57
|
"episode_length": episode_data.length,
|
|
52
58
|
}
|
|
59
|
+
if self._primary_score_fn is None:
|
|
60
|
+
# How many finished episodes the score is based on. 0 means the
|
|
61
|
+
# score above is only the per-step fallback: the training loops
|
|
62
|
+
# use this to avoid treating such a window as an evaluation.
|
|
63
|
+
metrics["episodes_completed"] = len(episode_returns)
|
|
53
64
|
metrics.update({k: float(v) for k, v in train_diagnostics.items()
|
|
54
65
|
if isinstance(v, (int, float))})
|
|
55
66
|
return EvalMetrics(primary_score=primary, metrics=metrics,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
from tensor_optix.core.base_evaluator import BaseEvaluator
|
|
3
|
-
from tensor_optix.core.reward_shape import split_episode_returns
|
|
3
|
+
from tensor_optix.core.reward_shape import completed_episode_returns, split_episode_returns
|
|
4
4
|
from tensor_optix.core.types import EpisodeData, EvalMetrics
|
|
5
5
|
|
|
6
6
|
|
|
@@ -38,7 +38,13 @@ class TFEvaluator(BaseEvaluator):
|
|
|
38
38
|
primary = float(self._primary_score_fn(episode_data, train_diagnostics))
|
|
39
39
|
else:
|
|
40
40
|
n_envs = int((episode_data.metadata or {}).get("n_envs", 1))
|
|
41
|
-
|
|
41
|
+
# Full returns of the episodes that finished in this window
|
|
42
|
+
# (tracked across windows by the pipeline when it supports it).
|
|
43
|
+
episode_returns = completed_episode_returns(episode_data, n_envs)
|
|
44
|
+
primary = (
|
|
45
|
+
float(np.mean(episode_returns)) if episode_returns
|
|
46
|
+
else float(rewards.mean()) if len(rewards) else 0.0
|
|
47
|
+
)
|
|
42
48
|
|
|
43
49
|
metrics = {
|
|
44
50
|
"primary_score": primary,
|
|
@@ -47,6 +53,11 @@ class TFEvaluator(BaseEvaluator):
|
|
|
47
53
|
"reward_std": float(rewards.std()) if len(rewards) > 1 else 0.0,
|
|
48
54
|
"episode_length": episode_data.length,
|
|
49
55
|
}
|
|
56
|
+
if self._primary_score_fn is None:
|
|
57
|
+
# How many finished episodes the score is based on. 0 means the
|
|
58
|
+
# score above is only the per-step fallback: the training loops
|
|
59
|
+
# use this to avoid treating such a window as an evaluation.
|
|
60
|
+
metrics["episodes_completed"] = len(episode_returns)
|
|
50
61
|
metrics.update({k: float(v) for k, v in train_diagnostics.items()
|
|
51
62
|
if isinstance(v, (int, float))})
|
|
52
63
|
return EvalMetrics(primary_score=primary, metrics=metrics,
|
|
@@ -320,6 +320,7 @@ def build_optimizer_from_config(cfg: TrainConfig, agent, pipeline):
|
|
|
320
320
|
"backoff_factor", "max_interval_episodes", "plateau_threshold",
|
|
321
321
|
"dormant_threshold", "degradation_threshold", "min_degradation_drop",
|
|
322
322
|
"noise_k", "score_window", "trend_window", "min_episodes_before_dormant",
|
|
323
|
+
"min_completed_episodes_before_dormant",
|
|
323
324
|
"min_episodes_before_degradation", "score_smoothing", "verbose",
|
|
324
325
|
"verbose_log_file", "diag_loss_spike_factor", "diag_entropy_floor",
|
|
325
326
|
"diag_target_kl", "diag_epsilon_patience", "diag_epsilon_reset_value",
|
|
@@ -232,6 +232,21 @@ class BackoffScheduler:
|
|
|
232
232
|
"""
|
|
233
233
|
self._state = LoopState.ACTIVE
|
|
234
234
|
|
|
235
|
+
def reset_scale(self) -> None:
|
|
236
|
+
"""
|
|
237
|
+
Forget everything measured so far, including best_score.
|
|
238
|
+
|
|
239
|
+
For when the SCORE SCALE itself changes — e.g. the first finished
|
|
240
|
+
episode arrives after windows that could only be scored by per-step
|
|
241
|
+
reward. Scores before and after are not comparable, so neither the
|
|
242
|
+
trend window nor the best score may carry over.
|
|
243
|
+
"""
|
|
244
|
+
self._score_window.clear()
|
|
245
|
+
self._best_score = None
|
|
246
|
+
self._consecutive_non_improvements = 0
|
|
247
|
+
self._current_interval = self._base_interval
|
|
248
|
+
self._state = LoopState.ACTIVE
|
|
249
|
+
|
|
235
250
|
def record_restart(self) -> None:
|
|
236
251
|
"""
|
|
237
252
|
Called after DORMANT fires and PolicyManager has acted.
|
|
@@ -88,6 +88,7 @@ class LoopController:
|
|
|
88
88
|
checkpoint_confirmation: bool = False,
|
|
89
89
|
checkpoint_confirm_window: int = 3,
|
|
90
90
|
checkpoint_noise_k: float = 2.0,
|
|
91
|
+
min_completed_episodes_before_dormant: int = 10,
|
|
91
92
|
):
|
|
92
93
|
self._agent = agent
|
|
93
94
|
self._evaluator = evaluator
|
|
@@ -140,6 +141,15 @@ class LoopController:
|
|
|
140
141
|
self._min_consecutive_degradations = min_consecutive_degradations
|
|
141
142
|
self._consecutive_degradation_count: int = 0
|
|
142
143
|
|
|
144
|
+
# Finished-episode accounting (see _account_episodes). Only active
|
|
145
|
+
# when the evaluator reports "episodes_completed".
|
|
146
|
+
self._min_completed_episodes_before_dormant = max(0, int(min_completed_episodes_before_dormant))
|
|
147
|
+
self._total_completed_episodes: int = 0
|
|
148
|
+
self._evaluator_reports_episodes: bool = False
|
|
149
|
+
self._checkpoint_confirm_args = dict(
|
|
150
|
+
noise_k=checkpoint_noise_k, confirm_window=checkpoint_confirm_window,
|
|
151
|
+
)
|
|
152
|
+
|
|
143
153
|
# Checkpoint measurement/acceptance — off by default (bit-identical
|
|
144
154
|
# to legacy raw-point comparison unless explicitly opted into).
|
|
145
155
|
# See docs/reference/core/base_evaluator.md and loop_controller.md
|
|
@@ -225,6 +235,8 @@ class LoopController:
|
|
|
225
235
|
if breadths:
|
|
226
236
|
self._breadth_history.append(breadths[-1])
|
|
227
237
|
|
|
238
|
+
self._account_episodes(eval_metrics)
|
|
239
|
+
|
|
228
240
|
if self._checkpoint_score_fn is not None:
|
|
229
241
|
ckpt_score = self._checkpoint_score_fn(self._agent)
|
|
230
242
|
elif self._checkpoint_confirmation_enabled:
|
|
@@ -302,6 +314,16 @@ class LoopController:
|
|
|
302
314
|
else:
|
|
303
315
|
eval_metrics = train_metrics
|
|
304
316
|
|
|
317
|
+
if not self._account_episodes(eval_metrics):
|
|
318
|
+
# No episode finished in this window, so there is no
|
|
319
|
+
# return to score — only the per-step fallback, which is
|
|
320
|
+
# on a different scale. Train on the window, but do not
|
|
321
|
+
# treat it as an evaluation: no checkpoint decision, no
|
|
322
|
+
# trend update, no plateau count, no optimizer step.
|
|
323
|
+
self._fire("on_episode_end", episode_id, None)
|
|
324
|
+
episode_id += 1
|
|
325
|
+
continue
|
|
326
|
+
|
|
305
327
|
self._metrics_history.append(eval_metrics)
|
|
306
328
|
|
|
307
329
|
raw = eval_metrics.primary_score
|
|
@@ -504,8 +526,58 @@ class LoopController:
|
|
|
504
526
|
self._fire("on_episode_end", episode_id, eval_metrics)
|
|
505
527
|
episode_id += 1
|
|
506
528
|
|
|
529
|
+
def _account_episodes(self, eval_metrics: EvalMetrics) -> bool:
|
|
530
|
+
"""
|
|
531
|
+
Track finished episodes and decide whether this window is a usable
|
|
532
|
+
evaluation. Returns False when it should be skipped.
|
|
533
|
+
|
|
534
|
+
The default evaluators report metrics["episodes_completed"] (or
|
|
535
|
+
"val_episodes_completed" when a validation pipeline drives the
|
|
536
|
+
score): how many finished episodes the score is the mean return of.
|
|
537
|
+
An evaluator that does not report it is always treated as usable.
|
|
538
|
+
|
|
539
|
+
- completed > 0: usable. If this is the first finished episode
|
|
540
|
+
after windows scored by the per-step fallback, the score scale
|
|
541
|
+
just changed, so everything measured so far is discarded.
|
|
542
|
+
- completed == 0, and an episode has finished before: skip.
|
|
543
|
+
- completed == 0, and none ever has: usable (per-step fallback) —
|
|
544
|
+
an env whose episodes never end must still be trainable.
|
|
545
|
+
"""
|
|
546
|
+
metrics = eval_metrics.metrics or {}
|
|
547
|
+
completed = metrics.get("val_episodes_completed", metrics.get("episodes_completed"))
|
|
548
|
+
if completed is None:
|
|
549
|
+
return True
|
|
550
|
+
completed = int(completed)
|
|
551
|
+
self._evaluator_reports_episodes = True
|
|
552
|
+
if completed == 0:
|
|
553
|
+
return self._total_completed_episodes == 0
|
|
554
|
+
if self._total_completed_episodes == 0 and self._metrics_history:
|
|
555
|
+
logger.info(
|
|
556
|
+
"First finished episode — score scale changes from per-step reward "
|
|
557
|
+
"to episode return; resetting best score and trend window."
|
|
558
|
+
)
|
|
559
|
+
self._reset_score_scale()
|
|
560
|
+
self._total_completed_episodes += completed
|
|
561
|
+
return True
|
|
562
|
+
|
|
563
|
+
def _reset_score_scale(self) -> None:
|
|
564
|
+
self._score_window.clear()
|
|
565
|
+
self._best_smoothed = None
|
|
566
|
+
self._best_raw = None
|
|
567
|
+
self._metrics_history.clear()
|
|
568
|
+
self._consecutive_degradation_count = 0
|
|
569
|
+
self._consecutive_above_target = 0
|
|
570
|
+
self._confirmation = CheckpointConfirmationTracker(**self._checkpoint_confirm_args)
|
|
571
|
+
self._scheduler.reset_scale()
|
|
572
|
+
|
|
507
573
|
def _record_plateau(self, episode_id: int) -> None:
|
|
508
574
|
"""Advance the scheduler on a non-improving eval and act on the new state."""
|
|
575
|
+
if (
|
|
576
|
+
self._evaluator_reports_episodes
|
|
577
|
+
and self._total_completed_episodes < self._min_completed_episodes_before_dormant
|
|
578
|
+
):
|
|
579
|
+
# Too few finished episodes to call anything a plateau yet.
|
|
580
|
+
return
|
|
509
581
|
self._scheduler.record_non_improvement()
|
|
510
582
|
state = self._scheduler.current_state
|
|
511
583
|
if state == LoopState.COOLING:
|
|
@@ -31,6 +31,61 @@ from typing import Deque, List
|
|
|
31
31
|
import numpy as np
|
|
32
32
|
|
|
33
33
|
|
|
34
|
+
class EpisodeReturnTracker:
|
|
35
|
+
"""
|
|
36
|
+
Accumulates per-episode returns ACROSS windows.
|
|
37
|
+
|
|
38
|
+
A pipeline yields fixed-size windows, so an episode usually starts in one
|
|
39
|
+
window and ends in a later one. Summing rewards inside a single window
|
|
40
|
+
only ever sees the tail of such an episode (and nothing at all when the
|
|
41
|
+
episode is longer than the window). The tracker keeps one running sum per
|
|
42
|
+
environment between calls, so every return it reports is the full return
|
|
43
|
+
of an episode, however many windows it spanned.
|
|
44
|
+
|
|
45
|
+
update() returns the returns of the episodes that FINISHED in this
|
|
46
|
+
window — an empty list when none did.
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
def __init__(self, n_envs: int = 1) -> None:
|
|
50
|
+
self._n_envs = max(1, int(n_envs))
|
|
51
|
+
self._running = [0.0] * self._n_envs
|
|
52
|
+
|
|
53
|
+
def update(self, rewards, dones) -> List[float]:
|
|
54
|
+
finished: List[float] = []
|
|
55
|
+
n = self._n_envs
|
|
56
|
+
for t in range(len(rewards)):
|
|
57
|
+
env_i = t % n
|
|
58
|
+
self._running[env_i] += float(rewards[t])
|
|
59
|
+
if dones[t]:
|
|
60
|
+
finished.append(self._running[env_i])
|
|
61
|
+
self._running[env_i] = 0.0
|
|
62
|
+
return finished
|
|
63
|
+
|
|
64
|
+
def reset(self) -> None:
|
|
65
|
+
self._running = [0.0] * self._n_envs
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
EPISODE_RETURNS_KEY = "episode_returns"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def completed_episode_returns(episode_data, n_envs: int = 1):
|
|
72
|
+
"""
|
|
73
|
+
Returns of the episodes that finished in this window.
|
|
74
|
+
|
|
75
|
+
Pipelines that track episodes across windows publish them in
|
|
76
|
+
EpisodeData.metadata["episode_returns"] (full returns, possibly an empty
|
|
77
|
+
list). For any other pipeline this falls back to window-local sums.
|
|
78
|
+
"""
|
|
79
|
+
metadata = getattr(episode_data, "metadata", None) or {}
|
|
80
|
+
tracked = metadata.get(EPISODE_RETURNS_KEY)
|
|
81
|
+
if tracked is not None:
|
|
82
|
+
return [float(r) for r in tracked]
|
|
83
|
+
return [
|
|
84
|
+
float(np.sum(seg))
|
|
85
|
+
for seg in split_episode_returns(episode_data.rewards, episode_data.dones, n_envs)
|
|
86
|
+
]
|
|
87
|
+
|
|
88
|
+
|
|
34
89
|
def split_episode_returns(values: List[float], dones: List[bool], n_envs: int = 1) -> List[List[float]]:
|
|
35
90
|
"""
|
|
36
91
|
Split a window of per-step values into per-completed-episode segments,
|
|
@@ -28,6 +28,7 @@ from typing import Any, Dict, Generator, Hashable, Optional
|
|
|
28
28
|
import numpy as np
|
|
29
29
|
|
|
30
30
|
from tensor_optix.core.types import EpisodeData
|
|
31
|
+
from tensor_optix.core.reward_shape import EPISODE_RETURNS_KEY, EpisodeReturnTracker
|
|
31
32
|
|
|
32
33
|
logger = logging.getLogger(__name__)
|
|
33
34
|
|
|
@@ -61,6 +62,8 @@ class AECMultiAgentPipeline:
|
|
|
61
62
|
self._agents = agents
|
|
62
63
|
self._window_size = window_size
|
|
63
64
|
self._window_counter = 0
|
|
65
|
+
# One cross-window episode-return tracker per seat.
|
|
66
|
+
self._return_trackers: Dict[Hashable, EpisodeReturnTracker] = {}
|
|
64
67
|
self._needs_reset = True
|
|
65
68
|
self._agent_iter = None
|
|
66
69
|
# See ParallelMultiAgentPipeline's constructor docstring for why
|
|
@@ -170,6 +173,14 @@ class AECMultiAgentPipeline:
|
|
|
170
173
|
truncated=data["truncated"],
|
|
171
174
|
infos=data["infos"],
|
|
172
175
|
episode_id=self._window_counter,
|
|
176
|
+
metadata={
|
|
177
|
+
EPISODE_RETURNS_KEY: self._return_trackers.setdefault(
|
|
178
|
+
aid, EpisodeReturnTracker()
|
|
179
|
+
).update(
|
|
180
|
+
data["rewards"],
|
|
181
|
+
[t or tr for t, tr in zip(data["terminated"], data["truncated"])],
|
|
182
|
+
),
|
|
183
|
+
},
|
|
173
184
|
final_obs=None if last_done else None,
|
|
174
185
|
# AEC has no per-seat "next observation immediately
|
|
175
186
|
# after the window" the way Parallel's step() return
|
|
@@ -54,6 +54,7 @@ class SeatResult:
|
|
|
54
54
|
state: LoopState
|
|
55
55
|
converged: bool
|
|
56
56
|
windows_scored: int
|
|
57
|
+
completed_episodes: int
|
|
57
58
|
best_score: Optional[float]
|
|
58
59
|
last_score: Optional[float]
|
|
59
60
|
best_snapshot: Optional[PolicySnapshot]
|
|
@@ -82,6 +83,9 @@ class _Seat:
|
|
|
82
83
|
self.best_snapshot: Optional[PolicySnapshot] = None
|
|
83
84
|
self.windows_scored = 0
|
|
84
85
|
self.converged = False
|
|
86
|
+
self.completed_episodes = 0
|
|
87
|
+
self.reports_episodes = False
|
|
88
|
+
self.scored_before_first_episode = False
|
|
85
89
|
|
|
86
90
|
|
|
87
91
|
class MultiAgentRunner:
|
|
@@ -116,6 +120,13 @@ class MultiAgentRunner:
|
|
|
116
120
|
is skipped for that window — not learned, not scored, and it does not
|
|
117
121
|
count toward that seat's plateau counter.
|
|
118
122
|
|
|
123
|
+
Scores are full episode returns, tracked across windows by the
|
|
124
|
+
pipeline. A window in which a seat finished no episode still trains
|
|
125
|
+
that seat but is not scored (no checkpoint, no plateau count). Until a
|
|
126
|
+
seat's first episode finishes, windows are scored by mean per-step
|
|
127
|
+
reward; when it does, that seat's best score and trend are reset
|
|
128
|
+
because the scale changes.
|
|
129
|
+
|
|
119
130
|
Args:
|
|
120
131
|
pipeline, agents: as before.
|
|
121
132
|
evaluator: a BaseEvaluator, or {agent_id: BaseEvaluator}.
|
|
@@ -125,6 +136,9 @@ class MultiAgentRunner:
|
|
|
125
136
|
max_snapshots: snapshots kept per seat.
|
|
126
137
|
improvement_margin: minimum score gain over the seat's best for
|
|
127
138
|
a new checkpoint.
|
|
139
|
+
min_completed_episodes_before_converged:
|
|
140
|
+
a seat cannot plateau/converge before it has
|
|
141
|
+
finished this many episodes (default 10).
|
|
128
142
|
plateau_threshold / dormant_threshold / min_windows_before_dormant /
|
|
129
143
|
noise_k / score_window / trend_window:
|
|
130
144
|
per-seat BackoffScheduler settings (same
|
|
@@ -148,6 +162,7 @@ class MultiAgentRunner:
|
|
|
148
162
|
plateau_threshold: int = 5,
|
|
149
163
|
dormant_threshold: int = 20,
|
|
150
164
|
min_windows_before_dormant: int = 0,
|
|
165
|
+
min_completed_episodes_before_converged: int = 10,
|
|
151
166
|
noise_k: float = 2.0,
|
|
152
167
|
score_window: int = 20,
|
|
153
168
|
trend_window: int = 8,
|
|
@@ -161,6 +176,7 @@ class MultiAgentRunner:
|
|
|
161
176
|
self._pipeline = pipeline
|
|
162
177
|
self._agents = agents
|
|
163
178
|
self._improvement_margin = improvement_margin
|
|
179
|
+
self._min_completed_episodes = max(0, int(min_completed_episodes_before_converged))
|
|
164
180
|
self._stop_when = stop_when
|
|
165
181
|
self._stop_on_convergence = stop_on_convergence
|
|
166
182
|
self._restore_best = restore_best
|
|
@@ -240,6 +256,10 @@ class MultiAgentRunner:
|
|
|
240
256
|
diagnostics = seat.agent.learn(episode_data) or {}
|
|
241
257
|
metrics = self._evaluators[aid].score(episode_data, diagnostics)
|
|
242
258
|
metrics.episode_id = windows_run
|
|
259
|
+
if not self._account_episodes(seat, metrics):
|
|
260
|
+
# No episode finished for this seat in this window:
|
|
261
|
+
# it trained, but there is no return to score.
|
|
262
|
+
continue
|
|
243
263
|
window_metrics[aid] = metrics
|
|
244
264
|
self._update_seat(seat, metrics, windows_run)
|
|
245
265
|
|
|
@@ -276,6 +296,7 @@ class MultiAgentRunner:
|
|
|
276
296
|
state=seat.scheduler.current_state,
|
|
277
297
|
converged=seat.converged,
|
|
278
298
|
windows_scored=seat.windows_scored,
|
|
299
|
+
completed_episodes=seat.completed_episodes,
|
|
279
300
|
best_score=seat.best_score,
|
|
280
301
|
last_score=seat.last_score,
|
|
281
302
|
best_snapshot=seat.best_snapshot,
|
|
@@ -288,6 +309,30 @@ class MultiAgentRunner:
|
|
|
288
309
|
# Internals
|
|
289
310
|
# ------------------------------------------------------------------
|
|
290
311
|
|
|
312
|
+
def _account_episodes(self, seat: _Seat, metrics: EvalMetrics) -> bool:
|
|
313
|
+
"""
|
|
314
|
+
Same rule as LoopController._account_episodes, per seat: a window in
|
|
315
|
+
which no episode finished is not an evaluation (once the seat has
|
|
316
|
+
finished at least one episode), and the first finished episode after
|
|
317
|
+
per-step-scored windows resets the seat's best score and trend.
|
|
318
|
+
Evaluators that do not report "episodes_completed" are always used.
|
|
319
|
+
"""
|
|
320
|
+
completed = (metrics.metrics or {}).get("episodes_completed")
|
|
321
|
+
if completed is None:
|
|
322
|
+
return True
|
|
323
|
+
completed = int(completed)
|
|
324
|
+
seat.reports_episodes = True
|
|
325
|
+
if completed == 0:
|
|
326
|
+
if seat.completed_episodes > 0:
|
|
327
|
+
return False
|
|
328
|
+
seat.scored_before_first_episode = True
|
|
329
|
+
return True
|
|
330
|
+
if seat.completed_episodes == 0 and seat.scored_before_first_episode:
|
|
331
|
+
seat.best_score = None
|
|
332
|
+
seat.scheduler.reset_scale()
|
|
333
|
+
seat.completed_episodes += completed
|
|
334
|
+
return True
|
|
335
|
+
|
|
291
336
|
def _update_seat(self, seat: _Seat, metrics: EvalMetrics, window_id: int) -> None:
|
|
292
337
|
score = float(metrics.primary_score)
|
|
293
338
|
seat.last_score = score
|
|
@@ -311,6 +356,9 @@ class MultiAgentRunner:
|
|
|
311
356
|
seat.converged = False
|
|
312
357
|
return
|
|
313
358
|
|
|
359
|
+
if seat.reports_episodes and seat.completed_episodes < self._min_completed_episodes:
|
|
360
|
+
return # too few finished episodes to call anything a plateau
|
|
361
|
+
|
|
314
362
|
prev_state = sched.current_state
|
|
315
363
|
sched.record_non_improvement()
|
|
316
364
|
state = sched.current_state
|
|
@@ -16,6 +16,7 @@ from typing import Any, Dict, Generator, Hashable, Optional
|
|
|
16
16
|
import numpy as np
|
|
17
17
|
|
|
18
18
|
from tensor_optix.core.types import EpisodeData
|
|
19
|
+
from tensor_optix.core.reward_shape import EPISODE_RETURNS_KEY, EpisodeReturnTracker
|
|
19
20
|
|
|
20
21
|
logger = logging.getLogger(__name__)
|
|
21
22
|
|
|
@@ -55,6 +56,8 @@ class ParallelMultiAgentPipeline:
|
|
|
55
56
|
self._agents = agents
|
|
56
57
|
self._window_size = window_size
|
|
57
58
|
self._window_counter = 0
|
|
59
|
+
# One cross-window episode-return tracker per seat.
|
|
60
|
+
self._return_trackers: Dict[Hashable, EpisodeReturnTracker] = {}
|
|
58
61
|
self._obs: Optional[Dict[Hashable, Any]] = None
|
|
59
62
|
self._needs_reset = True
|
|
60
63
|
# Optional Dict[AgentID, SeatEnvView] -- when given, each seat's raw
|
|
@@ -132,6 +135,14 @@ class ParallelMultiAgentPipeline:
|
|
|
132
135
|
truncated=data["truncated"],
|
|
133
136
|
infos=data["infos"],
|
|
134
137
|
episode_id=self._window_counter,
|
|
138
|
+
metadata={
|
|
139
|
+
EPISODE_RETURNS_KEY: self._return_trackers.setdefault(
|
|
140
|
+
aid, EpisodeReturnTracker()
|
|
141
|
+
).update(
|
|
142
|
+
data["rewards"],
|
|
143
|
+
[t or tr for t, tr in zip(data["terminated"], data["truncated"])],
|
|
144
|
+
),
|
|
145
|
+
},
|
|
135
146
|
final_obs=None if last_done else self._encode(aid, self._obs.get(aid)) if aid in self._obs else None,
|
|
136
147
|
)
|
|
137
148
|
yield window
|
|
@@ -98,6 +98,7 @@ class RLOptimizer:
|
|
|
98
98
|
checkpoint_confirmation: bool = False,
|
|
99
99
|
checkpoint_confirm_window: int = 3,
|
|
100
100
|
checkpoint_noise_k: float = 2.0,
|
|
101
|
+
min_completed_episodes_before_dormant: int = 10,
|
|
101
102
|
# ── Trial-level search (TrialOrchestrator) ────────────────────────
|
|
102
103
|
agent_factory: Optional[Callable[[Dict[str, Any]], BaseAgent]] = None,
|
|
103
104
|
pipeline_factory: Optional[Callable[[], BasePipeline]] = None,
|
|
@@ -152,6 +153,7 @@ class RLOptimizer:
|
|
|
152
153
|
checkpoint_confirmation=checkpoint_confirmation,
|
|
153
154
|
checkpoint_confirm_window=checkpoint_confirm_window,
|
|
154
155
|
checkpoint_noise_k=checkpoint_noise_k,
|
|
156
|
+
min_completed_episodes_before_dormant=min_completed_episodes_before_dormant,
|
|
155
157
|
checkpoint_dir=checkpoint_dir,
|
|
156
158
|
max_snapshots=max_snapshots,
|
|
157
159
|
rollback_on_degradation=rollback_on_degradation,
|
|
@@ -280,6 +282,7 @@ class RLOptimizer:
|
|
|
280
282
|
checkpoint_confirmation=kw["checkpoint_confirmation"],
|
|
281
283
|
checkpoint_confirm_window=kw["checkpoint_confirm_window"],
|
|
282
284
|
checkpoint_noise_k=kw["checkpoint_noise_k"],
|
|
285
|
+
min_completed_episodes_before_dormant=kw["min_completed_episodes_before_dormant"],
|
|
283
286
|
)
|
|
284
287
|
return controller
|
|
285
288
|
|
|
@@ -5,6 +5,7 @@ logger = logging.getLogger(__name__)
|
|
|
5
5
|
from typing import Any, Generator, Optional
|
|
6
6
|
from tensor_optix.core.base_pipeline import BasePipeline, EpisodeBoundaryFn
|
|
7
7
|
from tensor_optix.core.types import EpisodeData
|
|
8
|
+
from tensor_optix.core.reward_shape import EPISODE_RETURNS_KEY, EpisodeReturnTracker
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class BatchPipeline(BasePipeline):
|
|
@@ -53,6 +54,7 @@ class BatchPipeline(BasePipeline):
|
|
|
53
54
|
self._agent = agent
|
|
54
55
|
self._window_size = window_size
|
|
55
56
|
self._window_counter = 0
|
|
57
|
+
self._return_tracker = EpisodeReturnTracker()
|
|
56
58
|
self._obs = None
|
|
57
59
|
self._needs_reset = True
|
|
58
60
|
|
|
@@ -122,6 +124,11 @@ class BatchPipeline(BasePipeline):
|
|
|
122
124
|
self._obs = next_obs
|
|
123
125
|
|
|
124
126
|
last_done = terminated_flags[-1] or truncated_flags[-1]
|
|
127
|
+
# Full returns of the episodes that finished in this window,
|
|
128
|
+
# including the part of them collected in earlier windows.
|
|
129
|
+
episode_returns = self._return_tracker.update(
|
|
130
|
+
rewards, [t or tr for t, tr in zip(terminated_flags, truncated_flags)]
|
|
131
|
+
)
|
|
125
132
|
yield EpisodeData(
|
|
126
133
|
observations=np.array(observations),
|
|
127
134
|
actions=np.array(actions),
|
|
@@ -132,6 +139,7 @@ class BatchPipeline(BasePipeline):
|
|
|
132
139
|
episode_id=self._window_counter,
|
|
133
140
|
episode_starts=episode_start_indices,
|
|
134
141
|
final_obs=None if last_done else self._obs,
|
|
142
|
+
metadata={EPISODE_RETURNS_KEY: episode_returns},
|
|
135
143
|
)
|
|
136
144
|
self._window_counter += 1
|
|
137
145
|
|
|
@@ -3,6 +3,7 @@ from typing import Any, Callable, Generator, List, Optional
|
|
|
3
3
|
|
|
4
4
|
from tensor_optix.core.base_pipeline import BasePipeline
|
|
5
5
|
from tensor_optix.core.types import EpisodeData
|
|
6
|
+
from tensor_optix.core.reward_shape import EPISODE_RETURNS_KEY, EpisodeReturnTracker
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
class VectorBatchPipeline(BasePipeline):
|
|
@@ -78,6 +79,7 @@ class VectorBatchPipeline(BasePipeline):
|
|
|
78
79
|
self._async_envs = async_envs
|
|
79
80
|
self._vec_env = None
|
|
80
81
|
self._window_counter = 0
|
|
82
|
+
self._return_tracker = EpisodeReturnTracker(self._n_envs)
|
|
81
83
|
|
|
82
84
|
def set_agent(self, agent) -> None:
|
|
83
85
|
self._agent = agent
|
|
@@ -180,7 +182,14 @@ class VectorBatchPipeline(BasePipeline):
|
|
|
180
182
|
infos=all_infos,
|
|
181
183
|
episode_id=self._window_counter,
|
|
182
184
|
final_obs=final_obs_vec,
|
|
183
|
-
metadata={
|
|
185
|
+
metadata={
|
|
186
|
+
"n_envs": self._n_envs,
|
|
187
|
+
# Full per-env returns of episodes that finished this window.
|
|
188
|
+
EPISODE_RETURNS_KEY: self._return_tracker.update(
|
|
189
|
+
all_rewards,
|
|
190
|
+
[t or tr for t, tr in zip(all_terminated, all_truncated)],
|
|
191
|
+
),
|
|
192
|
+
},
|
|
184
193
|
)
|
|
185
194
|
self._window_counter += 1
|
|
186
195
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tensor-optix
|
|
3
|
-
Version: 2.0.
|
|
3
|
+
Version: 2.0.6
|
|
4
4
|
Summary: Autonomous training loop for any sequential learning model — PPO, DQN, SAC, TD3, Rainbow DQN, Recurrent PPO for TensorFlow, PyTorch, and JAX/Flax; distributed async actor-learner (IMPALA + V-trace)
|
|
5
5
|
Author: sup3rus3r
|
|
6
6
|
License-Expression: MIT
|
|
@@ -337,6 +337,7 @@ opt.best_snapshot # -> PolicySnapshot: best weights + EvalMetrics + Hyperparam
|
|
|
337
337
|
|
|
338
338
|
Loop state transitions: `ACTIVE` -> `COOLING` -> `DORMANT` -> watchdog shutdown or policy spawn.
|
|
339
339
|
|
|
340
|
+
- Scores are full episode returns, tracked across windows. A window in which no episode finished trains the agent but is not evaluated, and the loop cannot plateau before `min_completed_episodes_before_dormant` (default 10) episodes have finished (`0` for continuing tasks).
|
|
340
341
|
- Every non-improving eval counts toward `COOLING`/`DORMANT`, for on-policy and off-policy agents alike. While the score is flat the eval interval backs off (`backoff_factor`, default 2.0); set `backoff_factor=1.0` to evaluate every window.
|
|
341
342
|
- At `DORMANT` the loop stops by default. A `PolicyManagerCallback` with spawn budget remaining spawns a variant instead and training continues.
|
|
342
343
|
- `rollback_on_degradation=True` restores the best checkpoint when a degradation is confirmed (`min_consecutive_degradations` consecutive evals below `degradation_threshold x best`), for on-policy agents only - off-policy agents keep their weights because their replay buffer would immediately pull a restored policy back.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|