tensor-optix 2.0.6__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 (168) hide show
  1. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/PKG-INFO +2 -2
  2. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/README.md +1 -1
  3. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/pyproject.toml +1 -1
  4. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/__init__.py +9 -2
  5. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/multi_agent_runtime.py +269 -5
  6. tensor_optix-2.0.7/tensor_optix/multi_agent/self_play.py +292 -0
  7. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/PKG-INFO +2 -2
  8. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/SOURCES.txt +1 -0
  9. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/setup.cfg +0 -0
  10. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/__init__.py +0 -0
  11. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/__init__.py +0 -0
  12. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/__init__.py +0 -0
  13. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/flax_agent.py +0 -0
  14. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/jax/flax_evaluator.py +0 -0
  15. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/__init__.py +0 -0
  16. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/torch_agent.py +0 -0
  17. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/pytorch/torch_evaluator.py +0 -0
  18. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/__init__.py +0 -0
  19. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/tf_agent.py +0 -0
  20. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/adapters/tensorflow/tf_evaluator.py +0 -0
  21. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/__init__.py +0 -0
  22. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/flax_ppo.py +0 -0
  23. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_dqn.py +0 -0
  24. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_ppo.py +0 -0
  25. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_ppo_continuous.py +0 -0
  26. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_sac.py +0 -0
  27. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/tf_td3.py +0 -0
  28. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_dqn.py +0 -0
  29. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_ppo.py +0 -0
  30. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_ppo_continuous.py +0 -0
  31. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_rainbow_dqn.py +0 -0
  32. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_recurrent_ppo.py +0 -0
  33. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_sac.py +0 -0
  34. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/algorithms/torch_td3.py +0 -0
  35. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/callbacks/__init__.py +0 -0
  36. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/callbacks/rich_dashboard.py +0 -0
  37. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/callbacks/tensorboard_callback.py +0 -0
  38. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/callbacks/wandb_callback.py +0 -0
  39. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/cli.py +0 -0
  40. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/config.py +0 -0
  41. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/__init__.py +0 -0
  42. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/async_callback.py +0 -0
  43. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/backoff_scheduler.py +0 -0
  44. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/base_agent.py +0 -0
  45. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/base_evaluator.py +0 -0
  46. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/base_optimizer.py +0 -0
  47. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/base_pipeline.py +0 -0
  48. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/checkpoint_confirmation.py +0 -0
  49. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/checkpoint_registry.py +0 -0
  50. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/device.py +0 -0
  51. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/diagnostic_controller.py +0 -0
  52. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/ensemble_agent.py +0 -0
  53. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/her_buffer.py +0 -0
  54. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/loop_controller.py +0 -0
  55. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/meta_controller.py +0 -0
  56. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/noisy_linear.py +0 -0
  57. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/normalizers.py +0 -0
  58. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/obs_utils.py +0 -0
  59. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/policy_manager.py +0 -0
  60. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/regime_detector.py +0 -0
  61. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/replay_buffer.py +0 -0
  62. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/resume_state.py +0 -0
  63. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/reward_shape.py +0 -0
  64. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/trajectory_buffer.py +0 -0
  65. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/core/types.py +0 -0
  66. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/distributed/__init__.py +0 -0
  67. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/distributed/async_learner.py +0 -0
  68. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/distributed/vtrace.py +0 -0
  69. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/encoders/__init__.py +0 -0
  70. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/encoders/obs_encoder.py +0 -0
  71. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/encoders/obs_encoder_tf.py +0 -0
  72. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/exploration/__init__.py +0 -0
  73. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/exploration/rnd.py +0 -0
  74. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/factory.py +0 -0
  75. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/__init__.py +0 -0
  76. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/callback.py +0 -0
  77. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/provenance.py +0 -0
  78. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/records.py +0 -0
  79. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/schema.py +0 -0
  80. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ledger/store.py +0 -0
  81. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml/__init__.py +0 -0
  82. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml/dataset_pipeline.py +0 -0
  83. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml/loss_registry.py +0 -0
  84. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml/ml_agent.py +0 -0
  85. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/__init__.py +0 -0
  86. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/__init__.py +0 -0
  87. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/flax_model.py +0 -0
  88. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/tf_model.py +0 -0
  89. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/adapters/torch_model.py +0 -0
  90. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/base_model.py +0 -0
  91. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/lr_schedules.py +0 -0
  92. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics.py +0 -0
  93. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/__init__.py +0 -0
  94. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/classification.py +0 -0
  95. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/metrics_impl/regression.py +0 -0
  96. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/trainer.py +0 -0
  97. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/ml_core/transfer.py +0 -0
  98. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/aec_pipeline.py +0 -0
  99. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/multi_agent_episode.py +0 -0
  100. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/parallel_pipeline.py +0 -0
  101. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/multi_agent/seat_env.py +0 -0
  102. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/__init__.py +0 -0
  103. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/abstention.py +0 -0
  104. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/features.py +0 -0
  105. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/pooling.py +0 -0
  106. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/selector.py +0 -0
  107. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/nanonets/smalln.py +0 -0
  108. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/__init__.py +0 -0
  109. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/agent/__init__.py +0 -0
  110. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/agent/graph_agent.py +0 -0
  111. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/brain_network.py +0 -0
  112. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/__init__.py +0 -0
  113. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/topology_callback.py +0 -0
  114. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/controller/topology_controller.py +0 -0
  115. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/__init__.py +0 -0
  116. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/neuron.py +0 -0
  117. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/neuron_graph.py +0 -0
  118. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/graph/topology_ops.py +0 -0
  119. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/hebbian.py +0 -0
  120. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/neuromodulator.py +0 -0
  121. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/optimizer/__init__.py +0 -0
  122. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/neuroevo/optimizer/topology_aware_adam.py +0 -0
  123. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizer.py +0 -0
  124. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/__init__.py +0 -0
  125. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/adaptive_optimizer.py +0 -0
  126. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/backoff_optimizer.py +0 -0
  127. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/momentum_optimizer.py +0 -0
  128. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/pbt_optimizer.py +0 -0
  129. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/optimizers/spsa_optimizer.py +0 -0
  130. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/orchestrator.py +0 -0
  131. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/pipeline/__init__.py +0 -0
  132. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/pipeline/batch_pipeline.py +0 -0
  133. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/pipeline/live_pipeline.py +0 -0
  134. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/pipeline/vector_pipeline.py +0 -0
  135. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/__init__.py +0 -0
  136. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/baseline.py +0 -0
  137. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/experiment_stage.py +0 -0
  138. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/live_runtime.py +0 -0
  139. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/observer.py +0 -0
  140. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/runtime/promote.py +0 -0
  141. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/__init__.py +0 -0
  142. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/_mp_common.py +0 -0
  143. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/budget.py +0 -0
  144. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/dedup.py +0 -0
  145. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/isolation.py +0 -0
  146. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/pool.py +0 -0
  147. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/retry.py +0 -0
  148. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/scheduler/worker.py +0 -0
  149. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/selection/__init__.py +0 -0
  150. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/selection/backfill.py +0 -0
  151. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/selection/selector.py +0 -0
  152. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/selection/uncertainty.py +0 -0
  153. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/simple.py +0 -0
  154. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/__init__.py +0 -0
  155. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/candidate.py +0 -0
  156. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/comparator.py +0 -0
  157. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/grammar.py +0 -0
  158. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/promotion.py +0 -0
  159. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/runner.py +0 -0
  160. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/strategy/worker.py +0 -0
  161. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/utils/__init__.py +0 -0
  162. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/utils/console.py +0 -0
  163. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix/utils/window_size.py +0 -0
  164. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/dependency_links.txt +0 -0
  165. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/entry_points.txt +0 -0
  166. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/requires.txt +0 -0
  167. {tensor_optix-2.0.6 → tensor_optix-2.0.7}/tensor_optix.egg-info/top_level.txt +0 -0
  168. {tensor_optix-2.0.6 → 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.6
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
 
@@ -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
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "tensor-optix"
7
- version = "2.0.6"
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"
@@ -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
  ]
@@ -15,9 +15,15 @@ What "converged" means for the run as a whole is an explicit choice
15
15
  competitive game one seat plateauing while its opponent is still improving
16
16
  is not convergence, it is one side losing ground.
17
17
 
18
- Not done here (single-agent LoopController features with no obvious
19
- multi-agent meaning yet): online hyperparameter tuning, degradation
20
- rollback during training, policy spawning.
18
+ Each seat's hyperparameters are tuned online by its own optimizer (SPSA by
19
+ default, like RLOptimizer), and `self_play=SelfPlayConfig(...)` lets seats
20
+ train against past snapshots of their opponents.
21
+
22
+ `rollback_on_degradation=True` restores a seat's best checkpoint mid-run
23
+ when its score has confirmedly dropped.
24
+
25
+ Not done here (single-agent LoopController feature with no obvious
26
+ multi-agent meaning yet): policy spawning.
21
27
  """
22
28
  from __future__ import annotations
23
29
 
@@ -27,11 +33,21 @@ from dataclasses import dataclass, field
27
33
  from typing import Any, Dict, Hashable, List, Optional
28
34
 
29
35
  from tensor_optix.core.backoff_scheduler import BackoffScheduler
36
+ from tensor_optix.core.base_optimizer import BaseOptimizer
30
37
  from tensor_optix.core.checkpoint_registry import CheckpointRegistry
31
38
  from tensor_optix.core.types import EvalMetrics, HyperparamSet, LoopState, PolicySnapshot
32
39
 
40
+ from tensor_optix.multi_agent.self_play import (
41
+ OpponentPool,
42
+ SelfPlayConfig,
43
+ discard_rollout,
44
+ make_stand_in,
45
+ )
46
+
33
47
  logger = logging.getLogger(__name__)
34
48
 
49
+ _METRICS_HISTORY_LEN = 200
50
+
35
51
 
36
52
  class MultiAgentCallback:
37
53
  """
@@ -44,6 +60,8 @@ class MultiAgentCallback:
44
60
  def on_improvement(self, agent_id: Hashable, snapshot: Optional[PolicySnapshot], score: float) -> None: ...
45
61
  def on_plateau(self, agent_id: Hashable, window_id: int) -> None: ...
46
62
  def on_converged(self, agent_id: Hashable, window_id: int) -> None: ...
63
+ def on_hyperparam_update(self, agent_id: Hashable, old_params: dict, new_params: dict) -> None: ...
64
+ def on_degradation(self, agent_id: Hashable, window_id: int, score: float, rolled_back: bool) -> None: ...
47
65
  def on_run_stop(self, reason: str) -> None: ...
48
66
 
49
67
 
@@ -58,6 +76,10 @@ class SeatResult:
58
76
  best_score: Optional[float]
59
77
  last_score: Optional[float]
60
78
  best_snapshot: Optional[PolicySnapshot]
79
+ frozen_windows: int = 0 # windows this seat was played by a pool snapshot
80
+ degradations: int = 0 # confirmed degradations
81
+ rollbacks: int = 0 # of which restored the best checkpoint
82
+ hyperparams: Optional[dict] = None # the seat's hyperparameters at the end of the run
61
83
 
62
84
 
63
85
  @dataclass
@@ -66,6 +88,7 @@ class MultiAgentRunResult:
66
88
  windows_run: int
67
89
  stop_reason: str # "converged" | "max_windows" | "stopped" | "pipeline_exhausted"
68
90
  seats: Dict[Hashable, SeatResult] = field(default_factory=dict)
91
+ pool_sizes: Dict[Hashable, int] = field(default_factory=dict) # self-play snapshots per seat
69
92
 
70
93
  @property
71
94
  def converged(self) -> bool:
@@ -73,11 +96,18 @@ class MultiAgentRunResult:
73
96
 
74
97
 
75
98
  class _Seat:
76
- def __init__(self, agent_id, agent, scheduler: BackoffScheduler, registry: Optional[CheckpointRegistry]):
99
+ def __init__(self, agent_id, agent, scheduler: BackoffScheduler,
100
+ registry: Optional[CheckpointRegistry], optimizer: Optional[BaseOptimizer] = None):
77
101
  self.agent_id = agent_id
78
102
  self.agent = agent
79
103
  self.scheduler = scheduler
80
104
  self.registry = registry
105
+ self.optimizer = optimizer
106
+ self.metrics_history: List[EvalMetrics] = []
107
+ self.frozen_windows = 0
108
+ self.consecutive_degraded = 0
109
+ self.degradations = 0
110
+ self.rollbacks = 0
81
111
  self.best_score: Optional[float] = None
82
112
  self.last_score: Optional[float] = None
83
113
  self.best_snapshot: Optional[PolicySnapshot] = None
@@ -120,6 +150,32 @@ class MultiAgentRunner:
120
150
  is skipped for that window — not learned, not scored, and it does not
121
151
  count toward that seat's plateau counter.
122
152
 
153
+ Hyperparameter tuning: after every scored window the seat's optimizer
154
+ is shown that seat's score history and may adjust its hyperparameters
155
+ (`on_hyperparam_update` fires when it does). Windows that are not
156
+ scored do not step the optimizer.
157
+
158
+ Self-play pool (`self_play=SelfPlayConfig(...)`): every
159
+ `snapshot_every` windows each seat's weights are saved to that seat's
160
+ pool. Each window, a seat is played by a random past snapshot of itself
161
+ with probability `opponent_prob` — it then neither learns nor is scored
162
+ for that window — while the remaining live seats train against it. At
163
+ least one seat is always live. Live agents are put back before the run
164
+ returns.
165
+
166
+ Rollback (`rollback_on_degradation=True`): when a seat's score stays
167
+ clearly below its best for `min_consecutive_degradations` scored
168
+ windows in a row, `on_degradation` fires and — for on-policy agents with
169
+ a checkpoint — the seat's best weights are restored and training
170
+ continues. Off-policy agents are never rolled back (their replay buffer
171
+ would pull restored weights straight back). A score also drops when the
172
+ OPPONENT improves, which is not a collapse: with self-play enabled only
173
+ windows played against at least one frozen (pool) opponent count, since
174
+ those are the windows where the opposition did not change. Without
175
+ self-play, use rollback for cooperative games; in a competitive game it
176
+ would undo real learning. Probe windows of the seat's optimizer never
177
+ count.
178
+
123
179
  Scores are full episode returns, tracked across windows by the
124
180
  pipeline. A window in which a seat finished no episode still trains
125
181
  that seat but is not scored (no checkpoint, no plateau count). Until a
@@ -144,6 +200,26 @@ class MultiAgentRunner:
144
200
  per-seat BackoffScheduler settings (same
145
201
  meaning as RLOptimizer's). Each seat is
146
202
  evaluated every window (no eval backoff).
203
+ optimizer: per-seat online hyperparameter tuning.
204
+ "auto" (default): an SPSAOptimizer over the
205
+ agent's default_param_bounds, for every seat
206
+ whose agent declares them. None: no tuning.
207
+ A callable(agent) -> BaseOptimizer builds one
208
+ per seat; a dict {agent_id: BaseOptimizer or
209
+ None} assigns them explicitly. Optimizers are
210
+ stateful, so a single instance cannot be
211
+ shared between seats.
212
+ self_play: SelfPlayConfig enabling the frozen-opponent
213
+ pool (see below). None (default) = off.
214
+ rollback_on_degradation:
215
+ restore a seat's best checkpoint mid-run on a
216
+ confirmed degradation (see below). Requires
217
+ checkpoint_dir. Default False.
218
+ degradation_threshold: a window is "degraded" when the seat's score
219
+ is below best - max(|best| * (1 - threshold),
220
+ the seat's noise floor). Default 0.95.
221
+ min_consecutive_degradations:
222
+ degraded windows in a row needed to confirm.
147
223
  stop_when: "all" | "any".
148
224
  stop_on_convergence: False = only max_windows / stop() end the run.
149
225
  restore_best: restore each seat's best snapshot at the end.
@@ -166,6 +242,11 @@ class MultiAgentRunner:
166
242
  noise_k: float = 2.0,
167
243
  score_window: int = 20,
168
244
  trend_window: int = 8,
245
+ optimizer: Any = "auto",
246
+ self_play: Optional[SelfPlayConfig] = None,
247
+ rollback_on_degradation: bool = False,
248
+ degradation_threshold: float = 0.95,
249
+ min_consecutive_degradations: int = 3,
169
250
  stop_when: str = "all",
170
251
  stop_on_convergence: bool = True,
171
252
  restore_best: bool = True,
@@ -183,6 +264,22 @@ class MultiAgentRunner:
183
264
  self._callbacks: List[Any] = list(callbacks or [])
184
265
  self._stop_requested = False
185
266
 
267
+ if rollback_on_degradation and checkpoint_dir is None:
268
+ raise ValueError("rollback_on_degradation=True requires checkpoint_dir (there is nothing to roll back to).")
269
+ self._rollback_on_degradation = rollback_on_degradation
270
+ self._degradation_threshold = float(degradation_threshold)
271
+ self._min_consecutive_degradations = max(1, int(min_consecutive_degradations))
272
+
273
+ self._self_play = self_play
274
+ if self_play is not None and not hasattr(pipeline, "set_agents"):
275
+ raise TypeError(
276
+ "self_play requires a pipeline exposing set_agents() "
277
+ "(ParallelMultiAgentPipeline / AECMultiAgentPipeline)."
278
+ )
279
+ self._pool: Optional[OpponentPool] = None
280
+ self._stand_ins: Dict[Hashable, Any] = {}
281
+ self._frozen: set = set()
282
+
186
283
  if evaluator is None:
187
284
  # Framework-agnostic despite the name: numpy-only mean episode return.
188
285
  from tensor_optix.adapters.pytorch.torch_evaluator import TorchEvaluator
@@ -213,7 +310,10 @@ class MultiAgentRunner:
213
310
  score_window=score_window,
214
311
  trend_window=trend_window,
215
312
  )
216
- self._seats[aid] = _Seat(aid, agent, scheduler, registry)
313
+ self._seats[aid] = _Seat(
314
+ aid, agent, scheduler, registry,
315
+ optimizer=_resolve_optimizer(optimizer, aid, agent, len(agents)),
316
+ )
217
317
 
218
318
  # ------------------------------------------------------------------
219
319
  # Public API
@@ -244,6 +344,11 @@ class MultiAgentRunner:
244
344
  self._fire("on_run_start")
245
345
  windows_run = 0
246
346
  stop_reason = "pipeline_exhausted"
347
+ if self._self_play is not None:
348
+ self._pool = OpponentPool(
349
+ self._self_play.pool_size, self._self_play.pool_dir, self._self_play.seed
350
+ )
351
+ self._frozen = set()
247
352
  try:
248
353
  for window in self._pipeline.episodes():
249
354
  window_metrics: Dict[Hashable, EvalMetrics] = {}
@@ -253,6 +358,13 @@ class MultiAgentRunner:
253
358
  seat = self._seats.get(aid)
254
359
  if seat is None:
255
360
  continue
361
+ if aid in self._frozen:
362
+ # Played by a pool snapshot this window: the live
363
+ # agent did not act, so it has nothing to learn from
364
+ # and no score of its own.
365
+ seat.frozen_windows += 1
366
+ discard_rollout(self._stand_ins[aid])
367
+ continue
256
368
  diagnostics = seat.agent.learn(episode_data) or {}
257
369
  metrics = self._evaluators[aid].score(episode_data, diagnostics)
258
370
  metrics.episode_id = windows_run
@@ -265,6 +377,8 @@ class MultiAgentRunner:
265
377
 
266
378
  self._fire("on_window_end", windows_run, window_metrics)
267
379
  windows_run += 1
380
+ if self._pool is not None:
381
+ self._advance_self_play(windows_run)
268
382
 
269
383
  if self._stop_requested:
270
384
  stop_reason = "stopped"
@@ -280,6 +394,14 @@ class MultiAgentRunner:
280
394
  stop_reason = "max_windows"
281
395
  break
282
396
  finally:
397
+ pool_sizes: Dict[Hashable, int] = {}
398
+ if self._pool is not None:
399
+ pool_sizes = self._pool.sizes()
400
+ # Hand the pipeline its live agents back before anything else.
401
+ self._pipeline.set_agents(dict(self._agents))
402
+ self._frozen = set()
403
+ self._pool.cleanup()
404
+ self._pool = None
283
405
  try:
284
406
  if self._restore_best:
285
407
  self._restore_best_weights()
@@ -300,9 +422,14 @@ class MultiAgentRunner:
300
422
  best_score=seat.best_score,
301
423
  last_score=seat.last_score,
302
424
  best_snapshot=seat.best_snapshot,
425
+ frozen_windows=seat.frozen_windows,
426
+ degradations=seat.degradations,
427
+ rollbacks=seat.rollbacks,
428
+ hyperparams=dict(_hyperparams_of(seat.agent, windows_run).params),
303
429
  )
304
430
  for aid, seat in self._seats.items()
305
431
  },
432
+ pool_sizes=pool_sizes,
306
433
  )
307
434
 
308
435
  # ------------------------------------------------------------------
@@ -347,6 +474,14 @@ class MultiAgentRunner:
347
474
  )
348
475
  self._fire("on_improvement", seat.agent_id, seat.best_snapshot, score)
349
476
 
477
+ seat.metrics_history.append(metrics)
478
+ if len(seat.metrics_history) > _METRICS_HISTORY_LEN:
479
+ del seat.metrics_history[:-_METRICS_HISTORY_LEN]
480
+
481
+ self._update_convergence(seat, metrics, score, window_id)
482
+ self._tune(seat)
483
+
484
+ def _update_convergence(self, seat: _Seat, metrics: EvalMetrics, score: float, window_id: int) -> None:
350
485
  # --- convergence: trend over the seat's recent scores ---
351
486
  sched = seat.scheduler
352
487
  first = sched.best_score is None
@@ -354,8 +489,14 @@ class MultiAgentRunner:
354
489
  if first or sched.is_improving():
355
490
  sched.record_improvement(score, append=False)
356
491
  seat.converged = False
492
+ seat.consecutive_degraded = 0
493
+ if seat.optimizer is not None:
494
+ seat.optimizer.on_improvement(metrics)
357
495
  return
358
496
 
497
+ if self._check_degradation(seat, score, window_id):
498
+ return # a degraded window is a collapse in progress, not a plateau
499
+
359
500
  if seat.reports_episodes and seat.completed_episodes < self._min_completed_episodes:
360
501
  return # too few finished episodes to call anything a plateau
361
502
 
@@ -367,8 +508,101 @@ class MultiAgentRunner:
367
508
  elif state == LoopState.DORMANT and not seat.converged:
368
509
  seat.converged = True
369
510
  logger.info("MultiAgentRunner: seat %r converged at window %d", seat.agent_id, window_id)
511
+ if seat.optimizer is not None:
512
+ seat.optimizer.on_plateau(seat.metrics_history)
370
513
  self._fire("on_converged", seat.agent_id, window_id)
371
514
 
515
+ def _check_degradation(self, seat: _Seat, score: float, window_id: int) -> bool:
516
+ """Count degraded windows; on confirmation fire on_degradation and
517
+ (when enabled and safe) roll the seat back.
518
+
519
+ Returns True when this window is degraded (confirmed or not): such a
520
+ window must not count toward the plateau counter, or a collapsed seat
521
+ would be declared converged at its collapsed level between rollbacks.
522
+ """
523
+ if not self._rollback_on_degradation or seat.best_score is None:
524
+ return False
525
+ if seat.optimizer is not None and getattr(seat.optimizer, "is_probing", False):
526
+ return False # a probe's score drop is self-inflicted
527
+ if self._pool is not None and not (self._frozen - {seat.agent_id}):
528
+ # Self-play is on and every opponent was live this window: a drop
529
+ # may simply be the opponent improving. Neither count nor reset.
530
+ return False
531
+
532
+ best = seat.best_score
533
+ allowed_drop = max(
534
+ abs(best) * (1.0 - self._degradation_threshold),
535
+ seat.scheduler._adaptive_floor(),
536
+ )
537
+ if score >= best - allowed_drop:
538
+ seat.consecutive_degraded = 0
539
+ return False
540
+
541
+ seat.consecutive_degraded += 1
542
+ if seat.consecutive_degraded < self._min_consecutive_degradations:
543
+ return True
544
+
545
+ seat.consecutive_degraded = 0
546
+ seat.degradations += 1
547
+ rolled_back = False
548
+ if (
549
+ getattr(seat.agent, "is_on_policy", True)
550
+ and seat.registry is not None
551
+ and seat.best_snapshot is not None
552
+ ):
553
+ seat.registry.load_best(seat.agent)
554
+ discard_rollout(seat.agent)
555
+ seat.rollbacks += 1
556
+ rolled_back = True
557
+ logger.info(
558
+ "MultiAgentRunner: seat %r degraded (score=%.4f, best=%.4f) — rolled back at window %d",
559
+ seat.agent_id, score, best, window_id,
560
+ )
561
+ seat.scheduler.record_degradation()
562
+ seat.scheduler._consecutive_non_improvements = 0
563
+ seat.converged = False
564
+ self._fire("on_degradation", seat.agent_id, window_id, score, rolled_back)
565
+ return True
566
+
567
+ def _tune(self, seat: _Seat) -> None:
568
+ """One online hyperparameter step for this seat (after a scored window)."""
569
+ if seat.optimizer is None:
570
+ return
571
+ current = seat.agent.get_hyperparams()
572
+ old_params = dict(current.params)
573
+ suggested = seat.optimizer.suggest(current, seat.metrics_history)
574
+ seat.agent.set_hyperparams(suggested)
575
+ if suggested.params != old_params:
576
+ self._fire("on_hyperparam_update", seat.agent_id, old_params, dict(suggested.params))
577
+
578
+ def _advance_self_play(self, windows_run: int) -> None:
579
+ """Snapshot on schedule, then choose who is frozen for the next window."""
580
+ cfg = self._self_play
581
+ if windows_run % cfg.snapshot_every == 0:
582
+ for aid, seat in self._seats.items():
583
+ self._pool.add(aid, seat.agent)
584
+
585
+ rng = self._pool.rng
586
+ frozen = {
587
+ aid for aid in self._seats
588
+ if self._pool.size(aid) > 0 and rng.random() < cfg.opponent_prob
589
+ }
590
+ if len(frozen) >= len(self._seats):
591
+ # Somebody has to be learning.
592
+ frozen.discard(rng.choice(sorted(frozen, key=str)))
593
+
594
+ mapping = dict(self._agents)
595
+ for aid in frozen:
596
+ stand_in = self._stand_ins.get(aid)
597
+ if stand_in is None:
598
+ stand_in = make_stand_in(self._agents[aid], aid, cfg.opponent_factory)
599
+ self._stand_ins[aid] = stand_in
600
+ discard_rollout(stand_in)
601
+ self._pool.load_into(aid, stand_in, self._agents[aid])
602
+ mapping[aid] = stand_in
603
+ self._frozen = frozen
604
+ self._pipeline.set_agents(mapping)
605
+
372
606
  def _run_converged(self) -> bool:
373
607
  flags = [seat.converged for seat in self._seats.values()]
374
608
  if not flags:
@@ -402,6 +636,36 @@ def _hyperparams_of(agent, window_id: int) -> HyperparamSet:
402
636
  return HyperparamSet(params={}, episode_id=window_id)
403
637
 
404
638
 
639
+ def _resolve_optimizer(spec: Any, agent_id: Hashable, agent: Any, n_seats: int) -> Optional[BaseOptimizer]:
640
+ """Turn the runner's `optimizer` argument into this seat's own optimizer."""
641
+ if spec is None:
642
+ return None
643
+ if isinstance(spec, dict):
644
+ return spec.get(agent_id)
645
+ if isinstance(spec, str):
646
+ if spec != "auto":
647
+ raise ValueError(f"optimizer must be 'auto', None, a callable, or a dict; got {spec!r}")
648
+ bounds = getattr(agent, "default_param_bounds", None)
649
+ if not bounds or not hasattr(agent, "get_hyperparams"):
650
+ return None
651
+ from tensor_optix.optimizers.spsa_optimizer import SPSAOptimizer
652
+ return SPSAOptimizer(
653
+ param_bounds=dict(bounds),
654
+ log_params=list(getattr(agent, "default_log_params", []) or []),
655
+ )
656
+ if isinstance(spec, BaseOptimizer):
657
+ if n_seats > 1:
658
+ raise ValueError(
659
+ "A single optimizer instance cannot be shared between seats (it "
660
+ "holds per-run state). Pass a callable(agent) -> BaseOptimizer or "
661
+ "a dict {agent_id: optimizer}."
662
+ )
663
+ return spec
664
+ if callable(spec):
665
+ return spec(agent)
666
+ raise ValueError(f"Unsupported optimizer argument: {spec!r}")
667
+
668
+
405
669
  def _safe_dirname(agent_id: Hashable) -> str:
406
670
  text = str(agent_id)
407
671
  return "".join(c if (c.isalnum() or c in "-_.") else "_" for c in text) or "seat"