tensor-optix 2.0.5__tar.gz → 2.0.7__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.
Files changed (169) hide show
  1. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/PKG-INFO +3 -2
  2. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/README.md +2 -1
  3. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/pyproject.toml +1 -1
  4. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/torch_evaluator.py +13 -2
  5. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/tf_evaluator.py +13 -2
  6. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/config.py +1 -0
  7. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/backoff_scheduler.py +15 -0
  8. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/loop_controller.py +72 -0
  9. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/reward_shape.py +55 -0
  10. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/multi_agent/__init__.py +9 -2
  11. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/multi_agent/aec_pipeline.py +11 -0
  12. tensor_optix-2.0.7/tensor_optix/multi_agent/multi_agent_runtime.py +671 -0
  13. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/multi_agent/parallel_pipeline.py +11 -0
  14. tensor_optix-2.0.7/tensor_optix/multi_agent/self_play.py +292 -0
  15. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizer.py +3 -0
  16. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/pipeline/batch_pipeline.py +8 -0
  17. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/pipeline/vector_pipeline.py +10 -1
  18. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/PKG-INFO +3 -2
  19. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/SOURCES.txt +1 -0
  20. tensor_optix-2.0.5/tensor_optix/multi_agent/multi_agent_runtime.py +0 -359
  21. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/setup.cfg +0 -0
  22. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/__init__.py +0 -0
  23. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/__init__.py +0 -0
  24. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/__init__.py +0 -0
  25. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/flax_agent.py +0 -0
  26. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/flax_evaluator.py +0 -0
  27. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/__init__.py +0 -0
  28. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/torch_agent.py +0 -0
  29. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/__init__.py +0 -0
  30. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/tf_agent.py +0 -0
  31. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/__init__.py +0 -0
  32. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/flax_ppo.py +0 -0
  33. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_dqn.py +0 -0
  34. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_ppo.py +0 -0
  35. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_ppo_continuous.py +0 -0
  36. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_sac.py +0 -0
  37. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_td3.py +0 -0
  38. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_dqn.py +0 -0
  39. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_ppo.py +0 -0
  40. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_ppo_continuous.py +0 -0
  41. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_rainbow_dqn.py +0 -0
  42. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_recurrent_ppo.py +0 -0
  43. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_sac.py +0 -0
  44. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_td3.py +0 -0
  45. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/callbacks/__init__.py +0 -0
  46. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/callbacks/rich_dashboard.py +0 -0
  47. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/callbacks/tensorboard_callback.py +0 -0
  48. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/callbacks/wandb_callback.py +0 -0
  49. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/cli.py +0 -0
  50. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/__init__.py +0 -0
  51. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/async_callback.py +0 -0
  52. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/base_agent.py +0 -0
  53. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/base_evaluator.py +0 -0
  54. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/base_optimizer.py +0 -0
  55. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/base_pipeline.py +0 -0
  56. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/checkpoint_confirmation.py +0 -0
  57. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/checkpoint_registry.py +0 -0
  58. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/device.py +0 -0
  59. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/diagnostic_controller.py +0 -0
  60. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/ensemble_agent.py +0 -0
  61. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/her_buffer.py +0 -0
  62. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/meta_controller.py +0 -0
  63. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/noisy_linear.py +0 -0
  64. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/normalizers.py +0 -0
  65. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/obs_utils.py +0 -0
  66. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/policy_manager.py +0 -0
  67. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/regime_detector.py +0 -0
  68. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/replay_buffer.py +0 -0
  69. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/resume_state.py +0 -0
  70. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/trajectory_buffer.py +0 -0
  71. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/core/types.py +0 -0
  72. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/distributed/__init__.py +0 -0
  73. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/distributed/async_learner.py +0 -0
  74. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/distributed/vtrace.py +0 -0
  75. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/encoders/__init__.py +0 -0
  76. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/encoders/obs_encoder.py +0 -0
  77. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/encoders/obs_encoder_tf.py +0 -0
  78. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/exploration/__init__.py +0 -0
  79. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/exploration/rnd.py +0 -0
  80. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/factory.py +0 -0
  81. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/__init__.py +0 -0
  82. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/callback.py +0 -0
  83. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/provenance.py +0 -0
  84. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/records.py +0 -0
  85. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/schema.py +0 -0
  86. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ledger/store.py +0 -0
  87. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml/__init__.py +0 -0
  88. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml/dataset_pipeline.py +0 -0
  89. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml/loss_registry.py +0 -0
  90. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml/ml_agent.py +0 -0
  91. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/__init__.py +0 -0
  92. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/__init__.py +0 -0
  93. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/flax_model.py +0 -0
  94. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/tf_model.py +0 -0
  95. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/torch_model.py +0 -0
  96. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/base_model.py +0 -0
  97. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/lr_schedules.py +0 -0
  98. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics.py +0 -0
  99. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/__init__.py +0 -0
  100. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/classification.py +0 -0
  101. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/regression.py +0 -0
  102. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/trainer.py +0 -0
  103. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/ml_core/transfer.py +0 -0
  104. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/multi_agent/multi_agent_episode.py +0 -0
  105. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/multi_agent/seat_env.py +0 -0
  106. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/__init__.py +0 -0
  107. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/abstention.py +0 -0
  108. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/features.py +0 -0
  109. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/pooling.py +0 -0
  110. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/selector.py +0 -0
  111. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/nanonets/smalln.py +0 -0
  112. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/__init__.py +0 -0
  113. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/agent/__init__.py +0 -0
  114. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/agent/graph_agent.py +0 -0
  115. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/brain_network.py +0 -0
  116. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/__init__.py +0 -0
  117. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/topology_callback.py +0 -0
  118. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/topology_controller.py +0 -0
  119. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/__init__.py +0 -0
  120. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/neuron.py +0 -0
  121. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/neuron_graph.py +0 -0
  122. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/topology_ops.py +0 -0
  123. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/hebbian.py +0 -0
  124. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/neuromodulator.py +0 -0
  125. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/optimizer/__init__.py +0 -0
  126. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/neuroevo/optimizer/topology_aware_adam.py +0 -0
  127. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/__init__.py +0 -0
  128. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/adaptive_optimizer.py +0 -0
  129. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/backoff_optimizer.py +0 -0
  130. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/momentum_optimizer.py +0 -0
  131. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/pbt_optimizer.py +0 -0
  132. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/optimizers/spsa_optimizer.py +0 -0
  133. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/orchestrator.py +0 -0
  134. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/pipeline/__init__.py +0 -0
  135. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/pipeline/live_pipeline.py +0 -0
  136. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/__init__.py +0 -0
  137. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/baseline.py +0 -0
  138. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/experiment_stage.py +0 -0
  139. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/live_runtime.py +0 -0
  140. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/observer.py +0 -0
  141. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/runtime/promote.py +0 -0
  142. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/__init__.py +0 -0
  143. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/_mp_common.py +0 -0
  144. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/budget.py +0 -0
  145. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/dedup.py +0 -0
  146. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/isolation.py +0 -0
  147. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/pool.py +0 -0
  148. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/retry.py +0 -0
  149. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/scheduler/worker.py +0 -0
  150. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/selection/__init__.py +0 -0
  151. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/selection/backfill.py +0 -0
  152. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/selection/selector.py +0 -0
  153. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/selection/uncertainty.py +0 -0
  154. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/simple.py +0 -0
  155. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/__init__.py +0 -0
  156. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/candidate.py +0 -0
  157. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/comparator.py +0 -0
  158. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/grammar.py +0 -0
  159. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/promotion.py +0 -0
  160. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/runner.py +0 -0
  161. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/strategy/worker.py +0 -0
  162. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/utils/__init__.py +0 -0
  163. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/utils/console.py +0 -0
  164. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix/utils/window_size.py +0 -0
  165. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/dependency_links.txt +0 -0
  166. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/entry_points.txt +0 -0
  167. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/requires.txt +0 -0
  168. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/tensor_optix.egg-info/top_level.txt +0 -0
  169. {tensor_optix-2.0.5 → tensor_optix-2.0.7}/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.5
3
+ Version: 2.0.7
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
@@ -306,7 +306,7 @@ pipeline = AECMultiAgentPipeline(env, agents, window_size=400, views=views)
306
306
  MultiAgentRunner(pipeline, agents).run(max_windows=500)
307
307
  ```
308
308
 
309
- In turn-based games each reward (including the terminal win/loss) is credited to the action that earned it. `MultiAgentRunner` scores every seat each window, checkpoints each seat's best weights (`checkpoint_dir=`), detects per-seat convergence with the same trend test as the single-agent loop, and stops once every seat has converged (`stop_when="any"` for the first), restoring best weights. See [Multi-agent training](https://sup3rus3r.github.io/tensor-optix/guides/multi-agent/).
309
+ In turn-based games each reward (including the terminal win/loss) is credited to the action that earned it. `MultiAgentRunner` scores every seat each window, checkpoints each seat's best weights (`checkpoint_dir=`), detects per-seat convergence with the same trend test as the single-agent loop, and stops once every seat has converged (`stop_when="any"` for the first), restoring best weights. Each seat's hyperparameters are tuned online by its own optimizer (SPSA by default, `optimizer=None` to disable). `rollback_on_degradation=True` restores a seat's best checkpoint mid-run if its score collapses. For competitive games, `self_play=SelfPlayConfig(...)` lets seats train against a pool of past snapshots of their opponents, and `SelfPlayPipeline` turns a symmetric game into a single-agent pipeline (the other seats are played by past versions of the learner) so `RLOptimizer` can drive one learner with the full loop. See [Multi-agent training](https://sup3rus3r.github.io/tensor-optix/guides/multi-agent/).
310
310
 
311
311
  ---
312
312
 
@@ -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.
@@ -235,7 +235,7 @@ pipeline = AECMultiAgentPipeline(env, agents, window_size=400, views=views)
235
235
  MultiAgentRunner(pipeline, agents).run(max_windows=500)
236
236
  ```
237
237
 
238
- In turn-based games each reward (including the terminal win/loss) is credited to the action that earned it. `MultiAgentRunner` scores every seat each window, checkpoints each seat's best weights (`checkpoint_dir=`), detects per-seat convergence with the same trend test as the single-agent loop, and stops once every seat has converged (`stop_when="any"` for the first), restoring best weights. See [Multi-agent training](https://sup3rus3r.github.io/tensor-optix/guides/multi-agent/).
238
+ In turn-based games each reward (including the terminal win/loss) is credited to the action that earned it. `MultiAgentRunner` scores every seat each window, checkpoints each seat's best weights (`checkpoint_dir=`), detects per-seat convergence with the same trend test as the single-agent loop, and stops once every seat has converged (`stop_when="any"` for the first), restoring best weights. Each seat's hyperparameters are tuned online by its own optimizer (SPSA by default, `optimizer=None` to disable). `rollback_on_degradation=True` restores a seat's best checkpoint mid-run if its score collapses. For competitive games, `self_play=SelfPlayConfig(...)` lets seats train against a pool of past snapshots of their opponents, and `SelfPlayPipeline` turns a symmetric game into a single-agent pipeline (the other seats are played by past versions of the learner) so `RLOptimizer` can drive one learner with the full loop. See [Multi-agent training](https://sup3rus3r.github.io/tensor-optix/guides/multi-agent/).
239
239
 
240
240
  ---
241
241
 
@@ -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.5"
7
+ version = "2.0.7"
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
- primary = self._mean_episode_return(rewards, dones, n_envs)
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
- primary = self._mean_episode_return(rewards, dones, n_envs)
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,
@@ -16,8 +16,11 @@ per-seat convergence detection (BackoffScheduler) and best-snapshot
16
16
  checkpointing (CheckpointRegistry); the run stops when all seats (or any
17
17
  seat, configurable) have converged, and restores each seat's best weights.
18
18
 
19
- Out of scope for this package: shared/self-play policies across seats,
20
- online hyperparameter tuning and degradation rollback per seat, and
19
+ Each seat's hyperparameters are tuned online by its own optimizer, and
20
+ SelfPlayConfig / SelfPlayPipeline provide frozen-opponent self-play.
21
+
22
+ Out of scope for this package: one policy shared across seats, degradation
23
+ rollback and policy spawning per seat, and
21
24
  vectorizing across multiple copies of a multi-agent environment.
22
25
  """
23
26
  from tensor_optix.multi_agent.seat_env import SeatEnvView
@@ -29,6 +32,7 @@ from tensor_optix.multi_agent.multi_agent_runtime import (
29
32
  MultiAgentRunner,
30
33
  SeatResult,
31
34
  )
35
+ from tensor_optix.multi_agent.self_play import OpponentPool, SelfPlayConfig, SelfPlayPipeline
32
36
 
33
37
  __all__ = [
34
38
  "SeatEnvView",
@@ -38,4 +42,7 @@ __all__ = [
38
42
  "MultiAgentCallback",
39
43
  "MultiAgentRunResult",
40
44
  "SeatResult",
45
+ "SelfPlayConfig",
46
+ "SelfPlayPipeline",
47
+ "OpponentPool",
41
48
  ]
@@ -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