Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitignore +126 -0
- .gitmodules +9 -0
- LICENSE +7 -0
- cleanrl/.github/FUNDING.yml +12 -0
- cleanrl/.github/issue_template.md +24 -0
- cleanrl/.github/pull_request_template.md +33 -0
- cleanrl/.github/workflows/pre-commit.yml +25 -0
- cleanrl/.github/workflows/tests.yaml +201 -0
- cleanrl/.github/workflows/utils_test.yaml +32 -0
- cleanrl/Dockerfile +21 -0
- cleanrl/benchmark/cleanrl_1gpu.slurm_template +21 -0
- cleanrl/benchmark/ddpg.sh +22 -0
- cleanrl/benchmark/ppo.sh +145 -0
- cleanrl/benchmark/sac.sh +10 -0
- cleanrl/cleanrl/ppo_atari_multigpu.py +403 -0
- cleanrl/cleanrl/ppo_blackjack.py +564 -0
- cleanrl/cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py +393 -0
- cleanrl/cleanrl/ppo_frozenlake.py +567 -0
- cleanrl/cleanrl/ppo_frozenlake_nochangeenv.py +494 -0
- cleanrl/cleanrl/ppo_pettingzoo_ma_atari.py +313 -0
- cleanrl/cleanrl/ppo_sudoku.py +538 -0
- cleanrl/cleanrl/ppo_trxl/enjoy.py +91 -0
- cleanrl/cleanrl/ppo_trxl/uv.lock +0 -0
- cleanrl/cleanrl/pqn_atari_envpool.py +291 -0
- cleanrl/cleanrl/qdagger_dqn_atari_jax_impalacnn.py +475 -0
- cleanrl/cleanrl/rainbow_atari.py +529 -0
- cleanrl/cleanrl/scout_dqn/noisy_dqn_2048_5000score.py +737 -0
- cleanrl/cleanrl/scout_ppo/ppo_frozenlake_nochangeenv.py +494 -0
- cleanrl/cleanrl/wandb/run-20251107_100619-gm3bobw8/logs/debug-internal.log +31 -0
- cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/code/cleanrl/ppo_bandit.py +335 -0
- cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/config.yaml +153 -0
- cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/wandb-metadata.json +94 -0
- cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/wandb-summary.json +1 -0
- cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/logs/debug.log +24 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/code/cleanrl/ppo_bandit.py +335 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/output.log +610 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/requirements.txt +305 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/wandb-metadata.json +94 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug-internal.log +225 -0
- cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug.log +24 -0
- cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/files/requirements.txt +305 -0
- cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/files/wandb-summary.json +1 -0
- cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug-internal.log +215 -0
- cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug.log +24 -0
- cleanrl/cleanrl/wandb/run-20251107_112647-9utis4xx/files/wandb-summary.json +1 -0
- cleanrl/cleanrl/wandb/run-20251107_112647-9utis4xx/logs/debug-internal.log +15 -0
- cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/files/output.log +113 -0
- cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/files/wandb-summary.json +1 -0
- cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug-internal.log +61 -0
- cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug.log +362 -0
.gitignore
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
**/*.pt
|
| 2 |
+
**/checkpoints
|
| 3 |
+
**/wget-log
|
| 4 |
+
**/_build/
|
| 5 |
+
**/*.ckpt
|
| 6 |
+
**/outputs
|
| 7 |
+
**/*.tar.gz
|
| 8 |
+
**/playground
|
| 9 |
+
**/wandb
|
| 10 |
+
/verl
|
| 11 |
+
/scripts
|
| 12 |
+
/saves
|
| 13 |
+
/runs
|
| 14 |
+
/results
|
| 15 |
+
/cleanrl
|
| 16 |
+
/train_*.sh
|
| 17 |
+
|
| 18 |
+
# Byte-compiled / optimized / DLL files
|
| 19 |
+
__pycache__/
|
| 20 |
+
*.py[cod]
|
| 21 |
+
*$py.class
|
| 22 |
+
dataset/*
|
| 23 |
+
tensorflow/my_graph/*
|
| 24 |
+
.idea/
|
| 25 |
+
# C extensions
|
| 26 |
+
*.so
|
| 27 |
+
data
|
| 28 |
+
results/
|
| 29 |
+
|
| 30 |
+
# Distribution / packaging
|
| 31 |
+
.Python
|
| 32 |
+
build/
|
| 33 |
+
develop-eggs/
|
| 34 |
+
dist/
|
| 35 |
+
downloads/
|
| 36 |
+
eggs/
|
| 37 |
+
.eggs/
|
| 38 |
+
lib/
|
| 39 |
+
lib64/
|
| 40 |
+
parts/
|
| 41 |
+
sdist/
|
| 42 |
+
var/
|
| 43 |
+
*.egg-info/
|
| 44 |
+
.installed.cfg
|
| 45 |
+
*.egg
|
| 46 |
+
|
| 47 |
+
# PyInstaller
|
| 48 |
+
# Usually these files are written by a python script from a template
|
| 49 |
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
| 50 |
+
*.manifest
|
| 51 |
+
*.spec
|
| 52 |
+
|
| 53 |
+
# Installer logs
|
| 54 |
+
pip-log.txt
|
| 55 |
+
pip-delete-this-directory.txt
|
| 56 |
+
|
| 57 |
+
# Unit test / coverage reports
|
| 58 |
+
htmlcov/
|
| 59 |
+
.tox/
|
| 60 |
+
.coverage
|
| 61 |
+
.coverage.*
|
| 62 |
+
.cache
|
| 63 |
+
nosetests.xml
|
| 64 |
+
coverage.xml
|
| 65 |
+
*,cover
|
| 66 |
+
.hypothesis/
|
| 67 |
+
|
| 68 |
+
# Translations
|
| 69 |
+
*.mo
|
| 70 |
+
*.pot
|
| 71 |
+
|
| 72 |
+
# Django stuff:
|
| 73 |
+
*.log
|
| 74 |
+
local_settings.py
|
| 75 |
+
|
| 76 |
+
image_outputs
|
| 77 |
+
|
| 78 |
+
checkpoints
|
| 79 |
+
|
| 80 |
+
# Flask stuff:
|
| 81 |
+
instance/
|
| 82 |
+
.webassets-cache
|
| 83 |
+
|
| 84 |
+
# Scrapy stuff:
|
| 85 |
+
.scrapy
|
| 86 |
+
|
| 87 |
+
# Sphinx documentation
|
| 88 |
+
docs/_build/
|
| 89 |
+
|
| 90 |
+
# PyBuilder
|
| 91 |
+
target/
|
| 92 |
+
|
| 93 |
+
# IPython Notebook
|
| 94 |
+
.ipynb_checkpoints
|
| 95 |
+
|
| 96 |
+
# pyenv
|
| 97 |
+
.python-version
|
| 98 |
+
|
| 99 |
+
# celery beat schedule file
|
| 100 |
+
celerybeat-schedule
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
# virtualenv
|
| 104 |
+
venv/
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
# Spyder project settings
|
| 108 |
+
.spyderproject
|
| 109 |
+
|
| 110 |
+
# Rope project settings
|
| 111 |
+
.ropeproject
|
| 112 |
+
|
| 113 |
+
# vscode
|
| 114 |
+
.vscode
|
| 115 |
+
|
| 116 |
+
# Mac
|
| 117 |
+
.DS_Store
|
| 118 |
+
|
| 119 |
+
# output logs
|
| 120 |
+
tests/e2e/toy_examples/deepspeed/synchronous/output.txt
|
| 121 |
+
|
| 122 |
+
# vim
|
| 123 |
+
*.swp
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
log/
|
.gitmodules
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[submodule "verl"]
|
| 2 |
+
path = verl
|
| 3 |
+
url = https://github.com/volcengine/verl.git
|
| 4 |
+
[submodule "external/webshop-minimal"]
|
| 5 |
+
path = external/webshop-minimal
|
| 6 |
+
url = https://github.com/ZihanWang314/webshop-minimal.git
|
| 7 |
+
[submodule "external/kimina-lean-server"]
|
| 8 |
+
path = external/kimina-lean-server
|
| 9 |
+
url = https://github.com/project-numina/kimina-lean-server.git
|
LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Copyright 2025 RAGEN Team
|
| 2 |
+
|
| 3 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
| 4 |
+
|
| 5 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
| 6 |
+
|
| 7 |
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
cleanrl/.github/FUNDING.yml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# These are supported funding model platforms
|
| 2 |
+
|
| 3 |
+
github: [vwxyzjn]# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
| 4 |
+
patreon: # Replace with a single Patreon username
|
| 5 |
+
open_collective: # Replace with a single Open Collective username
|
| 6 |
+
ko_fi: # Replace with a single Ko-fi username
|
| 7 |
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
| 8 |
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
| 9 |
+
liberapay: # Replace with a single Liberapay username
|
| 10 |
+
issuehunt: # Replace with a single IssueHunt username
|
| 11 |
+
otechie: # Replace with a single Otechie username
|
| 12 |
+
custom: ['https://www.buymeacoffee.com/dosssman']# Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
cleanrl/.github/issue_template.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Problem Description
|
| 2 |
+
<!--- Provide a general summary of the issue in the Title above -->
|
| 3 |
+
|
| 4 |
+
## Checklist
|
| 5 |
+
- [ ] I have installed dependencies via `uv pip install` (see [CleanRL's installation guideline](https://docs.cleanrl.dev/get-started/installation/).
|
| 6 |
+
- [ ] I have checked that there is no similar [issue](https://github.com/vwxyzjn/cleanrl/issues) in the repo.
|
| 7 |
+
- [ ] I have checked the [documentation site](https://docs.cleanrl.dev/) and found not relevant information in [GitHub issues](https://github.com/vwxyzjn/cleanrl/issues).
|
| 8 |
+
|
| 9 |
+
## Current Behavior
|
| 10 |
+
<!--- Tell us what happens instead of the expected behavior -->
|
| 11 |
+
|
| 12 |
+
## Expected Behavior
|
| 13 |
+
<!--- Tell us what should happen -->
|
| 14 |
+
|
| 15 |
+
## Possible Solution
|
| 16 |
+
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
| 17 |
+
|
| 18 |
+
## Steps to Reproduce
|
| 19 |
+
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
| 20 |
+
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
| 21 |
+
1.
|
| 22 |
+
2.
|
| 23 |
+
3.
|
| 24 |
+
4.
|
cleanrl/.github/pull_request_template.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
## Description
|
| 2 |
+
<!--- Provide a general summary of your changes in here-->
|
| 3 |
+
|
| 4 |
+
## Types of changes
|
| 5 |
+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
| 6 |
+
- [ ] Bug fix
|
| 7 |
+
- [ ] New feature
|
| 8 |
+
- [ ] New algorithm
|
| 9 |
+
- [ ] Documentation
|
| 10 |
+
|
| 11 |
+
## Checklist:
|
| 12 |
+
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
| 13 |
+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
| 14 |
+
- [ ] I've read the [CONTRIBUTION](https://docs.cleanrl.dev/contribution/) guide (**required**).
|
| 15 |
+
- [ ] I have ensured `pre-commit run --all-files` passes (**required**).
|
| 16 |
+
- [ ] I have updated the tests accordingly (if applicable).
|
| 17 |
+
- [ ] I have updated the documentation and previewed the changes via `mkdocs serve`.
|
| 18 |
+
- [ ] I have explained note-worthy implementation details.
|
| 19 |
+
- [ ] I have explained the logged metrics.
|
| 20 |
+
- [ ] I have added links to the original paper and related papers.
|
| 21 |
+
|
| 22 |
+
If you need to run benchmark experiments for a performance-impacting changes:
|
| 23 |
+
|
| 24 |
+
- [ ] I have contacted @vwxyzjn to obtain access to the [openrlbenchmark W&B team](https://wandb.ai/openrlbenchmark).
|
| 25 |
+
- [ ] I have used the [benchmark utility](/get-started/benchmark-utility/) to submit the tracked experiments to the [openrlbenchmark/cleanrl](https://wandb.ai/openrlbenchmark/cleanrl) W&B project, optionally with `--capture_video`.
|
| 26 |
+
- [ ] I have performed RLops with `python -m openrlbenchmark.rlops`.
|
| 27 |
+
- For new feature or bug fix:
|
| 28 |
+
- [ ] I have used the RLops utility to understand the performance impact of the changes and confirmed there is no regression.
|
| 29 |
+
- For new algorithm:
|
| 30 |
+
- [ ] I have created a table comparing my results against those from reputable sources (i.e., the original paper or other reference implementation).
|
| 31 |
+
- [ ] I have added the learning curves generated by the `python -m openrlbenchmark.rlops` utility to the documentation.
|
| 32 |
+
- [ ] I have added links to the tracked experiments in W&B, generated by `python -m openrlbenchmark.rlops ....your_args... --report`, to the documentation.
|
| 33 |
+
|
cleanrl/.github/workflows/pre-commit.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: pre-commit
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
pull_request:
|
| 5 |
+
paths-ignore:
|
| 6 |
+
- 'docs/blog/*' # dummy ignore
|
| 7 |
+
jobs:
|
| 8 |
+
build:
|
| 9 |
+
runs-on: ubuntu-latest
|
| 10 |
+
strategy:
|
| 11 |
+
matrix:
|
| 12 |
+
python-version: [3.9]
|
| 13 |
+
|
| 14 |
+
steps:
|
| 15 |
+
- uses: actions/checkout@v4
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
submodules: recursive
|
| 19 |
+
- name: Set up Python ${{ matrix.python-version }}
|
| 20 |
+
uses: actions/setup-python@v5
|
| 21 |
+
with:
|
| 22 |
+
python-version: ${{ matrix.python-version }}
|
| 23 |
+
- uses: pre-commit/action@v3.0.1
|
| 24 |
+
with:
|
| 25 |
+
extra_args: --hook-stage manual --all-files
|
cleanrl/.github/workflows/tests.yaml
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: tests
|
| 2 |
+
on:
|
| 3 |
+
pull_request:
|
| 4 |
+
paths-ignore:
|
| 5 |
+
- '**/README.md'
|
| 6 |
+
- 'docs/**/*'
|
| 7 |
+
- 'cloud/**/*'
|
| 8 |
+
jobs:
|
| 9 |
+
test-core-envs:
|
| 10 |
+
strategy:
|
| 11 |
+
fail-fast: false
|
| 12 |
+
matrix:
|
| 13 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 14 |
+
os: [ubuntu-22.04]
|
| 15 |
+
runs-on: ${{ matrix.os }}
|
| 16 |
+
steps:
|
| 17 |
+
- uses: actions/checkout@v4
|
| 18 |
+
- uses: actions/setup-python@v5
|
| 19 |
+
with:
|
| 20 |
+
python-version: ${{ matrix.python-version }}
|
| 21 |
+
- name: Install uv
|
| 22 |
+
uses: astral-sh/setup-uv@v5
|
| 23 |
+
- run: uv venv
|
| 24 |
+
|
| 25 |
+
# classic control tests
|
| 26 |
+
- name: Install core dependencies
|
| 27 |
+
run: uv pip install ".[pytest]"
|
| 28 |
+
- name: Run core tests
|
| 29 |
+
run: uv run pytest tests/test_classic_control.py
|
| 30 |
+
- name: Install jax
|
| 31 |
+
if: runner.os == 'Linux' || runner.os == 'macOS'
|
| 32 |
+
run: uv pip install ".[pytest, jax]"
|
| 33 |
+
- name: Run gymnasium tests
|
| 34 |
+
run: uv run pytest tests/test_classic_control_gymnasium.py
|
| 35 |
+
- name: Run core tests with jax
|
| 36 |
+
if: runner.os == 'Linux' || runner.os == 'macOS'
|
| 37 |
+
run: uv run pytest tests/test_classic_control_jax_gymnasium.py
|
| 38 |
+
- name: Run gae tests with jax
|
| 39 |
+
if: runner.os == 'Linux' || runner.os == 'macOS'
|
| 40 |
+
run: uv run pytest tests/test_jax_compute_gae.py
|
| 41 |
+
- name: Install tuner dependencies
|
| 42 |
+
run: uv pip install ".[pytest, optuna]"
|
| 43 |
+
- name: Run tuner tests
|
| 44 |
+
run: uv run pytest tests/test_tuner.py
|
| 45 |
+
|
| 46 |
+
test-atari-envs:
|
| 47 |
+
strategy:
|
| 48 |
+
fail-fast: false
|
| 49 |
+
matrix:
|
| 50 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 51 |
+
os: [ubuntu-22.04]
|
| 52 |
+
runs-on: ${{ matrix.os }}
|
| 53 |
+
steps:
|
| 54 |
+
- uses: actions/checkout@v4
|
| 55 |
+
- uses: actions/setup-python@v5
|
| 56 |
+
with:
|
| 57 |
+
python-version: ${{ matrix.python-version }}
|
| 58 |
+
- name: Install uv
|
| 59 |
+
uses: astral-sh/setup-uv@v5
|
| 60 |
+
- run: uv venv
|
| 61 |
+
|
| 62 |
+
# atari tests
|
| 63 |
+
- name: Install atari dependencies
|
| 64 |
+
run: uv pip install ".[pytest, atari]"
|
| 65 |
+
- name: Run atari tests
|
| 66 |
+
run: uv run pytest tests/test_atari.py
|
| 67 |
+
- name: Install jax
|
| 68 |
+
if: runner.os == 'Linux' || runner.os == 'macOS'
|
| 69 |
+
run: uv pip install ".[pytest, atari, jax]"
|
| 70 |
+
- name: Run gymnasium migration dependencies
|
| 71 |
+
run: uv run pip install "gymnasium[atari,accept-rom-license]==0.28.1" "ale-py==0.8.1"
|
| 72 |
+
- name: Run gymnasium tests
|
| 73 |
+
run: uv run pytest tests/test_atari_gymnasium.py
|
| 74 |
+
- name: Run gymnasium tests with jax
|
| 75 |
+
if: runner.os == 'Linux' || runner.os == 'macOS'
|
| 76 |
+
run: uv run pytest tests/test_atari_jax_gymnasium.py
|
| 77 |
+
|
| 78 |
+
test-procgen-envs:
|
| 79 |
+
strategy:
|
| 80 |
+
fail-fast: false
|
| 81 |
+
matrix:
|
| 82 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 83 |
+
os: [ubuntu-22.04]
|
| 84 |
+
runs-on: ${{ matrix.os }}
|
| 85 |
+
steps:
|
| 86 |
+
- uses: actions/checkout@v4
|
| 87 |
+
- uses: actions/setup-python@v5
|
| 88 |
+
with:
|
| 89 |
+
python-version: ${{ matrix.python-version }}
|
| 90 |
+
- name: Install uv
|
| 91 |
+
uses: astral-sh/setup-uv@v5
|
| 92 |
+
- run: uv venv
|
| 93 |
+
|
| 94 |
+
# procgen tests
|
| 95 |
+
- name: Install core dependencies
|
| 96 |
+
run: uv pip install ".[pytest, procgen]"
|
| 97 |
+
- name: Downgrade setuptools
|
| 98 |
+
run: uv run pip install setuptools==59.5.0
|
| 99 |
+
- name: Run procgen tests
|
| 100 |
+
run: uv run pytest tests/test_procgen.py
|
| 101 |
+
|
| 102 |
+
test-mujoco-envs:
|
| 103 |
+
strategy:
|
| 104 |
+
fail-fast: false
|
| 105 |
+
matrix:
|
| 106 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 107 |
+
os: [ubuntu-22.04]
|
| 108 |
+
runs-on: ${{ matrix.os }}
|
| 109 |
+
steps:
|
| 110 |
+
- uses: actions/checkout@v4
|
| 111 |
+
- uses: actions/setup-python@v5
|
| 112 |
+
with:
|
| 113 |
+
python-version: ${{ matrix.python-version }}
|
| 114 |
+
- name: Install uv
|
| 115 |
+
uses: astral-sh/setup-uv@v5
|
| 116 |
+
- run: uv venv
|
| 117 |
+
- name: Setup virtual display
|
| 118 |
+
run: |
|
| 119 |
+
sudo apt-get update
|
| 120 |
+
sudo apt-get install -y xvfb
|
| 121 |
+
export DISPLAY=:99
|
| 122 |
+
Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
|
| 123 |
+
|
| 124 |
+
# mujoco tests
|
| 125 |
+
- name: Install dependencies
|
| 126 |
+
run: uv pip install ".[pytest, mujoco, dm_control, jax]"
|
| 127 |
+
- name: install mujoco dependencies
|
| 128 |
+
run: |
|
| 129 |
+
sudo apt-get update && sudo apt-get -y install libgl1-mesa-glx libosmesa6 libglfw3
|
| 130 |
+
- name: Run mujoco tests
|
| 131 |
+
run: uv run pytest tests/test_mujoco.py
|
| 132 |
+
env:
|
| 133 |
+
DISPLAY: :99
|
| 134 |
+
|
| 135 |
+
test-envpool-envs:
|
| 136 |
+
strategy:
|
| 137 |
+
fail-fast: false
|
| 138 |
+
matrix:
|
| 139 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 140 |
+
os: [ubuntu-22.04]
|
| 141 |
+
runs-on: ${{ matrix.os }}
|
| 142 |
+
steps:
|
| 143 |
+
- uses: actions/checkout@v4
|
| 144 |
+
- uses: actions/setup-python@v5
|
| 145 |
+
with:
|
| 146 |
+
python-version: ${{ matrix.python-version }}
|
| 147 |
+
- name: Install uv
|
| 148 |
+
uses: astral-sh/setup-uv@v5
|
| 149 |
+
- run: uv venv
|
| 150 |
+
|
| 151 |
+
# envpool tests
|
| 152 |
+
- name: Install envpool dependencies
|
| 153 |
+
run: uv pip install ".[pytest, envpool, jax]"
|
| 154 |
+
- name: Run envpool tests
|
| 155 |
+
run: uv run pytest tests/test_envpool.py
|
| 156 |
+
|
| 157 |
+
test-atari-multigpu-envs:
|
| 158 |
+
strategy:
|
| 159 |
+
fail-fast: false
|
| 160 |
+
matrix:
|
| 161 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 162 |
+
os: [ubuntu-22.04]
|
| 163 |
+
runs-on: ${{ matrix.os }}
|
| 164 |
+
steps:
|
| 165 |
+
- uses: actions/checkout@v4
|
| 166 |
+
- uses: actions/setup-python@v5
|
| 167 |
+
with:
|
| 168 |
+
python-version: ${{ matrix.python-version }}
|
| 169 |
+
- name: Install uv
|
| 170 |
+
uses: astral-sh/setup-uv@v5
|
| 171 |
+
- run: uv venv
|
| 172 |
+
|
| 173 |
+
# atari multigpu tests
|
| 174 |
+
- name: Install atari dependencies
|
| 175 |
+
run: uv pip install ".[pytest, atari]"
|
| 176 |
+
- name: Run atari tests
|
| 177 |
+
run: uv run pytest tests/test_atari_multigpu.py
|
| 178 |
+
|
| 179 |
+
test-pettingzoo-envs:
|
| 180 |
+
strategy:
|
| 181 |
+
fail-fast: false
|
| 182 |
+
matrix:
|
| 183 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 184 |
+
os: [ubuntu-22.04]
|
| 185 |
+
runs-on: ${{ matrix.os }}
|
| 186 |
+
steps:
|
| 187 |
+
- uses: actions/checkout@v4
|
| 188 |
+
- uses: actions/setup-python@v5
|
| 189 |
+
with:
|
| 190 |
+
python-version: ${{ matrix.python-version }}
|
| 191 |
+
- name: Install uv
|
| 192 |
+
uses: astral-sh/setup-uv@v5
|
| 193 |
+
- run: uv venv
|
| 194 |
+
|
| 195 |
+
# pettingzoo tests
|
| 196 |
+
- name: Install pettingzoo dependencies
|
| 197 |
+
run: uv pip install ".[pytest, pettingzoo, atari]"
|
| 198 |
+
- name: Install ROMs
|
| 199 |
+
run: uv run AutoROM --accept-license
|
| 200 |
+
- name: Run pettingzoo tests
|
| 201 |
+
run: uv run pytest tests/test_pettingzoo_ma_atari.py
|
cleanrl/.github/workflows/utils_test.yaml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: utils_test
|
| 2 |
+
on:
|
| 3 |
+
pull_request:
|
| 4 |
+
paths-ignore:
|
| 5 |
+
- '**/README.md'
|
| 6 |
+
- 'docs/**/*'
|
| 7 |
+
- 'cloud/**/*'
|
| 8 |
+
jobs:
|
| 9 |
+
ci:
|
| 10 |
+
strategy:
|
| 11 |
+
fail-fast: false
|
| 12 |
+
matrix:
|
| 13 |
+
python-version: ["3.8", "3.9", "3.10"]
|
| 14 |
+
os: [ubuntu-22.04]
|
| 15 |
+
runs-on: ${{ matrix.os }}
|
| 16 |
+
steps:
|
| 17 |
+
- uses: actions/checkout@v4
|
| 18 |
+
- uses: actions/setup-python@v5
|
| 19 |
+
with:
|
| 20 |
+
python-version: ${{ matrix.python-version }}
|
| 21 |
+
- name: Install uv
|
| 22 |
+
uses: astral-sh/setup-uv@v5
|
| 23 |
+
- run: uv venv
|
| 24 |
+
|
| 25 |
+
- name: Install test dependencies
|
| 26 |
+
run: uv pip install ".[pytest]"
|
| 27 |
+
- name: Install cloud dependencies
|
| 28 |
+
run: uv pip install ".[pytest, cloud]"
|
| 29 |
+
- name: Downgrade setuptools
|
| 30 |
+
run: uv pip install setuptools==59.5.0
|
| 31 |
+
- name: Run utils tests
|
| 32 |
+
run: uv run pytest tests/test_utils.py
|
cleanrl/Dockerfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM nvidia/cuda:11.4.2-runtime-ubuntu20.04
|
| 2 |
+
|
| 3 |
+
# install ubuntu dependencies
|
| 4 |
+
ENV DEBIAN_FRONTEND=noninteractive
|
| 5 |
+
RUN apt-get update && \
|
| 6 |
+
apt-get -y install python3-pip xvfb ffmpeg git build-essential python-opengl
|
| 7 |
+
RUN ln -s /usr/bin/python3 /usr/bin/python
|
| 8 |
+
|
| 9 |
+
# install python dependencies
|
| 10 |
+
RUN mkdir cleanrl_utils && touch cleanrl_utils/__init__.py
|
| 11 |
+
RUN pip install uv --upgrade
|
| 12 |
+
COPY pyproject.toml pyproject.toml
|
| 13 |
+
COPY uv.lock uv.lock
|
| 14 |
+
RUN uv pip install .
|
| 15 |
+
|
| 16 |
+
COPY entrypoint.sh /usr/local/bin/
|
| 17 |
+
RUN chmod 777 /usr/local/bin/entrypoint.sh
|
| 18 |
+
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
| 19 |
+
|
| 20 |
+
# copy local files
|
| 21 |
+
COPY ./cleanrl /cleanrl
|
cleanrl/benchmark/cleanrl_1gpu.slurm_template
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
#SBATCH --job-name=low-priority
|
| 3 |
+
#SBATCH --partition=production-cluster
|
| 4 |
+
#SBATCH --gpus-per-task={{gpus_per_task}}
|
| 5 |
+
#SBATCH --cpus-per-gpu={{cpus_per_gpu}}
|
| 6 |
+
#SBATCH --ntasks={{ntasks}}
|
| 7 |
+
#SBATCH --output=slurm/logs/%x_%j.out
|
| 8 |
+
#SBATCH --array={{array}}
|
| 9 |
+
#SBATCH --mem-per-cpu=12G
|
| 10 |
+
#SBATCH --exclude=ip-26-0-146-[33,100,122-123,149,183,212,249],ip-26-0-147-[6,94,120,141],ip-26-0-152-[71,101,119,178,186,207,211],ip-26-0-153-[6,62,112,132,166,251],ip-26-0-154-[38,65],ip-26-0-155-[164,174,187,217],ip-26-0-156-[13,40],ip-26-0-157-27
|
| 11 |
+
##SBATCH --nodelist=ip-26-0-147-204
|
| 12 |
+
{{nodes}}
|
| 13 |
+
|
| 14 |
+
env_ids={{env_ids}}
|
| 15 |
+
seeds={{seeds}}
|
| 16 |
+
env_id=${env_ids[$SLURM_ARRAY_TASK_ID / {{len_seeds}}]}
|
| 17 |
+
seed=${seeds[$SLURM_ARRAY_TASK_ID % {{len_seeds}}]}
|
| 18 |
+
|
| 19 |
+
echo "Running task $SLURM_ARRAY_TASK_ID with env_id: $env_id and seed: $seed"
|
| 20 |
+
|
| 21 |
+
srun {{command}} --env-id $env_id --seed $seed #
|
cleanrl/benchmark/ddpg.sh
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uv pip install ".[mujoco]"
|
| 2 |
+
python -m cleanrl_utils.benchmark \
|
| 3 |
+
--env-ids HalfCheetah-v4 Walker2d-v4 Hopper-v4 InvertedPendulum-v4 Humanoid-v4 Pusher-v4 \
|
| 4 |
+
--command "uv run python cleanrl/ddpg_continuous_action.py --track" \
|
| 5 |
+
--num-seeds 3 \
|
| 6 |
+
--workers 18 \
|
| 7 |
+
--slurm-gpus-per-task 1 \
|
| 8 |
+
--slurm-ntasks 1 \
|
| 9 |
+
--slurm-total-cpus 10 \
|
| 10 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 11 |
+
|
| 12 |
+
uv pip install ".[mujoco, jax]"
|
| 13 |
+
uv pip install --upgrade "jax[cuda11_cudnn82]==0.4.8" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
|
| 14 |
+
uv run python -m cleanrl_utils.benchmark \
|
| 15 |
+
--env-ids HalfCheetah-v4 Walker2d-v4 Hopper-v4 InvertedPendulum-v4 Humanoid-v4 Pusher-v4 \
|
| 16 |
+
--command "uv run python cleanrl/ddpg_continuous_action_jax.py --track" \
|
| 17 |
+
--num-seeds 3 \
|
| 18 |
+
--workers 18 \
|
| 19 |
+
--slurm-gpus-per-task 1 \
|
| 20 |
+
--slurm-ntasks 1 \
|
| 21 |
+
--slurm-total-cpus 10 \
|
| 22 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
cleanrl/benchmark/ppo.sh
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# export WANDB_ENTITY=openrlbenchmark
|
| 2 |
+
|
| 3 |
+
uv pip install .
|
| 4 |
+
OMP_NUM_THREADS=1 xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 5 |
+
--env-ids CartPole-v1 Acrobot-v1 MountainCar-v0 \
|
| 6 |
+
--command "uv run python cleanrl/ppo.py --no_cuda --track --capture_video" \
|
| 7 |
+
--num-seeds 3 \
|
| 8 |
+
--workers 9 \
|
| 9 |
+
--slurm-gpus-per-task 1 \
|
| 10 |
+
--slurm-ntasks 1 \
|
| 11 |
+
--slurm-total-cpus 10 \
|
| 12 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 13 |
+
|
| 14 |
+
uv pip install ".[atari]"
|
| 15 |
+
OMP_NUM_THREADS=1 xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 16 |
+
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
|
| 17 |
+
--command "uv run python cleanrl/ppo_atari.py --track --capture_video" \
|
| 18 |
+
--num-seeds 3 \
|
| 19 |
+
--workers 9 \
|
| 20 |
+
--slurm-gpus-per-task 1 \
|
| 21 |
+
--slurm-ntasks 1 \
|
| 22 |
+
--slurm-total-cpus 10 \
|
| 23 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 24 |
+
|
| 25 |
+
uv pip install ".[mujoco]"
|
| 26 |
+
OMP_NUM_THREADS=1 xvfb-run -a python -m cleanrl_utils.benchmark \
|
| 27 |
+
--env-ids HalfCheetah-v4 Walker2d-v4 Hopper-v4 InvertedPendulum-v4 Humanoid-v4 Pusher-v4 \
|
| 28 |
+
--command "uv run python cleanrl/ppo_continuous_action.py --no_cuda --track --capture_video" \
|
| 29 |
+
--num-seeds 3 \
|
| 30 |
+
--workers 9 \
|
| 31 |
+
--slurm-gpus-per-task 1 \
|
| 32 |
+
--slurm-ntasks 1 \
|
| 33 |
+
--slurm-total-cpus 10 \
|
| 34 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 35 |
+
|
| 36 |
+
uv pip install ".[mujoco, dm_control]"
|
| 37 |
+
OMP_NUM_THREADS=1 xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 38 |
+
--env-ids dm_control/acrobot-swingup-v0 dm_control/acrobot-swingup_sparse-v0 dm_control/ball_in_cup-catch-v0 dm_control/cartpole-balance-v0 dm_control/cartpole-balance_sparse-v0 dm_control/cartpole-swingup-v0 dm_control/cartpole-swingup_sparse-v0 dm_control/cartpole-two_poles-v0 dm_control/cartpole-three_poles-v0 dm_control/cheetah-run-v0 dm_control/dog-stand-v0 dm_control/dog-walk-v0 dm_control/dog-trot-v0 dm_control/dog-run-v0 dm_control/dog-fetch-v0 dm_control/finger-spin-v0 dm_control/finger-turn_easy-v0 dm_control/finger-turn_hard-v0 dm_control/fish-upright-v0 dm_control/fish-swim-v0 dm_control/hopper-stand-v0 dm_control/hopper-hop-v0 dm_control/humanoid-stand-v0 dm_control/humanoid-walk-v0 dm_control/humanoid-run-v0 dm_control/humanoid-run_pure_state-v0 dm_control/humanoid_CMU-stand-v0 dm_control/humanoid_CMU-run-v0 dm_control/lqr-lqr_2_1-v0 dm_control/lqr-lqr_6_2-v0 dm_control/manipulator-bring_ball-v0 dm_control/manipulator-bring_peg-v0 dm_control/manipulator-insert_ball-v0 dm_control/manipulator-insert_peg-v0 dm_control/pendulum-swingup-v0 dm_control/point_mass-easy-v0 dm_control/point_mass-hard-v0 dm_control/quadruped-walk-v0 dm_control/quadruped-run-v0 dm_control/quadruped-escape-v0 dm_control/quadruped-fetch-v0 dm_control/reacher-easy-v0 dm_control/reacher-hard-v0 dm_control/stacker-stack_2-v0 dm_control/stacker-stack_4-v0 dm_control/swimmer-swimmer6-v0 dm_control/swimmer-swimmer15-v0 dm_control/walker-stand-v0 dm_control/walker-walk-v0 dm_control/walker-run-v0 \
|
| 39 |
+
--command "uv run python cleanrl/ppo_continuous_action.py --exp-name ppo_continuous_action_8M --total-timesteps 8000000 --no_cuda --track" \
|
| 40 |
+
--num-seeds 10 \
|
| 41 |
+
--workers 9 \
|
| 42 |
+
--slurm-gpus-per-task 1 \
|
| 43 |
+
--slurm-ntasks 1 \
|
| 44 |
+
--slurm-total-cpus 10 \
|
| 45 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 46 |
+
|
| 47 |
+
uv pip install ".[atari]"
|
| 48 |
+
OMP_NUM_THREADS=1 xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 49 |
+
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
|
| 50 |
+
--command "uv run python cleanrl/ppo_atari_lstm.py --track --capture_video" \
|
| 51 |
+
--num-seeds 3 \
|
| 52 |
+
--workers 9 \
|
| 53 |
+
--slurm-gpus-per-task 1 \
|
| 54 |
+
--slurm-ntasks 1 \
|
| 55 |
+
--slurm-total-cpus 10 \
|
| 56 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 57 |
+
|
| 58 |
+
uv pip install ".[envpool]"
|
| 59 |
+
uv run python -m cleanrl_utils.benchmark \
|
| 60 |
+
--env-ids Pong-v5 BeamRider-v5 Breakout-v5 \
|
| 61 |
+
--command "uv run python cleanrl/ppo_atari_envpool.py --track --capture_video" \
|
| 62 |
+
--num-seeds 3 \
|
| 63 |
+
--workers 9 \
|
| 64 |
+
--slurm-gpus-per-task 1 \
|
| 65 |
+
--slurm-ntasks 1 \
|
| 66 |
+
--slurm-total-cpus 10 \
|
| 67 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 68 |
+
|
| 69 |
+
uv pip install ".[envpool, jax]"
|
| 70 |
+
uv run python -m cleanrl_utils.benchmark \
|
| 71 |
+
--env-ids Alien-v5 Amidar-v5 Assault-v5 Asterix-v5 Asteroids-v5 Atlantis-v5 BankHeist-v5 BattleZone-v5 BeamRider-v5 Berzerk-v5 Bowling-v5 Boxing-v5 Breakout-v5 Centipede-v5 ChopperCommand-v5 CrazyClimber-v5 Defender-v5 DemonAttack-v5 DoubleDunk-v5 Enduro-v5 FishingDerby-v5 Freeway-v5 Frostbite-v5 Gopher-v5 Gravitar-v5 Hero-v5 IceHockey-v5 Jamesbond-v5 Kangaroo-v5 Krull-v5 KungFuMaster-v5 MontezumaRevenge-v5 MsPacman-v5 NameThisGame-v5 Phoenix-v5 Pitfall-v5 Pong-v5 PrivateEye-v5 Qbert-v5 Riverraid-v5 RoadRunner-v5 Robotank-v5 Seaquest-v5 Skiing-v5 Solaris-v5 SpaceInvaders-v5 StarGunner-v5 Surround-v5 Tennis-v5 TimePilot-v5 Tutankham-v5 UpNDown-v5 Venture-v5 VideoPinball-v5 WizardOfWor-v5 YarsRevenge-v5 Zaxxon-v5 \
|
| 72 |
+
--command "uv run python ppo_atari_envpool_xla_jax.py --track --wandb-project-name envpool-atari --wandb-entity openrlbenchmark" \
|
| 73 |
+
--num-seeds 3 \
|
| 74 |
+
--workers 9 \
|
| 75 |
+
--slurm-gpus-per-task 1 \
|
| 76 |
+
--slurm-ntasks 1 \
|
| 77 |
+
--slurm-total-cpus 10 \
|
| 78 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 79 |
+
|
| 80 |
+
uv pip install ".[envpool, jax]"
|
| 81 |
+
python -m cleanrl_utils.benchmark \
|
| 82 |
+
--env-ids Pong-v5 BeamRider-v5 Breakout-v5 \
|
| 83 |
+
--command "uv run python cleanrl/ppo_atari_envpool_xla_jax_scan.py --track --capture_video" \
|
| 84 |
+
--num-seeds 3 \
|
| 85 |
+
--workers 9 \
|
| 86 |
+
--slurm-gpus-per-task 1 \
|
| 87 |
+
--slurm-ntasks 1 \
|
| 88 |
+
--slurm-total-cpus 10 \
|
| 89 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 90 |
+
|
| 91 |
+
uv pip install ".[procgen]"
|
| 92 |
+
uv run python -m cleanrl_utils.benchmark \
|
| 93 |
+
--env-ids starpilot bossfight bigfish \
|
| 94 |
+
--command "uv run python cleanrl/ppo_procgen.py --track --capture_video" \
|
| 95 |
+
--num-seeds 3 \
|
| 96 |
+
--workers 9 \
|
| 97 |
+
--slurm-gpus-per-task 1 \
|
| 98 |
+
--slurm-ntasks 1 \
|
| 99 |
+
--slurm-total-cpus 10 \
|
| 100 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 101 |
+
|
| 102 |
+
uv pip install ".[atari]"
|
| 103 |
+
xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 104 |
+
--env-ids PongNoFrameskip-v4 BeamRiderNoFrameskip-v4 BreakoutNoFrameskip-v4 \
|
| 105 |
+
--command "uv run torchrun --standalone --nnodes=1 --nproc_per_node=2 cleanrl/ppo_atari_multigpu.py --local-num-envs 4 --track --capture_video" \
|
| 106 |
+
--num-seeds 3 \
|
| 107 |
+
--workers 9 \
|
| 108 |
+
--slurm-gpus-per-task 1 \
|
| 109 |
+
--slurm-ntasks 1 \
|
| 110 |
+
--slurm-total-cpus 10 \
|
| 111 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 112 |
+
|
| 113 |
+
uv pip install ".[pettingzoo, atari]"
|
| 114 |
+
uv run AutoROM --accept-license
|
| 115 |
+
xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 116 |
+
--env-ids pong_v3 surround_v2 tennis_v3 \
|
| 117 |
+
--command "uv run python cleanrl/ppo_pettingzoo_ma_atari.py --track --capture_video" \
|
| 118 |
+
--num-seeds 3 \
|
| 119 |
+
--workers 9 \
|
| 120 |
+
--slurm-gpus-per-task 1 \
|
| 121 |
+
--slurm-ntasks 1 \
|
| 122 |
+
--slurm-total-cpus 10 \
|
| 123 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 124 |
+
|
| 125 |
+
# IMPORTANT: see specific Isaac Gym installation at
|
| 126 |
+
# https://docs.cleanrl.dev/rl-algorithms/ppo/#usage_8
|
| 127 |
+
poetry install --with isaacgym
|
| 128 |
+
xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 129 |
+
--env-ids Cartpole Ant Humanoid BallBalance Anymal \
|
| 130 |
+
--command "uv run python cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py --track --capture_video" \
|
| 131 |
+
--num-seeds 3 \
|
| 132 |
+
--workers 9 \
|
| 133 |
+
--slurm-gpus-per-task 1 \
|
| 134 |
+
--slurm-ntasks 1 \
|
| 135 |
+
--slurm-total-cpus 10 \
|
| 136 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
| 137 |
+
xvfb-run -a uv run python -m cleanrl_utils.benchmark \
|
| 138 |
+
--env-ids AllegroHand ShadowHand \
|
| 139 |
+
--command "uv run python cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py --track --capture_video --num-envs 8192 --num-steps 8 --update-epochs 5 --num-minibatches 4 --reward-scaler 0.01 --total-timesteps 600000000 --record-video-step-frequency 3660" \
|
| 140 |
+
--num-seeds 3 \
|
| 141 |
+
--workers 9 \
|
| 142 |
+
--slurm-gpus-per-task 1 \
|
| 143 |
+
--slurm-ntasks 1 \
|
| 144 |
+
--slurm-total-cpus 10 \
|
| 145 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
cleanrl/benchmark/sac.sh
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
uv pip install ".[mujoco]"
|
| 2 |
+
uv run python -m cleanrl_utils.benchmark \
|
| 3 |
+
--env-ids HalfCheetah-v4 Walker2d-v4 Hopper-v4 InvertedPendulum-v4 Humanoid-v4 Pusher-v4 \
|
| 4 |
+
--command "uv run python cleanrl/sac_continuous_action.py --track" \
|
| 5 |
+
--num-seeds 3 \
|
| 6 |
+
--workers 18 \
|
| 7 |
+
--slurm-gpus-per-task 1 \
|
| 8 |
+
--slurm-ntasks 1 \
|
| 9 |
+
--slurm-total-cpus 10 \
|
| 10 |
+
--slurm-template-path benchmark/cleanrl_1gpu.slurm_template
|
cleanrl/cleanrl/ppo_atari_multigpu.py
ADDED
|
@@ -0,0 +1,403 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/ppo/#ppo_atari_multigpupy
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
import warnings
|
| 6 |
+
from dataclasses import dataclass, field
|
| 7 |
+
from typing import List, Literal
|
| 8 |
+
|
| 9 |
+
import gymnasium as gym
|
| 10 |
+
import numpy as np
|
| 11 |
+
import torch
|
| 12 |
+
import torch.distributed as dist
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
from rich.pretty import pprint
|
| 17 |
+
from torch.distributions.categorical import Categorical
|
| 18 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 19 |
+
|
| 20 |
+
from cleanrl_utils.atari_wrappers import ( # isort:skip
|
| 21 |
+
ClipRewardEnv,
|
| 22 |
+
EpisodicLifeEnv,
|
| 23 |
+
FireResetEnv,
|
| 24 |
+
MaxAndSkipEnv,
|
| 25 |
+
NoopResetEnv,
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@dataclass
|
| 30 |
+
class Args:
|
| 31 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 32 |
+
"""the name of this experiment"""
|
| 33 |
+
seed: int = 1
|
| 34 |
+
"""seed of the experiment"""
|
| 35 |
+
torch_deterministic: bool = True
|
| 36 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 37 |
+
cuda: bool = True
|
| 38 |
+
"""if toggled, cuda will be enabled by default"""
|
| 39 |
+
track: bool = False
|
| 40 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 41 |
+
wandb_project_name: str = "cleanRL"
|
| 42 |
+
"""the wandb's project name"""
|
| 43 |
+
wandb_entity: str = None
|
| 44 |
+
"""the entity (team) of wandb's project"""
|
| 45 |
+
capture_video: bool = False
|
| 46 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 47 |
+
|
| 48 |
+
# Algorithm specific arguments
|
| 49 |
+
env_id: str = "BreakoutNoFrameskip-v4"
|
| 50 |
+
"""the id of the environment"""
|
| 51 |
+
total_timesteps: int = 10000000
|
| 52 |
+
"""total timesteps of the experiments"""
|
| 53 |
+
learning_rate: float = 2.5e-4
|
| 54 |
+
"""the learning rate of the optimizer"""
|
| 55 |
+
local_num_envs: int = 8
|
| 56 |
+
"""the number of parallel game environments (in the local rank)"""
|
| 57 |
+
num_steps: int = 128
|
| 58 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 59 |
+
anneal_lr: bool = True
|
| 60 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 61 |
+
gamma: float = 0.99
|
| 62 |
+
"""the discount factor gamma"""
|
| 63 |
+
gae_lambda: float = 0.95
|
| 64 |
+
"""the lambda for the general advantage estimation"""
|
| 65 |
+
num_minibatches: int = 4
|
| 66 |
+
"""the number of mini-batches"""
|
| 67 |
+
update_epochs: int = 4
|
| 68 |
+
"""the K epochs to update the policy"""
|
| 69 |
+
norm_adv: bool = True
|
| 70 |
+
"""Toggles advantages normalization"""
|
| 71 |
+
clip_coef: float = 0.1
|
| 72 |
+
"""the surrogate clipping coefficient"""
|
| 73 |
+
clip_vloss: bool = True
|
| 74 |
+
"""Toggles whether or not to use a clipped loss for the value function, as per the paper."""
|
| 75 |
+
ent_coef: float = 0.01
|
| 76 |
+
"""coefficient of the entropy"""
|
| 77 |
+
vf_coef: float = 0.5
|
| 78 |
+
"""coefficient of the value function"""
|
| 79 |
+
max_grad_norm: float = 0.5
|
| 80 |
+
"""the maximum norm for the gradient clipping"""
|
| 81 |
+
target_kl: float = None
|
| 82 |
+
"""the target KL divergence threshold"""
|
| 83 |
+
device_ids: List[int] = field(default_factory=lambda: [])
|
| 84 |
+
"""the device ids that subprocess workers will use"""
|
| 85 |
+
backend: Literal["gloo", "nccl", "mpi"] = "gloo"
|
| 86 |
+
"""the backend for distributed training"""
|
| 87 |
+
|
| 88 |
+
# to be filled in runtime
|
| 89 |
+
local_batch_size: int = 0
|
| 90 |
+
"""the local batch size in the local rank (computed in runtime)"""
|
| 91 |
+
local_minibatch_size: int = 0
|
| 92 |
+
"""the local mini-batch size in the local rank (computed in runtime)"""
|
| 93 |
+
num_envs: int = 0
|
| 94 |
+
"""the number of parallel game environments (computed in runtime)"""
|
| 95 |
+
batch_size: int = 0
|
| 96 |
+
"""the batch size (computed in runtime)"""
|
| 97 |
+
minibatch_size: int = 0
|
| 98 |
+
"""the mini-batch size (computed in runtime)"""
|
| 99 |
+
num_iterations: int = 0
|
| 100 |
+
"""the number of iterations (computed in runtime)"""
|
| 101 |
+
world_size: int = 0
|
| 102 |
+
"""the number of processes (computed in runtime)"""
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def make_env(env_id, idx, capture_video, run_name):
|
| 106 |
+
def thunk():
|
| 107 |
+
if capture_video and idx == 0:
|
| 108 |
+
env = gym.make(env_id, render_mode="rgb_array")
|
| 109 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 110 |
+
else:
|
| 111 |
+
env = gym.make(env_id)
|
| 112 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 113 |
+
env = NoopResetEnv(env, noop_max=30)
|
| 114 |
+
env = MaxAndSkipEnv(env, skip=4)
|
| 115 |
+
env = EpisodicLifeEnv(env)
|
| 116 |
+
if "FIRE" in env.unwrapped.get_action_meanings():
|
| 117 |
+
env = FireResetEnv(env)
|
| 118 |
+
env = ClipRewardEnv(env)
|
| 119 |
+
env = gym.wrappers.ResizeObservation(env, (84, 84))
|
| 120 |
+
env = gym.wrappers.GrayScaleObservation(env)
|
| 121 |
+
env = gym.wrappers.FrameStack(env, 4)
|
| 122 |
+
return env
|
| 123 |
+
|
| 124 |
+
return thunk
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 128 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 129 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 130 |
+
return layer
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
class Agent(nn.Module):
|
| 134 |
+
def __init__(self, envs):
|
| 135 |
+
super().__init__()
|
| 136 |
+
self.network = nn.Sequential(
|
| 137 |
+
layer_init(nn.Conv2d(4, 32, 8, stride=4)),
|
| 138 |
+
nn.ReLU(),
|
| 139 |
+
layer_init(nn.Conv2d(32, 64, 4, stride=2)),
|
| 140 |
+
nn.ReLU(),
|
| 141 |
+
layer_init(nn.Conv2d(64, 64, 3, stride=1)),
|
| 142 |
+
nn.ReLU(),
|
| 143 |
+
nn.Flatten(),
|
| 144 |
+
layer_init(nn.Linear(64 * 7 * 7, 512)),
|
| 145 |
+
nn.ReLU(),
|
| 146 |
+
)
|
| 147 |
+
self.actor = layer_init(nn.Linear(512, envs.single_action_space.n), std=0.01)
|
| 148 |
+
self.critic = layer_init(nn.Linear(512, 1), std=1)
|
| 149 |
+
|
| 150 |
+
def get_value(self, x):
|
| 151 |
+
return self.critic(self.network(x / 255.0))
|
| 152 |
+
|
| 153 |
+
def get_action_and_value(self, x, action=None):
|
| 154 |
+
hidden = self.network(x / 255.0)
|
| 155 |
+
logits = self.actor(hidden)
|
| 156 |
+
probs = Categorical(logits=logits)
|
| 157 |
+
if action is None:
|
| 158 |
+
action = probs.sample()
|
| 159 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(hidden)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
if __name__ == "__main__":
|
| 163 |
+
# torchrun --standalone --nnodes=1 --nproc_per_node=2 ppo_atari_multigpu.py
|
| 164 |
+
# taken from https://pytorch.org/docs/stable/elastic/run.html
|
| 165 |
+
args = tyro.cli(Args)
|
| 166 |
+
local_rank = int(os.getenv("LOCAL_RANK", "0"))
|
| 167 |
+
args.world_size = int(os.getenv("WORLD_SIZE", "1"))
|
| 168 |
+
args.local_batch_size = int(args.local_num_envs * args.num_steps)
|
| 169 |
+
args.local_minibatch_size = int(args.local_batch_size // args.num_minibatches)
|
| 170 |
+
args.num_envs = args.local_num_envs * args.world_size
|
| 171 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 172 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 173 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 174 |
+
if args.world_size > 1:
|
| 175 |
+
dist.init_process_group(args.backend, rank=local_rank, world_size=args.world_size)
|
| 176 |
+
else:
|
| 177 |
+
warnings.warn(
|
| 178 |
+
"""
|
| 179 |
+
Not using distributed mode!
|
| 180 |
+
If you want to use distributed mode, please execute this script with 'torchrun'.
|
| 181 |
+
E.g., `torchrun --standalone --nnodes=1 --nproc_per_node=2 ppo_atari_multigpu.py`
|
| 182 |
+
"""
|
| 183 |
+
)
|
| 184 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 185 |
+
writer = None
|
| 186 |
+
if local_rank == 0:
|
| 187 |
+
if args.track:
|
| 188 |
+
import wandb
|
| 189 |
+
|
| 190 |
+
wandb.init(
|
| 191 |
+
project=args.wandb_project_name,
|
| 192 |
+
entity=args.wandb_entity,
|
| 193 |
+
sync_tensorboard=True,
|
| 194 |
+
config=vars(args),
|
| 195 |
+
name=run_name,
|
| 196 |
+
monitor_gym=True,
|
| 197 |
+
save_code=True,
|
| 198 |
+
)
|
| 199 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 200 |
+
writer.add_text(
|
| 201 |
+
"hyperparameters",
|
| 202 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 203 |
+
)
|
| 204 |
+
pprint(args)
|
| 205 |
+
|
| 206 |
+
# TRY NOT TO MODIFY: seeding
|
| 207 |
+
# CRUCIAL: note that we needed to pass a different seed for each data parallelism worker
|
| 208 |
+
args.seed += local_rank
|
| 209 |
+
random.seed(args.seed)
|
| 210 |
+
np.random.seed(args.seed)
|
| 211 |
+
torch.manual_seed(args.seed - local_rank)
|
| 212 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 213 |
+
|
| 214 |
+
if len(args.device_ids) > 0:
|
| 215 |
+
assert len(args.device_ids) == args.world_size, "you must specify the same number of device ids as `--nproc_per_node`"
|
| 216 |
+
device = torch.device(f"cuda:{args.device_ids[local_rank]}" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 217 |
+
else:
|
| 218 |
+
device_count = torch.cuda.device_count()
|
| 219 |
+
if device_count < args.world_size:
|
| 220 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 221 |
+
else:
|
| 222 |
+
device = torch.device(f"cuda:{local_rank}" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 223 |
+
|
| 224 |
+
# env setup
|
| 225 |
+
envs = gym.vector.SyncVectorEnv(
|
| 226 |
+
[make_env(args.env_id, i, args.capture_video, run_name) for i in range(args.local_num_envs)],
|
| 227 |
+
)
|
| 228 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 229 |
+
|
| 230 |
+
agent = Agent(envs).to(device)
|
| 231 |
+
torch.manual_seed(args.seed)
|
| 232 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 233 |
+
|
| 234 |
+
# ALGO Logic: Storage setup
|
| 235 |
+
obs = torch.zeros((args.num_steps, args.local_num_envs) + envs.single_observation_space.shape).to(device)
|
| 236 |
+
actions = torch.zeros((args.num_steps, args.local_num_envs) + envs.single_action_space.shape).to(device)
|
| 237 |
+
logprobs = torch.zeros((args.num_steps, args.local_num_envs)).to(device)
|
| 238 |
+
rewards = torch.zeros((args.num_steps, args.local_num_envs)).to(device)
|
| 239 |
+
dones = torch.zeros((args.num_steps, args.local_num_envs)).to(device)
|
| 240 |
+
values = torch.zeros((args.num_steps, args.local_num_envs)).to(device)
|
| 241 |
+
|
| 242 |
+
# TRY NOT TO MODIFY: start the game
|
| 243 |
+
global_step = 0
|
| 244 |
+
start_time = time.time()
|
| 245 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 246 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 247 |
+
next_done = torch.zeros(args.local_num_envs).to(device)
|
| 248 |
+
|
| 249 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 250 |
+
# Annealing the rate if instructed to do so.
|
| 251 |
+
if args.anneal_lr:
|
| 252 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 253 |
+
lrnow = frac * args.learning_rate
|
| 254 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 255 |
+
|
| 256 |
+
for step in range(0, args.num_steps):
|
| 257 |
+
global_step += args.num_envs
|
| 258 |
+
obs[step] = next_obs
|
| 259 |
+
dones[step] = next_done
|
| 260 |
+
|
| 261 |
+
# ALGO LOGIC: action logic
|
| 262 |
+
with torch.no_grad():
|
| 263 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 264 |
+
values[step] = value.flatten()
|
| 265 |
+
actions[step] = action
|
| 266 |
+
logprobs[step] = logprob
|
| 267 |
+
|
| 268 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 269 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 270 |
+
next_done = np.logical_or(terminations, truncations)
|
| 271 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 272 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 273 |
+
|
| 274 |
+
if not writer:
|
| 275 |
+
continue
|
| 276 |
+
|
| 277 |
+
if "final_info" in infos:
|
| 278 |
+
for info in infos["final_info"]:
|
| 279 |
+
if info and "episode" in info:
|
| 280 |
+
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
|
| 281 |
+
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
|
| 282 |
+
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
|
| 283 |
+
|
| 284 |
+
print(
|
| 285 |
+
f"local_rank: {local_rank}, action.sum(): {action.sum()}, iteration: {iteration}, agent.actor.weight.sum(): {agent.actor.weight.sum()}"
|
| 286 |
+
)
|
| 287 |
+
# bootstrap value if not done
|
| 288 |
+
with torch.no_grad():
|
| 289 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 290 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 291 |
+
lastgaelam = 0
|
| 292 |
+
for t in reversed(range(args.num_steps)):
|
| 293 |
+
if t == args.num_steps - 1:
|
| 294 |
+
nextnonterminal = 1.0 - next_done
|
| 295 |
+
nextvalues = next_value
|
| 296 |
+
else:
|
| 297 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 298 |
+
nextvalues = values[t + 1]
|
| 299 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 300 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 301 |
+
returns = advantages + values
|
| 302 |
+
|
| 303 |
+
# flatten the batch
|
| 304 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 305 |
+
b_logprobs = logprobs.reshape(-1)
|
| 306 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 307 |
+
b_advantages = advantages.reshape(-1)
|
| 308 |
+
b_returns = returns.reshape(-1)
|
| 309 |
+
b_values = values.reshape(-1)
|
| 310 |
+
|
| 311 |
+
# Optimizing the policy and value network
|
| 312 |
+
b_inds = np.arange(args.local_batch_size)
|
| 313 |
+
clipfracs = []
|
| 314 |
+
for epoch in range(args.update_epochs):
|
| 315 |
+
np.random.shuffle(b_inds)
|
| 316 |
+
for start in range(0, args.local_batch_size, args.local_minibatch_size):
|
| 317 |
+
end = start + args.local_minibatch_size
|
| 318 |
+
mb_inds = b_inds[start:end]
|
| 319 |
+
|
| 320 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 321 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 322 |
+
ratio = logratio.exp()
|
| 323 |
+
|
| 324 |
+
with torch.no_grad():
|
| 325 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 326 |
+
old_approx_kl = (-logratio).mean()
|
| 327 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 328 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 329 |
+
|
| 330 |
+
mb_advantages = b_advantages[mb_inds]
|
| 331 |
+
if args.norm_adv:
|
| 332 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 333 |
+
|
| 334 |
+
# Policy loss
|
| 335 |
+
pg_loss1 = -mb_advantages * ratio
|
| 336 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 337 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 338 |
+
|
| 339 |
+
# Value loss
|
| 340 |
+
newvalue = newvalue.view(-1)
|
| 341 |
+
if args.clip_vloss:
|
| 342 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 343 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 344 |
+
newvalue - b_values[mb_inds],
|
| 345 |
+
-args.clip_coef,
|
| 346 |
+
args.clip_coef,
|
| 347 |
+
)
|
| 348 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 349 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 350 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 351 |
+
else:
|
| 352 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 353 |
+
|
| 354 |
+
entropy_loss = entropy.mean()
|
| 355 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 356 |
+
|
| 357 |
+
optimizer.zero_grad()
|
| 358 |
+
loss.backward()
|
| 359 |
+
|
| 360 |
+
if args.world_size > 1:
|
| 361 |
+
# batch allreduce ops: see https://github.com/entity-neural-network/incubator/pull/220
|
| 362 |
+
all_grads_list = []
|
| 363 |
+
for param in agent.parameters():
|
| 364 |
+
if param.grad is not None:
|
| 365 |
+
all_grads_list.append(param.grad.view(-1))
|
| 366 |
+
all_grads = torch.cat(all_grads_list)
|
| 367 |
+
dist.all_reduce(all_grads, op=dist.ReduceOp.SUM)
|
| 368 |
+
offset = 0
|
| 369 |
+
for param in agent.parameters():
|
| 370 |
+
if param.grad is not None:
|
| 371 |
+
param.grad.data.copy_(
|
| 372 |
+
all_grads[offset : offset + param.numel()].view_as(param.grad.data) / args.world_size
|
| 373 |
+
)
|
| 374 |
+
offset += param.numel()
|
| 375 |
+
|
| 376 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 377 |
+
optimizer.step()
|
| 378 |
+
|
| 379 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 380 |
+
break
|
| 381 |
+
|
| 382 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 383 |
+
var_y = np.var(y_true)
|
| 384 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 385 |
+
|
| 386 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 387 |
+
if local_rank == 0:
|
| 388 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 389 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 390 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 391 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 392 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 393 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 394 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 395 |
+
writer.add_scalar("losses/explained_variance", explained_var, global_step)
|
| 396 |
+
print("SPS:", int(global_step / (time.time() - start_time)))
|
| 397 |
+
writer.add_scalar("charts/SPS", int(global_step / (time.time() - start_time)), global_step)
|
| 398 |
+
|
| 399 |
+
envs.close()
|
| 400 |
+
if local_rank == 0:
|
| 401 |
+
writer.close()
|
| 402 |
+
if args.track:
|
| 403 |
+
wandb.finish()
|
cleanrl/cleanrl/ppo_blackjack.py
ADDED
|
@@ -0,0 +1,564 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO with small MLP for RAGEN Blackjack using the improved Wrapper logic
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
import re
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
from typing import Dict, Any, Tuple, List
|
| 9 |
+
import json
|
| 10 |
+
import sys
|
| 11 |
+
from collections import deque
|
| 12 |
+
|
| 13 |
+
import gymnasium as gym
|
| 14 |
+
import numpy as np
|
| 15 |
+
import torch
|
| 16 |
+
import torch.nn as nn
|
| 17 |
+
import torch.optim as optim
|
| 18 |
+
import tyro
|
| 19 |
+
from torch.distributions.categorical import Categorical
|
| 20 |
+
|
| 21 |
+
# 假设你的目录结构是 ragen/env/blackjack/
|
| 22 |
+
# 如果报错找不到 ragen,请调整这里的路径或者在项目根目录运行
|
| 23 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 24 |
+
|
| 25 |
+
from ragen.env.blackjack.env import BlackjackEnv
|
| 26 |
+
from ragen.env.blackjack.config import BlackjackEnvConfig
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
class BlackjackWrapper(gym.Env):
|
| 30 |
+
"""
|
| 31 |
+
改进后的适配器,用于处理新的 text observation 格式。
|
| 32 |
+
- 增加了 _last_dealer_show 记忆,防止游戏结算画面丢失 Dealer 明牌信息。
|
| 33 |
+
- 使用正则解析,更稳健。
|
| 34 |
+
"""
|
| 35 |
+
metadata = {"render_modes": ["ansi", "human", "text"]}
|
| 36 |
+
|
| 37 |
+
def __init__(self):
|
| 38 |
+
super().__init__()
|
| 39 |
+
# 强制使用 text 模式以便解析
|
| 40 |
+
cfg = BlackjackEnvConfig(render_mode='text')
|
| 41 |
+
self._env = BlackjackEnv(cfg)
|
| 42 |
+
|
| 43 |
+
# 8维特征向量:
|
| 44 |
+
# [player_sum/31, dealer_show/11, usable_ace, done_flag,
|
| 45 |
+
# is_20_21, player_sum_sq, dealer_ge_7, bias]
|
| 46 |
+
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(8,), dtype=np.float32)
|
| 47 |
+
self.action_space = gym.spaces.Discrete(2)
|
| 48 |
+
|
| 49 |
+
# 记忆变量
|
| 50 |
+
self._last_dealer_show = 0
|
| 51 |
+
|
| 52 |
+
@staticmethod
|
| 53 |
+
def _safe_extract_ints(line: str) -> List[int]:
|
| 54 |
+
"""使用正则提取行内所有整数"""
|
| 55 |
+
return [int(x) for x in re.findall(r'-?\d+', line)]
|
| 56 |
+
|
| 57 |
+
def _encode_obs(self, text_obs: str, done_flag: bool) -> np.ndarray:
|
| 58 |
+
# 默认值
|
| 59 |
+
p_sum = 0
|
| 60 |
+
usable = 0
|
| 61 |
+
# 如果是 Done 状态,Environment 可能不显示 Visible Card,使用记忆值
|
| 62 |
+
dealer_show = self._last_dealer_show
|
| 63 |
+
|
| 64 |
+
lines = text_obs.split('\n')
|
| 65 |
+
for ln in lines:
|
| 66 |
+
# 1. 解析玩家点数
|
| 67 |
+
# 格式示例: "Your Hand: [10, 8] (Total: 18)."
|
| 68 |
+
if "Your Hand" in ln:
|
| 69 |
+
if "Total:" in ln:
|
| 70 |
+
try:
|
| 71 |
+
# 截取 Total: 之后的部分进行数字提取
|
| 72 |
+
part = ln.split("Total:")[1]
|
| 73 |
+
ints = self._safe_extract_ints(part)
|
| 74 |
+
if ints: p_sum = ints[0]
|
| 75 |
+
except:
|
| 76 |
+
pass
|
| 77 |
+
else:
|
| 78 |
+
# 兼容旧格式或兜底:取该行最后一个数字
|
| 79 |
+
ints = self._safe_extract_ints(ln)
|
| 80 |
+
if ints: p_sum = ints[-1]
|
| 81 |
+
|
| 82 |
+
# 2. 解析 Usable Ace
|
| 83 |
+
elif "usable Ace" in ln:
|
| 84 |
+
if "do NOT" not in ln and "possess" in ln:
|
| 85 |
+
usable = 1
|
| 86 |
+
|
| 87 |
+
# 3. 解析庄家明牌
|
| 88 |
+
# 只有在非 Done 状态下,才有这一行
|
| 89 |
+
elif "Dealer's Visible Card:" in ln:
|
| 90 |
+
ints = self._safe_extract_ints(ln)
|
| 91 |
+
if len(ints) >= 1:
|
| 92 |
+
dealer_show = ints[0]
|
| 93 |
+
self._last_dealer_show = dealer_show # 更新记忆
|
| 94 |
+
|
| 95 |
+
# 特征归一化与构建
|
| 96 |
+
ps = float(p_sum) / 31.0
|
| 97 |
+
ds = float(dealer_show) / 11.0
|
| 98 |
+
ua = float(usable)
|
| 99 |
+
df = 1.0 if done_flag else 0.0
|
| 100 |
+
|
| 101 |
+
# 辅助特征 (Heuristic features)
|
| 102 |
+
is_20_21 = 1.0 if (p_sum >= 20) else 0.0
|
| 103 |
+
ps_sq = (float(p_sum) ** 2) / (31.0 ** 2)
|
| 104 |
+
dealer_ge_7 = 1.0 if dealer_show >= 7 else 0.0
|
| 105 |
+
bias = 1.0
|
| 106 |
+
|
| 107 |
+
feat = np.array([ps, ds, ua, df, is_20_21, ps_sq, dealer_ge_7, bias], dtype=np.float32)
|
| 108 |
+
return feat
|
| 109 |
+
|
| 110 |
+
def reset(self, *, seed: int | None = None, options: Dict[str, Any] | None = None):
|
| 111 |
+
text_obs = self._env.reset(seed=seed)
|
| 112 |
+
self._last_dealer_show = 0 # 重置
|
| 113 |
+
# 第一次 encode 会自动更新 _last_dealer_show
|
| 114 |
+
obs = self._encode_obs(text_obs, done_flag=False)
|
| 115 |
+
return obs, {}
|
| 116 |
+
|
| 117 |
+
def step(self, action: int):
|
| 118 |
+
# 映射: Agent 0/1 -> Env 1(Stick)/2(Hit)
|
| 119 |
+
mapped = int(action) + 1
|
| 120 |
+
text_obs, reward, done, info = self._env.step(mapped)
|
| 121 |
+
|
| 122 |
+
# 即使 done=True,也会根据 _last_dealer_show 生成稳定的 observation
|
| 123 |
+
obs = self._encode_obs(text_obs, done_flag=bool(done))
|
| 124 |
+
|
| 125 |
+
terminated = bool(done)
|
| 126 |
+
truncated = False
|
| 127 |
+
info = info or {}
|
| 128 |
+
return obs, float(reward), terminated, truncated, info
|
| 129 |
+
|
| 130 |
+
def render(self):
|
| 131 |
+
return self._env.render()
|
| 132 |
+
|
| 133 |
+
def close(self):
|
| 134 |
+
self._env.close()
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
@dataclass
|
| 138 |
+
class Args:
|
| 139 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 140 |
+
seed: int = 1
|
| 141 |
+
torch_deterministic: bool = True
|
| 142 |
+
cuda: bool = True
|
| 143 |
+
track: bool = False # 如果要用 WandB,设为 True
|
| 144 |
+
wandb_project_name: str = "ragen_blackjack"
|
| 145 |
+
wandb_entity: str | None = None
|
| 146 |
+
capture_video: bool = False
|
| 147 |
+
|
| 148 |
+
# Algorithm
|
| 149 |
+
env_id: str = "Blackjack"
|
| 150 |
+
total_timesteps: int = 2000_000
|
| 151 |
+
learning_rate: float = 2.5e-4
|
| 152 |
+
num_envs: int = 8
|
| 153 |
+
num_steps: int = 128
|
| 154 |
+
anneal_lr: bool = True
|
| 155 |
+
gamma: float = 0.99
|
| 156 |
+
gae_lambda: float = 0.95
|
| 157 |
+
num_minibatches: int = 4
|
| 158 |
+
update_epochs: int = 4
|
| 159 |
+
norm_adv: bool = True
|
| 160 |
+
clip_coef: float = 0.2
|
| 161 |
+
clip_vloss: bool = True
|
| 162 |
+
|
| 163 |
+
# 修改:增加熵系数,鼓励探索
|
| 164 |
+
ent_coef: float = 0.05
|
| 165 |
+
vf_coef: float = 0.5
|
| 166 |
+
max_grad_norm: float = 0.5
|
| 167 |
+
target_kl: float | None = None
|
| 168 |
+
|
| 169 |
+
# runtime filled
|
| 170 |
+
batch_size: int = 0
|
| 171 |
+
minibatch_size: int = 0
|
| 172 |
+
num_iterations: int = 0
|
| 173 |
+
|
| 174 |
+
# eval config
|
| 175 |
+
eval_splits: int = 10
|
| 176 |
+
eval_episodes: int = 1000
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def make_env(idx, run_name, seed, capture_video=False):
|
| 180 |
+
def thunk():
|
| 181 |
+
env = BlackjackWrapper()
|
| 182 |
+
# Blackjack 每一局很短,设置一个安全上限即可
|
| 183 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=64)
|
| 184 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 185 |
+
if capture_video and idx == 0:
|
| 186 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 187 |
+
return env
|
| 188 |
+
return thunk
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 192 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 193 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 194 |
+
return layer
|
| 195 |
+
|
| 196 |
+
|
| 197 |
+
class Agent(nn.Module):
|
| 198 |
+
def __init__(self, envs):
|
| 199 |
+
super().__init__()
|
| 200 |
+
obs_shape = int(np.array(envs.single_observation_space.shape).prod())
|
| 201 |
+
hidden = 64
|
| 202 |
+
# Critic: 评估当前状态好坏
|
| 203 |
+
self.critic = nn.Sequential(
|
| 204 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 205 |
+
nn.Tanh(),
|
| 206 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 207 |
+
nn.Tanh(),
|
| 208 |
+
layer_init(nn.Linear(hidden, 1), std=1.0),
|
| 209 |
+
)
|
| 210 |
+
# Actor: 输出动作概率
|
| 211 |
+
self.actor = nn.Sequential(
|
| 212 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 213 |
+
nn.Tanh(),
|
| 214 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 215 |
+
nn.Tanh(),
|
| 216 |
+
layer_init(nn.Linear(hidden, envs.single_action_space.n), std=0.01),
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
def get_value(self, x):
|
| 220 |
+
return self.critic(x)
|
| 221 |
+
|
| 222 |
+
def get_action_and_value(self, x, action=None):
|
| 223 |
+
logits = self.actor(x)
|
| 224 |
+
probs = Categorical(logits=logits)
|
| 225 |
+
if action is None:
|
| 226 |
+
action = probs.sample()
|
| 227 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 228 |
+
|
| 229 |
+
|
| 230 |
+
if __name__ == "__main__":
|
| 231 |
+
args = tyro.cli(Args)
|
| 232 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 233 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 234 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 235 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 236 |
+
|
| 237 |
+
if args.track:
|
| 238 |
+
import wandb
|
| 239 |
+
wandb.init(
|
| 240 |
+
project=args.wandb_project_name,
|
| 241 |
+
entity=args.wandb_entity,
|
| 242 |
+
config=vars(args),
|
| 243 |
+
name=run_name,
|
| 244 |
+
monitor_gym=True,
|
| 245 |
+
save_code=True,
|
| 246 |
+
)
|
| 247 |
+
|
| 248 |
+
# Seeding
|
| 249 |
+
random.seed(args.seed)
|
| 250 |
+
np.random.seed(args.seed)
|
| 251 |
+
torch.manual_seed(args.seed)
|
| 252 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 253 |
+
|
| 254 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 255 |
+
print(f"Using device: {device}")
|
| 256 |
+
|
| 257 |
+
# Envs
|
| 258 |
+
envs = gym.vector.SyncVectorEnv([
|
| 259 |
+
make_env(i, run_name, args.seed, args.capture_video)
|
| 260 |
+
for i in range(args.num_envs)
|
| 261 |
+
])
|
| 262 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete)
|
| 263 |
+
|
| 264 |
+
agent = Agent(envs).to(device)
|
| 265 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 266 |
+
|
| 267 |
+
# Storage setup
|
| 268 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 269 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 270 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 271 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 272 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 273 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 274 |
+
|
| 275 |
+
# Start loop
|
| 276 |
+
global_step = 0
|
| 277 |
+
start_time = time.time()
|
| 278 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 279 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 280 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 281 |
+
|
| 282 |
+
# Evaluation helper function
|
| 283 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes, step_tag):
|
| 284 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 285 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 286 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 287 |
+
|
| 288 |
+
# 独立的 Eval 环境
|
| 289 |
+
env = make_env_fn()
|
| 290 |
+
collected = 0
|
| 291 |
+
summary_returns = []
|
| 292 |
+
summary_success = []
|
| 293 |
+
|
| 294 |
+
with out_path.open("w") as f:
|
| 295 |
+
while collected < n_episodes:
|
| 296 |
+
state, _ = env.reset(seed=args.seed + 100000 + collected)
|
| 297 |
+
traj_states = [state.tolist()]
|
| 298 |
+
traj_actions = []
|
| 299 |
+
traj_rewards = []
|
| 300 |
+
traj_dones = []
|
| 301 |
+
traj_success = []
|
| 302 |
+
done = False
|
| 303 |
+
|
| 304 |
+
while not done:
|
| 305 |
+
with torch.no_grad():
|
| 306 |
+
logits = agent_model.actor(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 307 |
+
action = int(torch.argmax(logits, dim=1).item())
|
| 308 |
+
|
| 309 |
+
next_state, reward, terminated, truncated, info = env.step(action)
|
| 310 |
+
|
| 311 |
+
traj_actions.append(int(action))
|
| 312 |
+
traj_rewards.append(float(reward))
|
| 313 |
+
|
| 314 |
+
d = bool(terminated) or bool(truncated)
|
| 315 |
+
traj_dones.append(d)
|
| 316 |
+
traj_success.append(bool((info or {}).get('success', False)))
|
| 317 |
+
|
| 318 |
+
state = next_state
|
| 319 |
+
traj_states.append(state.tolist())
|
| 320 |
+
done = d
|
| 321 |
+
|
| 322 |
+
ep_ret = float(sum(traj_rewards))
|
| 323 |
+
ep_succ = bool(any(traj_success))
|
| 324 |
+
|
| 325 |
+
record = {
|
| 326 |
+
"states": traj_states,
|
| 327 |
+
"actions": traj_actions,
|
| 328 |
+
"rewards": traj_rewards,
|
| 329 |
+
"dones": traj_dones,
|
| 330 |
+
"success": traj_success,
|
| 331 |
+
"episode_return": ep_ret,
|
| 332 |
+
"episode_success": ep_succ,
|
| 333 |
+
}
|
| 334 |
+
f.write(json.dumps(record) + "\n")
|
| 335 |
+
collected += 1
|
| 336 |
+
summary_returns.append(ep_ret)
|
| 337 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 338 |
+
|
| 339 |
+
env.close()
|
| 340 |
+
try:
|
| 341 |
+
metrics = {
|
| 342 |
+
"global_step": int(step_tag),
|
| 343 |
+
"episodes": int(n_episodes),
|
| 344 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 345 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 346 |
+
}
|
| 347 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 348 |
+
json.dump(metrics, mf)
|
| 349 |
+
return metrics
|
| 350 |
+
except Exception as e:
|
| 351 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 352 |
+
return {
|
| 353 |
+
"global_step": int(step_tag),
|
| 354 |
+
"episodes": int(n_episodes),
|
| 355 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 356 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
# Training Loop
|
| 360 |
+
eval_every_iters = max(1, args.num_iterations // args.eval_splits)
|
| 361 |
+
# Convergence trackers
|
| 362 |
+
recent_winrates = deque(maxlen=50)
|
| 363 |
+
winrate_ema = None
|
| 364 |
+
|
| 365 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 366 |
+
# Anneal LR
|
| 367 |
+
if args.anneal_lr:
|
| 368 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 369 |
+
lrnow = frac * args.learning_rate
|
| 370 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 371 |
+
|
| 372 |
+
# Per-iteration episode outcome accumulators
|
| 373 |
+
iter_outcomes: List[int] = [] # +1 win, 0 draw, -1 loss
|
| 374 |
+
iter_ep_returns: List[float] = []
|
| 375 |
+
|
| 376 |
+
for step in range(0, args.num_steps):
|
| 377 |
+
global_step += args.num_envs
|
| 378 |
+
obs[step] = next_obs
|
| 379 |
+
dones[step] = next_done
|
| 380 |
+
|
| 381 |
+
with torch.no_grad():
|
| 382 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 383 |
+
values[step] = value.flatten()
|
| 384 |
+
actions[step] = action
|
| 385 |
+
logprobs[step] = logprob
|
| 386 |
+
|
| 387 |
+
# Step Env
|
| 388 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 389 |
+
next_done = np.logical_or(terminations, truncations)
|
| 390 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 391 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 392 |
+
|
| 393 |
+
# Collect per-episode stats robustly across Gymnasium vector API variants
|
| 394 |
+
# Preferred: infos.get("final_info") contains a list of infos for envs that ended this step
|
| 395 |
+
if isinstance(infos, dict):
|
| 396 |
+
final_infos = infos.get("final_info", None)
|
| 397 |
+
if final_infos is not None:
|
| 398 |
+
for finfo in final_infos:
|
| 399 |
+
if finfo:
|
| 400 |
+
ep_r = float(finfo.get("episode", {}).get("r", 0.0))
|
| 401 |
+
# success flag may be propagated; fallback to reward sign
|
| 402 |
+
succ = bool(finfo.get("success", ep_r > 0))
|
| 403 |
+
if succ:
|
| 404 |
+
iter_outcomes.append(1)
|
| 405 |
+
else:
|
| 406 |
+
# draw if zero, else loss
|
| 407 |
+
if ep_r == 0.0:
|
| 408 |
+
iter_outcomes.append(0)
|
| 409 |
+
else:
|
| 410 |
+
iter_outcomes.append(-1)
|
| 411 |
+
iter_ep_returns.append(ep_r)
|
| 412 |
+
# Fallback: some vector envs expose aggregated episode arrays directly
|
| 413 |
+
elif "episode" in infos:
|
| 414 |
+
ep = infos.get("episode", {})
|
| 415 |
+
# ep["r"] may be array-like aligned with envs where episode ended
|
| 416 |
+
ep_r_vals = ep.get("r", [])
|
| 417 |
+
try:
|
| 418 |
+
for ep_r in list(np.atleast_1d(ep_r_vals)):
|
| 419 |
+
ep_r = float(ep_r)
|
| 420 |
+
if ep_r > 0:
|
| 421 |
+
iter_outcomes.append(1)
|
| 422 |
+
elif ep_r < 0:
|
| 423 |
+
iter_outcomes.append(-1)
|
| 424 |
+
else:
|
| 425 |
+
iter_outcomes.append(0)
|
| 426 |
+
iter_ep_returns.append(ep_r)
|
| 427 |
+
except Exception:
|
| 428 |
+
pass
|
| 429 |
+
|
| 430 |
+
# GAE Calculation
|
| 431 |
+
with torch.no_grad():
|
| 432 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 433 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 434 |
+
lastgaelam = 0
|
| 435 |
+
for t in reversed(range(args.num_steps)):
|
| 436 |
+
if t == args.num_steps - 1:
|
| 437 |
+
nextnonterminal = 1.0 - next_done
|
| 438 |
+
nextvalues = next_value
|
| 439 |
+
else:
|
| 440 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 441 |
+
nextvalues = values[t + 1]
|
| 442 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 443 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 444 |
+
returns = advantages + values
|
| 445 |
+
|
| 446 |
+
# Flatten batch
|
| 447 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 448 |
+
b_logprobs = logprobs.reshape(-1)
|
| 449 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 450 |
+
b_advantages = advantages.reshape(-1)
|
| 451 |
+
b_returns = returns.reshape(-1)
|
| 452 |
+
b_values = values.reshape(-1)
|
| 453 |
+
|
| 454 |
+
# Optimizing the policy and value network
|
| 455 |
+
b_inds = np.arange(args.batch_size)
|
| 456 |
+
clipfracs = []
|
| 457 |
+
for epoch in range(args.update_epochs):
|
| 458 |
+
np.random.shuffle(b_inds)
|
| 459 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 460 |
+
end = start + args.minibatch_size
|
| 461 |
+
mb_inds = b_inds[start:end]
|
| 462 |
+
|
| 463 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 464 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 465 |
+
ratio = logratio.exp()
|
| 466 |
+
|
| 467 |
+
with torch.no_grad():
|
| 468 |
+
# old_approx_kl = (-logratio).mean()
|
| 469 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 470 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 471 |
+
|
| 472 |
+
mb_advantages = b_advantages[mb_inds]
|
| 473 |
+
if args.norm_adv:
|
| 474 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 475 |
+
|
| 476 |
+
# Policy Loss
|
| 477 |
+
pg_loss1 = -mb_advantages * ratio
|
| 478 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 479 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 480 |
+
|
| 481 |
+
# Value Loss
|
| 482 |
+
newvalue = newvalue.view(-1)
|
| 483 |
+
if args.clip_vloss:
|
| 484 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 485 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 486 |
+
newvalue - b_values[mb_inds], -args.clip_coef, args.clip_coef,
|
| 487 |
+
)
|
| 488 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 489 |
+
v_loss = 0.5 * torch.max(v_loss_unclipped, v_loss_clipped).mean()
|
| 490 |
+
else:
|
| 491 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 492 |
+
|
| 493 |
+
entropy_loss = entropy.mean()
|
| 494 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 495 |
+
|
| 496 |
+
optimizer.zero_grad()
|
| 497 |
+
loss.backward()
|
| 498 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 499 |
+
optimizer.step()
|
| 500 |
+
|
| 501 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 502 |
+
break
|
| 503 |
+
|
| 504 |
+
# Output / Logging
|
| 505 |
+
sps = int(global_step / (time.time() - start_time))
|
| 506 |
+
progress = 100 * iteration / args.num_iterations
|
| 507 |
+
# Compute iteration-level win/draw/loss rates from finished episodes
|
| 508 |
+
if len(iter_outcomes) > 0:
|
| 509 |
+
wins = sum(1 for o in iter_outcomes if o == 1)
|
| 510 |
+
draws = sum(1 for o in iter_outcomes if o == 0)
|
| 511 |
+
losses = sum(1 for o in iter_outcomes if o == -1)
|
| 512 |
+
total_eps = len(iter_outcomes)
|
| 513 |
+
win_rate = wins / total_eps
|
| 514 |
+
draw_rate = draws / total_eps
|
| 515 |
+
loss_rate = losses / total_eps
|
| 516 |
+
avg_ep_return = float(np.mean(iter_ep_returns)) if len(iter_ep_returns) else 0.0
|
| 517 |
+
recent_winrates.append(win_rate)
|
| 518 |
+
if winrate_ema is None:
|
| 519 |
+
winrate_ema = win_rate
|
| 520 |
+
else:
|
| 521 |
+
winrate_ema = 0.1 * win_rate + 0.9 * winrate_ema
|
| 522 |
+
winrate_std_50 = float(np.std(list(recent_winrates))) if len(recent_winrates) > 1 else 0.0
|
| 523 |
+
else:
|
| 524 |
+
win_rate = draw_rate = loss_rate = avg_ep_return = 0.0
|
| 525 |
+
winrate_std_50 = float(np.std(list(recent_winrates))) if len(recent_winrates) > 1 else 0.0
|
| 526 |
+
if winrate_ema is None:
|
| 527 |
+
winrate_ema = 0.0
|
| 528 |
+
|
| 529 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d} | SPS: {sps:4d} | Rew: {rewards.mean().item():.3f} | PLoss: {pg_loss.item():.3f} | VLoss: {v_loss.item():.3f} | WinRate: {win_rate:.3f} (EMA {winrate_ema:.3f})")
|
| 530 |
+
|
| 531 |
+
if args.track:
|
| 532 |
+
import wandb
|
| 533 |
+
wandb.log({
|
| 534 |
+
"charts/avg_reward": float(rewards.mean().item()),
|
| 535 |
+
"losses/policy_loss": float(pg_loss.item()),
|
| 536 |
+
"losses/value_loss": float(v_loss.item()),
|
| 537 |
+
"global_step": global_step,
|
| 538 |
+
"charts/SPS": sps,
|
| 539 |
+
"charts/win_rate": float(win_rate),
|
| 540 |
+
"charts/draw_rate": float(draw_rate),
|
| 541 |
+
"charts/loss_rate": float(loss_rate),
|
| 542 |
+
"charts/avg_ep_return": float(avg_ep_return),
|
| 543 |
+
"charts/winrate_ema": float(winrate_ema),
|
| 544 |
+
"charts/winrate_std_50": float(winrate_std_50),
|
| 545 |
+
})
|
| 546 |
+
|
| 547 |
+
# Eval
|
| 548 |
+
if iteration == 1 or iteration % eval_every_iters == 0:
|
| 549 |
+
print(f"Running evaluation at step {global_step}...")
|
| 550 |
+
try:
|
| 551 |
+
def eval_thunk():
|
| 552 |
+
return make_env(0, run_name, args.seed + 9999, False)()
|
| 553 |
+
eval_metrics = collect_eval_trajectories(agent, eval_thunk, n_episodes=args.eval_episodes, step_tag=global_step)
|
| 554 |
+
if args.track:
|
| 555 |
+
import wandb
|
| 556 |
+
wandb.log({
|
| 557 |
+
"eval/success_rate": float(eval_metrics.get("success_rate", 0.0)),
|
| 558 |
+
"eval/avg_return": float(eval_metrics.get("avg_return", 0.0)),
|
| 559 |
+
"global_step": global_step,
|
| 560 |
+
})
|
| 561 |
+
except Exception as e:
|
| 562 |
+
print(f"Eval failed: {e}")
|
| 563 |
+
|
| 564 |
+
envs.close()
|
cleanrl/cleanrl/ppo_continuous_action_isaacgym/ppo_continuous_action_isaacgym.py
ADDED
|
@@ -0,0 +1,393 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2018-2022, NVIDIA Corporation
|
| 2 |
+
# All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Redistribution and use in source and binary forms, with or without
|
| 5 |
+
# modification, are permitted provided that the following conditions are met:
|
| 6 |
+
#
|
| 7 |
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
| 8 |
+
# list of conditions and the following disclaimer.
|
| 9 |
+
#
|
| 10 |
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
| 11 |
+
# this list of conditions and the following disclaimer in the documentation
|
| 12 |
+
# and/or other materials provided with the distribution.
|
| 13 |
+
#
|
| 14 |
+
# 3. Neither the name of the copyright holder nor the names of its
|
| 15 |
+
# contributors may be used to endorse or promote products derived from
|
| 16 |
+
# this software without specific prior written permission.
|
| 17 |
+
#
|
| 18 |
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
| 19 |
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
| 20 |
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
| 21 |
+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
| 22 |
+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
| 23 |
+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
| 24 |
+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
| 25 |
+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
| 26 |
+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| 27 |
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| 28 |
+
|
| 29 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/ppo/#ppo_continuous_action_isaacgympy
|
| 30 |
+
import os
|
| 31 |
+
import random
|
| 32 |
+
import time
|
| 33 |
+
from dataclasses import dataclass
|
| 34 |
+
|
| 35 |
+
import gym
|
| 36 |
+
import isaacgym # noqa
|
| 37 |
+
import isaacgymenvs
|
| 38 |
+
import numpy as np
|
| 39 |
+
import torch
|
| 40 |
+
import torch.nn as nn
|
| 41 |
+
import torch.optim as optim
|
| 42 |
+
import tyro
|
| 43 |
+
from torch.distributions.normal import Normal
|
| 44 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@dataclass
|
| 48 |
+
class Args:
|
| 49 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 50 |
+
"""the name of this experiment"""
|
| 51 |
+
seed: int = 1
|
| 52 |
+
"""seed of the experiment"""
|
| 53 |
+
torch_deterministic: bool = True
|
| 54 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 55 |
+
cuda: bool = True
|
| 56 |
+
"""if toggled, cuda will be enabled by default"""
|
| 57 |
+
track: bool = False
|
| 58 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 59 |
+
wandb_project_name: str = "cleanRL"
|
| 60 |
+
"""the wandb's project name"""
|
| 61 |
+
wandb_entity: str = None
|
| 62 |
+
"""the entity (team) of wandb's project"""
|
| 63 |
+
capture_video: bool = False
|
| 64 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 65 |
+
|
| 66 |
+
# Algorithm specific arguments
|
| 67 |
+
env_id: str = "Ant"
|
| 68 |
+
"""the id of the environment"""
|
| 69 |
+
total_timesteps: int = 30000000
|
| 70 |
+
"""total timesteps of the experiments"""
|
| 71 |
+
learning_rate: float = 0.0026
|
| 72 |
+
"""the learning rate of the optimizer"""
|
| 73 |
+
num_envs: int = 4096
|
| 74 |
+
"""the number of parallel game environments"""
|
| 75 |
+
num_steps: int = 16
|
| 76 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 77 |
+
anneal_lr: bool = False
|
| 78 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 79 |
+
gamma: float = 0.99
|
| 80 |
+
"""the discount factor gamma"""
|
| 81 |
+
gae_lambda: float = 0.95
|
| 82 |
+
"""the lambda for the general advantage estimation"""
|
| 83 |
+
num_minibatches: int = 2
|
| 84 |
+
"""the number of mini-batches"""
|
| 85 |
+
update_epochs: int = 4
|
| 86 |
+
"""the K epochs to update the policy"""
|
| 87 |
+
norm_adv: bool = True
|
| 88 |
+
"""Toggles advantages normalization"""
|
| 89 |
+
clip_coef: float = 0.2
|
| 90 |
+
"""the surrogate clipping coefficient"""
|
| 91 |
+
clip_vloss: bool = False
|
| 92 |
+
"""Toggles whether or not to use a clipped loss for the value function, as per the paper."""
|
| 93 |
+
ent_coef: float = 0.0
|
| 94 |
+
"""coefficient of the entropy"""
|
| 95 |
+
vf_coef: float = 2
|
| 96 |
+
"""coefficient of the value function"""
|
| 97 |
+
max_grad_norm: float = 1
|
| 98 |
+
"""the maximum norm for the gradient clipping"""
|
| 99 |
+
target_kl: float = None
|
| 100 |
+
"""the target KL divergence threshold"""
|
| 101 |
+
reward_scaler: float = 1
|
| 102 |
+
"""the scale factor applied to the reward during training"""
|
| 103 |
+
record_video_step_frequency: int = 1464
|
| 104 |
+
"""the frequency at which to record the videos"""
|
| 105 |
+
|
| 106 |
+
# to be filled in runtime
|
| 107 |
+
batch_size: int = 0
|
| 108 |
+
"""the batch size (computed in runtime)"""
|
| 109 |
+
minibatch_size: int = 0
|
| 110 |
+
"""the mini-batch size (computed in runtime)"""
|
| 111 |
+
num_iterations: int = 0
|
| 112 |
+
"""the number of iterations (computed in runtime)"""
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class RecordEpisodeStatisticsTorch(gym.Wrapper):
|
| 116 |
+
def __init__(self, env, device):
|
| 117 |
+
super().__init__(env)
|
| 118 |
+
self.num_envs = getattr(env, "num_envs", 1)
|
| 119 |
+
self.device = device
|
| 120 |
+
self.episode_returns = None
|
| 121 |
+
self.episode_lengths = None
|
| 122 |
+
|
| 123 |
+
def reset(self, **kwargs):
|
| 124 |
+
observations = super().reset(**kwargs)
|
| 125 |
+
self.episode_returns = torch.zeros(self.num_envs, dtype=torch.float32, device=self.device)
|
| 126 |
+
self.episode_lengths = torch.zeros(self.num_envs, dtype=torch.int32, device=self.device)
|
| 127 |
+
self.returned_episode_returns = torch.zeros(self.num_envs, dtype=torch.float32, device=self.device)
|
| 128 |
+
self.returned_episode_lengths = torch.zeros(self.num_envs, dtype=torch.int32, device=self.device)
|
| 129 |
+
return observations
|
| 130 |
+
|
| 131 |
+
def step(self, action):
|
| 132 |
+
observations, rewards, dones, infos = super().step(action)
|
| 133 |
+
self.episode_returns += rewards
|
| 134 |
+
self.episode_lengths += 1
|
| 135 |
+
self.returned_episode_returns[:] = self.episode_returns
|
| 136 |
+
self.returned_episode_lengths[:] = self.episode_lengths
|
| 137 |
+
self.episode_returns *= 1 - dones
|
| 138 |
+
self.episode_lengths *= 1 - dones
|
| 139 |
+
infos["r"] = self.returned_episode_returns
|
| 140 |
+
infos["l"] = self.returned_episode_lengths
|
| 141 |
+
return (
|
| 142 |
+
observations,
|
| 143 |
+
rewards,
|
| 144 |
+
dones,
|
| 145 |
+
infos,
|
| 146 |
+
)
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 150 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 151 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 152 |
+
return layer
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
class Agent(nn.Module):
|
| 156 |
+
def __init__(self, envs):
|
| 157 |
+
super().__init__()
|
| 158 |
+
self.critic = nn.Sequential(
|
| 159 |
+
layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 256)),
|
| 160 |
+
nn.Tanh(),
|
| 161 |
+
layer_init(nn.Linear(256, 256)),
|
| 162 |
+
nn.Tanh(),
|
| 163 |
+
layer_init(nn.Linear(256, 1), std=1.0),
|
| 164 |
+
)
|
| 165 |
+
self.actor_mean = nn.Sequential(
|
| 166 |
+
layer_init(nn.Linear(np.array(envs.single_observation_space.shape).prod(), 256)),
|
| 167 |
+
nn.Tanh(),
|
| 168 |
+
layer_init(nn.Linear(256, 256)),
|
| 169 |
+
nn.Tanh(),
|
| 170 |
+
layer_init(nn.Linear(256, np.prod(envs.single_action_space.shape)), std=0.01),
|
| 171 |
+
)
|
| 172 |
+
self.actor_logstd = nn.Parameter(torch.zeros(1, np.prod(envs.single_action_space.shape)))
|
| 173 |
+
|
| 174 |
+
def get_value(self, x):
|
| 175 |
+
return self.critic(x)
|
| 176 |
+
|
| 177 |
+
def get_action_and_value(self, x, action=None):
|
| 178 |
+
action_mean = self.actor_mean(x)
|
| 179 |
+
action_logstd = self.actor_logstd.expand_as(action_mean)
|
| 180 |
+
action_std = torch.exp(action_logstd)
|
| 181 |
+
probs = Normal(action_mean, action_std)
|
| 182 |
+
if action is None:
|
| 183 |
+
action = probs.sample()
|
| 184 |
+
return action, probs.log_prob(action).sum(1), probs.entropy().sum(1), self.critic(x)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class ExtractObsWrapper(gym.ObservationWrapper):
|
| 188 |
+
def observation(self, obs):
|
| 189 |
+
return obs["obs"]
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
if __name__ == "__main__":
|
| 193 |
+
args = tyro.cli(Args)
|
| 194 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 195 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 196 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 197 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 198 |
+
if args.track:
|
| 199 |
+
import wandb
|
| 200 |
+
|
| 201 |
+
wandb.init(
|
| 202 |
+
project=args.wandb_project_name,
|
| 203 |
+
entity=args.wandb_entity,
|
| 204 |
+
sync_tensorboard=True,
|
| 205 |
+
config=vars(args),
|
| 206 |
+
name=run_name,
|
| 207 |
+
monitor_gym=True,
|
| 208 |
+
save_code=True,
|
| 209 |
+
)
|
| 210 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 211 |
+
writer.add_text(
|
| 212 |
+
"hyperparameters",
|
| 213 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 214 |
+
)
|
| 215 |
+
|
| 216 |
+
# TRY NOT TO MODIFY: seeding
|
| 217 |
+
random.seed(args.seed)
|
| 218 |
+
np.random.seed(args.seed)
|
| 219 |
+
torch.manual_seed(args.seed)
|
| 220 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 221 |
+
|
| 222 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 223 |
+
|
| 224 |
+
# env setup
|
| 225 |
+
envs = isaacgymenvs.make(
|
| 226 |
+
seed=args.seed,
|
| 227 |
+
task=args.env_id,
|
| 228 |
+
num_envs=args.num_envs,
|
| 229 |
+
sim_device="cuda:0" if torch.cuda.is_available() and args.cuda else "cpu",
|
| 230 |
+
rl_device="cuda:0" if torch.cuda.is_available() and args.cuda else "cpu",
|
| 231 |
+
graphics_device_id=0 if torch.cuda.is_available() and args.cuda else -1,
|
| 232 |
+
headless=False if torch.cuda.is_available() and args.cuda else True,
|
| 233 |
+
multi_gpu=False,
|
| 234 |
+
virtual_screen_capture=args.capture_video,
|
| 235 |
+
force_render=False,
|
| 236 |
+
)
|
| 237 |
+
if args.capture_video:
|
| 238 |
+
envs.is_vector_env = True
|
| 239 |
+
print(f"record_video_step_frequency={args.record_video_step_frequency}")
|
| 240 |
+
envs = gym.wrappers.RecordVideo(
|
| 241 |
+
envs,
|
| 242 |
+
f"videos/{run_name}",
|
| 243 |
+
step_trigger=lambda step: step % args.record_video_step_frequency == 0,
|
| 244 |
+
video_length=100, # for each video record up to 100 steps
|
| 245 |
+
)
|
| 246 |
+
envs = ExtractObsWrapper(envs)
|
| 247 |
+
envs = RecordEpisodeStatisticsTorch(envs, device)
|
| 248 |
+
envs.single_action_space = envs.action_space
|
| 249 |
+
envs.single_observation_space = envs.observation_space
|
| 250 |
+
assert isinstance(envs.single_action_space, gym.spaces.Box), "only continuous action space is supported"
|
| 251 |
+
|
| 252 |
+
agent = Agent(envs).to(device)
|
| 253 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 254 |
+
|
| 255 |
+
# ALGO Logic: Storage setup
|
| 256 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape, dtype=torch.float).to(device)
|
| 257 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape, dtype=torch.float).to(device)
|
| 258 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs), dtype=torch.float).to(device)
|
| 259 |
+
rewards = torch.zeros((args.num_steps, args.num_envs), dtype=torch.float).to(device)
|
| 260 |
+
dones = torch.zeros((args.num_steps, args.num_envs), dtype=torch.float).to(device)
|
| 261 |
+
values = torch.zeros((args.num_steps, args.num_envs), dtype=torch.float).to(device)
|
| 262 |
+
advantages = torch.zeros_like(rewards, dtype=torch.float).to(device)
|
| 263 |
+
|
| 264 |
+
# TRY NOT TO MODIFY: start the game
|
| 265 |
+
global_step = 0
|
| 266 |
+
start_time = time.time()
|
| 267 |
+
next_obs = envs.reset()
|
| 268 |
+
next_done = torch.zeros(args.num_envs, dtype=torch.float).to(device)
|
| 269 |
+
|
| 270 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 271 |
+
# Annealing the rate if instructed to do so.
|
| 272 |
+
if args.anneal_lr:
|
| 273 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 274 |
+
lrnow = frac * args.learning_rate
|
| 275 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 276 |
+
|
| 277 |
+
for step in range(0, args.num_steps):
|
| 278 |
+
global_step += args.num_envs
|
| 279 |
+
obs[step] = next_obs
|
| 280 |
+
dones[step] = next_done
|
| 281 |
+
|
| 282 |
+
# ALGO LOGIC: action logic
|
| 283 |
+
with torch.no_grad():
|
| 284 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 285 |
+
values[step] = value.flatten()
|
| 286 |
+
actions[step] = action
|
| 287 |
+
logprobs[step] = logprob
|
| 288 |
+
|
| 289 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 290 |
+
next_obs, rewards[step], next_done, info = envs.step(action)
|
| 291 |
+
if 0 <= step <= 2:
|
| 292 |
+
for idx, d in enumerate(next_done):
|
| 293 |
+
if d:
|
| 294 |
+
episodic_return = info["r"][idx].item()
|
| 295 |
+
print(f"global_step={global_step}, episodic_return={episodic_return}")
|
| 296 |
+
writer.add_scalar("charts/episodic_return", episodic_return, global_step)
|
| 297 |
+
writer.add_scalar("charts/episodic_length", info["l"][idx], global_step)
|
| 298 |
+
if "consecutive_successes" in info: # ShadowHand and AllegroHand metric
|
| 299 |
+
writer.add_scalar(
|
| 300 |
+
"charts/consecutive_successes", info["consecutive_successes"].item(), global_step
|
| 301 |
+
)
|
| 302 |
+
break
|
| 303 |
+
|
| 304 |
+
# bootstrap value if not done
|
| 305 |
+
with torch.no_grad():
|
| 306 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 307 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 308 |
+
lastgaelam = 0
|
| 309 |
+
for t in reversed(range(args.num_steps)):
|
| 310 |
+
if t == args.num_steps - 1:
|
| 311 |
+
nextnonterminal = 1.0 - next_done
|
| 312 |
+
nextvalues = next_value
|
| 313 |
+
else:
|
| 314 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 315 |
+
nextvalues = values[t + 1]
|
| 316 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 317 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 318 |
+
returns = advantages + values
|
| 319 |
+
|
| 320 |
+
# flatten the batch
|
| 321 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 322 |
+
b_logprobs = logprobs.reshape(-1)
|
| 323 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 324 |
+
b_advantages = advantages.reshape(-1)
|
| 325 |
+
b_returns = returns.reshape(-1)
|
| 326 |
+
b_values = values.reshape(-1)
|
| 327 |
+
|
| 328 |
+
# Optimizing the policy and value network
|
| 329 |
+
clipfracs = []
|
| 330 |
+
for epoch in range(args.update_epochs):
|
| 331 |
+
b_inds = torch.randperm(args.batch_size, device=device)
|
| 332 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 333 |
+
end = start + args.minibatch_size
|
| 334 |
+
mb_inds = b_inds[start:end]
|
| 335 |
+
|
| 336 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions[mb_inds])
|
| 337 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 338 |
+
ratio = logratio.exp()
|
| 339 |
+
|
| 340 |
+
with torch.no_grad():
|
| 341 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 342 |
+
old_approx_kl = (-logratio).mean()
|
| 343 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 344 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 345 |
+
|
| 346 |
+
mb_advantages = b_advantages[mb_inds]
|
| 347 |
+
if args.norm_adv:
|
| 348 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 349 |
+
|
| 350 |
+
# Policy loss
|
| 351 |
+
pg_loss1 = -mb_advantages * ratio
|
| 352 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 353 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 354 |
+
|
| 355 |
+
# Value loss
|
| 356 |
+
newvalue = newvalue.view(-1)
|
| 357 |
+
if args.clip_vloss:
|
| 358 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 359 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 360 |
+
newvalue - b_values[mb_inds],
|
| 361 |
+
-args.clip_coef,
|
| 362 |
+
args.clip_coef,
|
| 363 |
+
)
|
| 364 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 365 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 366 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 367 |
+
else:
|
| 368 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 369 |
+
|
| 370 |
+
entropy_loss = entropy.mean()
|
| 371 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 372 |
+
|
| 373 |
+
optimizer.zero_grad()
|
| 374 |
+
loss.backward()
|
| 375 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 376 |
+
optimizer.step()
|
| 377 |
+
|
| 378 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 379 |
+
break
|
| 380 |
+
|
| 381 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 382 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 383 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 384 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 385 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 386 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 387 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 388 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 389 |
+
print("SPS:", int(global_step / (time.time() - start_time)))
|
| 390 |
+
writer.add_scalar("charts/SPS", int(global_step / (time.time() - start_time)), global_step)
|
| 391 |
+
|
| 392 |
+
# envs.close()
|
| 393 |
+
writer.close()
|
cleanrl/cleanrl/ppo_frozenlake.py
ADDED
|
@@ -0,0 +1,567 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO implementation for RAGEN FrozenLake environment
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
import json
|
| 7 |
+
from pathlib import Path
|
| 8 |
+
|
| 9 |
+
import gymnasium as gym
|
| 10 |
+
import numpy as np
|
| 11 |
+
import torch
|
| 12 |
+
import torch.nn as nn
|
| 13 |
+
import torch.optim as optim
|
| 14 |
+
import tyro
|
| 15 |
+
from torch.distributions.categorical import Categorical
|
| 16 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 17 |
+
|
| 18 |
+
import sys
|
| 19 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 20 |
+
|
| 21 |
+
from ragen.env.frozen_lake.env import FrozenLakeEnv
|
| 22 |
+
from ragen.env.frozen_lake.config import FrozenLakeEnvConfig
|
| 23 |
+
from ragen_wrappers import FrozenLakeWrapper
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
@dataclass
|
| 27 |
+
class Args:
|
| 28 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 29 |
+
"""the name of this experiment"""
|
| 30 |
+
seed: int = 1
|
| 31 |
+
"""seed of the experiment"""
|
| 32 |
+
torch_deterministic: bool = True
|
| 33 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 34 |
+
cuda: bool = True
|
| 35 |
+
"""if toggled, cuda will be enabled by default"""
|
| 36 |
+
track: bool = True
|
| 37 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 38 |
+
wandb_project_name: str = "cleanRL"
|
| 39 |
+
"""the wandb's project name"""
|
| 40 |
+
wandb_entity: str = None
|
| 41 |
+
"""the entity (team) of wandb's project"""
|
| 42 |
+
capture_video: bool = False
|
| 43 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 44 |
+
|
| 45 |
+
# Algorithm specific arguments
|
| 46 |
+
env_id: str = "FrozenLake"
|
| 47 |
+
"""the id of the environment"""
|
| 48 |
+
total_timesteps: int = 1000000
|
| 49 |
+
"""total timesteps of the experiments"""
|
| 50 |
+
learning_rate: float = 2.5e-4
|
| 51 |
+
"""the learning rate of the optimizer"""
|
| 52 |
+
num_envs: int = 8
|
| 53 |
+
"""the number of parallel game environments"""
|
| 54 |
+
num_steps: int = 128
|
| 55 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 56 |
+
anneal_lr: bool = True
|
| 57 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 58 |
+
gamma: float = 0.99
|
| 59 |
+
"""the discount factor gamma"""
|
| 60 |
+
gae_lambda: float = 0.95
|
| 61 |
+
"""the lambda for the general advantage estimation"""
|
| 62 |
+
num_minibatches: int = 4
|
| 63 |
+
"""the number of mini-batches"""
|
| 64 |
+
update_epochs: int = 4
|
| 65 |
+
"""the K epochs to update the policy"""
|
| 66 |
+
norm_adv: bool = True
|
| 67 |
+
"""Toggles advantages normalization"""
|
| 68 |
+
clip_coef: float = 0.2
|
| 69 |
+
"""the surrogate clipping coefficient"""
|
| 70 |
+
clip_vloss: bool = True
|
| 71 |
+
"""Toggles whether or not to use a clipped loss for the value function, as per the paper."""
|
| 72 |
+
ent_coef: float = 0.01
|
| 73 |
+
"""coefficient of the entropy"""
|
| 74 |
+
vf_coef: float = 0.5
|
| 75 |
+
"""coefficient of the value function"""
|
| 76 |
+
max_grad_norm: float = 0.5
|
| 77 |
+
"""the maximum norm for the gradient clipping"""
|
| 78 |
+
target_kl: float = None
|
| 79 |
+
"""the target KL divergence threshold"""
|
| 80 |
+
save_plots: bool = True
|
| 81 |
+
"""whether to save PNG/CSV curves for training trend"""
|
| 82 |
+
eval_splits: int = 5
|
| 83 |
+
"""number of test checkpoints (every 1/eval_splits of training)"""
|
| 84 |
+
eval_episodes: int = 4000
|
| 85 |
+
"""number of test trajectories to collect per checkpoint"""
|
| 86 |
+
|
| 87 |
+
# FrozenLake specific
|
| 88 |
+
grid_size: int = 4
|
| 89 |
+
"""size of the frozen lake grid"""
|
| 90 |
+
is_slippery: bool = True
|
| 91 |
+
"""whether the ice is slippery"""
|
| 92 |
+
|
| 93 |
+
# to be filled in runtime
|
| 94 |
+
batch_size: int = 0
|
| 95 |
+
"""the batch size (computed in runtime)"""
|
| 96 |
+
minibatch_size: int = 0
|
| 97 |
+
"""the mini-batch size (computed in runtime)"""
|
| 98 |
+
num_iterations: int = 0
|
| 99 |
+
"""the number of iterations (computed in runtime)"""
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def make_env(env_id, idx, capture_video, run_name, seed, grid_size, is_slippery):
|
| 103 |
+
def thunk():
|
| 104 |
+
config = FrozenLakeEnvConfig(
|
| 105 |
+
size=grid_size,
|
| 106 |
+
p=0.8,
|
| 107 |
+
is_slippery=is_slippery,
|
| 108 |
+
map_seed=seed + idx
|
| 109 |
+
)
|
| 110 |
+
env = FrozenLakeEnv(config)
|
| 111 |
+
env = FrozenLakeWrapper(env)
|
| 112 |
+
# Add a time limit to prevent infinite loops during evaluation/training
|
| 113 |
+
max_steps = int(grid_size * grid_size * 4)
|
| 114 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=max_steps)
|
| 115 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 116 |
+
if capture_video and idx == 0:
|
| 117 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 118 |
+
return env
|
| 119 |
+
return thunk
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 123 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 124 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 125 |
+
return layer
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
class Agent(nn.Module):
|
| 129 |
+
def __init__(self, envs):
|
| 130 |
+
super().__init__()
|
| 131 |
+
obs_shape = np.array(envs.single_observation_space.shape).prod()
|
| 132 |
+
self.critic = nn.Sequential(
|
| 133 |
+
layer_init(nn.Linear(obs_shape, 128)),
|
| 134 |
+
nn.Tanh(),
|
| 135 |
+
layer_init(nn.Linear(128, 128)),
|
| 136 |
+
nn.Tanh(),
|
| 137 |
+
layer_init(nn.Linear(128, 1), std=1.0),
|
| 138 |
+
)
|
| 139 |
+
self.actor = nn.Sequential(
|
| 140 |
+
layer_init(nn.Linear(obs_shape, 128)),
|
| 141 |
+
nn.Tanh(),
|
| 142 |
+
layer_init(nn.Linear(128, 128)),
|
| 143 |
+
nn.Tanh(),
|
| 144 |
+
layer_init(nn.Linear(128, envs.single_action_space.n), std=0.01),
|
| 145 |
+
)
|
| 146 |
+
|
| 147 |
+
def get_value(self, x):
|
| 148 |
+
return self.critic(x)
|
| 149 |
+
|
| 150 |
+
def get_action_and_value(self, x, action=None):
|
| 151 |
+
logits = self.actor(x)
|
| 152 |
+
probs = Categorical(logits=logits)
|
| 153 |
+
if action is None:
|
| 154 |
+
action = probs.sample()
|
| 155 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
if __name__ == "__main__":
|
| 159 |
+
args = tyro.cli(Args)
|
| 160 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 161 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 162 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 163 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 164 |
+
if args.track:
|
| 165 |
+
import wandb
|
| 166 |
+
|
| 167 |
+
wandb.init(
|
| 168 |
+
project=args.wandb_project_name,
|
| 169 |
+
entity=args.wandb_entity,
|
| 170 |
+
sync_tensorboard=True,
|
| 171 |
+
config=vars(args),
|
| 172 |
+
name=run_name,
|
| 173 |
+
monitor_gym=True,
|
| 174 |
+
save_code=True,
|
| 175 |
+
)
|
| 176 |
+
# Define step metric and groups for better chart organization
|
| 177 |
+
try:
|
| 178 |
+
wandb.define_metric("global_step")
|
| 179 |
+
for prefix in ["train/*", "rollout/*", "eval/*", "losses/*", "charts/*", "perf/*"]:
|
| 180 |
+
wandb.define_metric(prefix, step_metric="global_step")
|
| 181 |
+
except Exception:
|
| 182 |
+
pass
|
| 183 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 184 |
+
writer.add_text(
|
| 185 |
+
"hyperparameters",
|
| 186 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
# TRY NOT TO MODIFY: seeding
|
| 190 |
+
random.seed(args.seed)
|
| 191 |
+
np.random.seed(args.seed)
|
| 192 |
+
torch.manual_seed(args.seed)
|
| 193 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 194 |
+
|
| 195 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 196 |
+
|
| 197 |
+
# env setup
|
| 198 |
+
envs = gym.vector.SyncVectorEnv(
|
| 199 |
+
[make_env(args.env_id, i, args.capture_video, run_name, args.seed, args.grid_size, args.is_slippery)
|
| 200 |
+
for i in range(args.num_envs)],
|
| 201 |
+
)
|
| 202 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 203 |
+
|
| 204 |
+
agent = Agent(envs).to(device)
|
| 205 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 206 |
+
|
| 207 |
+
# ALGO Logic: Storage setup
|
| 208 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 209 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 210 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 211 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 212 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 213 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 214 |
+
|
| 215 |
+
# TRY NOT TO MODIFY: start the game
|
| 216 |
+
global_step = 0
|
| 217 |
+
start_time = time.time()
|
| 218 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 219 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 220 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 221 |
+
|
| 222 |
+
episode_returns = []
|
| 223 |
+
episode_steps = []
|
| 224 |
+
episode_successes = []
|
| 225 |
+
# Helper: evaluate greedy policy rollout and dump trajectories
|
| 226 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes, step_tag):
|
| 227 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 228 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 229 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 230 |
+
env = make_env_fn()
|
| 231 |
+
collected = 0
|
| 232 |
+
summary_returns = []
|
| 233 |
+
summary_success = []
|
| 234 |
+
with out_path.open("w") as f:
|
| 235 |
+
while collected < n_episodes:
|
| 236 |
+
# Make sure to reseed and also guard against long episodes
|
| 237 |
+
state, _ = env.reset(seed=args.seed + 100000 + collected)
|
| 238 |
+
traj_states = [state.tolist()]
|
| 239 |
+
traj_actions = []
|
| 240 |
+
traj_rewards = []
|
| 241 |
+
traj_dones = []
|
| 242 |
+
traj_success = []
|
| 243 |
+
done = False
|
| 244 |
+
step_count = 0
|
| 245 |
+
max_eval_steps = getattr(env, '_max_episode_steps', None) or int(args.grid_size * args.grid_size * 4)
|
| 246 |
+
while not done:
|
| 247 |
+
with torch.no_grad():
|
| 248 |
+
logits = agent_model.actor(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 249 |
+
action = int(torch.argmax(logits, dim=1).item())
|
| 250 |
+
next_state, reward, terminated, truncated, info = env.step(action)
|
| 251 |
+
traj_actions.append(int(action))
|
| 252 |
+
traj_rewards.append(float(reward))
|
| 253 |
+
step_count += 1
|
| 254 |
+
d = bool(terminated) or bool(truncated) or (step_count >= max_eval_steps)
|
| 255 |
+
traj_dones.append(d)
|
| 256 |
+
traj_success.append(bool(info.get('success', False)))
|
| 257 |
+
state = next_state
|
| 258 |
+
traj_states.append(state.tolist())
|
| 259 |
+
done = d
|
| 260 |
+
ep_ret = float(sum(traj_rewards))
|
| 261 |
+
ep_succ = bool(any(traj_success))
|
| 262 |
+
record = {
|
| 263 |
+
"states": traj_states,
|
| 264 |
+
"actions": traj_actions,
|
| 265 |
+
"rewards": traj_rewards,
|
| 266 |
+
"dones": traj_dones,
|
| 267 |
+
"success": traj_success,
|
| 268 |
+
"episode_return": ep_ret,
|
| 269 |
+
"episode_success": ep_succ,
|
| 270 |
+
}
|
| 271 |
+
f.write(json.dumps(record) + "\n")
|
| 272 |
+
collected += 1
|
| 273 |
+
summary_returns.append(ep_ret)
|
| 274 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 275 |
+
env.close()
|
| 276 |
+
# write summary metrics
|
| 277 |
+
try:
|
| 278 |
+
metrics = {
|
| 279 |
+
"global_step": int(step_tag),
|
| 280 |
+
"episodes": int(n_episodes),
|
| 281 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 282 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 283 |
+
"std_return": float(np.std(summary_returns)) if len(summary_returns) else 0.0,
|
| 284 |
+
}
|
| 285 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 286 |
+
json.dump(metrics, mf)
|
| 287 |
+
except Exception as e:
|
| 288 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 289 |
+
|
| 290 |
+
eval_every_iters = max(1, args.num_iterations // args.eval_splits)
|
| 291 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 292 |
+
# Annealing the rate if instructed to do so.
|
| 293 |
+
if args.anneal_lr:
|
| 294 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 295 |
+
lrnow = frac * args.learning_rate
|
| 296 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 297 |
+
|
| 298 |
+
for step in range(0, args.num_steps):
|
| 299 |
+
global_step += args.num_envs
|
| 300 |
+
obs[step] = next_obs
|
| 301 |
+
dones[step] = next_done
|
| 302 |
+
|
| 303 |
+
# ALGO LOGIC: action logic
|
| 304 |
+
with torch.no_grad():
|
| 305 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 306 |
+
values[step] = value.flatten()
|
| 307 |
+
actions[step] = action
|
| 308 |
+
logprobs[step] = logprob
|
| 309 |
+
|
| 310 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 311 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 312 |
+
next_done = np.logical_or(terminations, truncations)
|
| 313 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 314 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 315 |
+
# Vectorized episode end handling: use RecordEpisodeStatistics outputs
|
| 316 |
+
try:
|
| 317 |
+
mask = None
|
| 318 |
+
if isinstance(infos, dict):
|
| 319 |
+
if "_episode" in infos:
|
| 320 |
+
mask = np.asarray(infos["_episode"]).astype(bool)
|
| 321 |
+
elif "episode" in infos and isinstance(infos["episode"], dict) and "_l" in infos["episode"]:
|
| 322 |
+
mask = np.asarray(infos["episode"]["_l"]).astype(bool)
|
| 323 |
+
if mask is not None and np.any(mask):
|
| 324 |
+
# For each finished sub-env, log its episode stats
|
| 325 |
+
r_arr = np.asarray(infos.get("episode", {}).get("r", np.zeros_like(mask, dtype=float)))
|
| 326 |
+
l_arr = np.asarray(infos.get("episode", {}).get("l", np.zeros_like(mask, dtype=int)))
|
| 327 |
+
succ_arr = np.asarray(infos.get("success", np.zeros_like(mask, dtype=bool))).astype(float)
|
| 328 |
+
for i in np.where(mask)[0]:
|
| 329 |
+
ep_r = float(r_arr[i])
|
| 330 |
+
ep_l = int(l_arr[i])
|
| 331 |
+
ep_succ = float(succ_arr[i])
|
| 332 |
+
episode_returns.append(ep_r)
|
| 333 |
+
episode_steps.append(global_step)
|
| 334 |
+
episode_successes.append(ep_succ)
|
| 335 |
+
# print(f"global_step={global_step}, episodic_return={ep_r}")
|
| 336 |
+
writer.add_scalar("charts/episodic_return", ep_r, global_step)
|
| 337 |
+
writer.add_scalar("charts/episodic_length", ep_l, global_step)
|
| 338 |
+
writer.add_scalar("charts/success", ep_succ, global_step)
|
| 339 |
+
if len(episode_successes) >= 100:
|
| 340 |
+
writer.add_scalar("charts/success_rate_100", float(np.mean(episode_successes[-100:])), global_step)
|
| 341 |
+
if args.track:
|
| 342 |
+
try:
|
| 343 |
+
import wandb
|
| 344 |
+
log_dict = {
|
| 345 |
+
"global_step": int(global_step),
|
| 346 |
+
# per-step averages across finished episodes
|
| 347 |
+
"rollout/ep_rew_mean": float(np.mean(r_arr[mask])) if np.any(mask) else None,
|
| 348 |
+
"rollout/ep_len_mean": float(np.mean(l_arr[mask])) if np.any(mask) else None,
|
| 349 |
+
"rollout/success_rate": float(np.mean(succ_arr[mask])) if np.any(mask) else None,
|
| 350 |
+
}
|
| 351 |
+
# Also log the latest episode stats individually for convenience
|
| 352 |
+
if np.any(mask):
|
| 353 |
+
last_idx = np.where(mask)[0][-1]
|
| 354 |
+
log_dict.update({
|
| 355 |
+
"train/episodic_return": float(r_arr[last_idx]),
|
| 356 |
+
"train/episodic_length": int(l_arr[last_idx]),
|
| 357 |
+
"train/success": float(succ_arr[last_idx]),
|
| 358 |
+
"train/success_rate_100": float(np.mean(episode_successes[-100:])) if len(episode_successes) >= 100 else None,
|
| 359 |
+
})
|
| 360 |
+
wandb.log(log_dict, step=global_step)
|
| 361 |
+
except Exception:
|
| 362 |
+
pass
|
| 363 |
+
except Exception:
|
| 364 |
+
# Be robust to any unexpected info structure
|
| 365 |
+
pass
|
| 366 |
+
|
| 367 |
+
# bootstrap value if not done
|
| 368 |
+
with torch.no_grad():
|
| 369 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 370 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 371 |
+
lastgaelam = 0
|
| 372 |
+
for t in reversed(range(args.num_steps)):
|
| 373 |
+
if t == args.num_steps - 1:
|
| 374 |
+
nextnonterminal = 1.0 - next_done
|
| 375 |
+
nextvalues = next_value
|
| 376 |
+
else:
|
| 377 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 378 |
+
nextvalues = values[t + 1]
|
| 379 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 380 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 381 |
+
returns = advantages + values
|
| 382 |
+
|
| 383 |
+
# flatten the batch
|
| 384 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 385 |
+
b_logprobs = logprobs.reshape(-1)
|
| 386 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 387 |
+
b_advantages = advantages.reshape(-1)
|
| 388 |
+
b_returns = returns.reshape(-1)
|
| 389 |
+
b_values = values.reshape(-1)
|
| 390 |
+
|
| 391 |
+
# Optimizing the policy and value network
|
| 392 |
+
b_inds = np.arange(args.batch_size)
|
| 393 |
+
clipfracs = []
|
| 394 |
+
for epoch in range(args.update_epochs):
|
| 395 |
+
np.random.shuffle(b_inds)
|
| 396 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 397 |
+
end = start + args.minibatch_size
|
| 398 |
+
mb_inds = b_inds[start:end]
|
| 399 |
+
|
| 400 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 401 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 402 |
+
ratio = logratio.exp()
|
| 403 |
+
|
| 404 |
+
with torch.no_grad():
|
| 405 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 406 |
+
old_approx_kl = (-logratio).mean()
|
| 407 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 408 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 409 |
+
|
| 410 |
+
mb_advantages = b_advantages[mb_inds]
|
| 411 |
+
if args.norm_adv:
|
| 412 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 413 |
+
|
| 414 |
+
# Policy loss
|
| 415 |
+
pg_loss1 = -mb_advantages * ratio
|
| 416 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 417 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 418 |
+
|
| 419 |
+
# Value loss
|
| 420 |
+
newvalue = newvalue.view(-1)
|
| 421 |
+
if args.clip_vloss:
|
| 422 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 423 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 424 |
+
newvalue - b_values[mb_inds],
|
| 425 |
+
-args.clip_coef,
|
| 426 |
+
args.clip_coef,
|
| 427 |
+
)
|
| 428 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 429 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 430 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 431 |
+
else:
|
| 432 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 433 |
+
|
| 434 |
+
entropy_loss = entropy.mean()
|
| 435 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 436 |
+
|
| 437 |
+
optimizer.zero_grad()
|
| 438 |
+
loss.backward()
|
| 439 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 440 |
+
optimizer.step()
|
| 441 |
+
|
| 442 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 443 |
+
break
|
| 444 |
+
|
| 445 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 446 |
+
var_y = np.var(y_true)
|
| 447 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 448 |
+
|
| 449 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 450 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 451 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 452 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 453 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 454 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 455 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 456 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 457 |
+
writer.add_scalar("losses/explained_variance", explained_var, global_step)
|
| 458 |
+
|
| 459 |
+
# Additional useful metrics
|
| 460 |
+
writer.add_scalar("charts/avg_reward", rewards.mean().item(), global_step)
|
| 461 |
+
writer.add_scalar("charts/avg_value", values.mean().item(), global_step)
|
| 462 |
+
writer.add_scalar("charts/max_reward", rewards.max().item(), global_step)
|
| 463 |
+
writer.add_scalar("charts/min_reward", rewards.min().item(), global_step)
|
| 464 |
+
|
| 465 |
+
# Console output with key metrics
|
| 466 |
+
sps = int(global_step / (time.time() - start_time))
|
| 467 |
+
progress = 100 * iteration / args.num_iterations
|
| 468 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 469 |
+
f"SPS: {sps:5d} | "
|
| 470 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 471 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 472 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 473 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 474 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 475 |
+
writer.add_scalar("charts/SPS", sps, global_step)
|
| 476 |
+
# Mirror key metrics to W&B explicitly (in addition to TB sync)
|
| 477 |
+
if args.track:
|
| 478 |
+
try:
|
| 479 |
+
import wandb
|
| 480 |
+
wandb.log({
|
| 481 |
+
"global_step": int(global_step),
|
| 482 |
+
"train/value_loss": float(v_loss.item()),
|
| 483 |
+
"train/policy_loss": float(pg_loss.item()),
|
| 484 |
+
"train/entropy": float(entropy_loss.item()),
|
| 485 |
+
"train/old_approx_kl": float(old_approx_kl.item()),
|
| 486 |
+
"train/approx_kl": float(approx_kl.item()),
|
| 487 |
+
"train/clipfrac": float(np.mean(clipfracs)),
|
| 488 |
+
"losses/explained_variance": float(explained_var),
|
| 489 |
+
"charts/avg_reward": float(rewards.mean().item()),
|
| 490 |
+
"charts/avg_value": float(values.mean().item()),
|
| 491 |
+
"perf/SPS": int(sps),
|
| 492 |
+
"train/learning_rate": float(optimizer.param_groups[0]["lr"]),
|
| 493 |
+
}, step=global_step)
|
| 494 |
+
except Exception:
|
| 495 |
+
pass
|
| 496 |
+
# periodic evaluation collection
|
| 497 |
+
if iteration % eval_every_iters == 0:
|
| 498 |
+
try:
|
| 499 |
+
eval_thunk = make_env(args.env_id, 0, False, run_name, args.seed + 9999, args.grid_size, args.is_slippery)
|
| 500 |
+
# collect trajectories and write metrics.json
|
| 501 |
+
collect_eval_trajectories(agent, eval_thunk, args.eval_episodes, step_tag=global_step)
|
| 502 |
+
# also log summary metrics to W&B
|
| 503 |
+
if args.track:
|
| 504 |
+
try:
|
| 505 |
+
import json as _json
|
| 506 |
+
from pathlib import Path as _Path
|
| 507 |
+
mpath = _Path(f"runs/{run_name}/trajectories/step_{global_step}/metrics.json")
|
| 508 |
+
if mpath.exists():
|
| 509 |
+
with mpath.open("r") as mf:
|
| 510 |
+
metrics = _json.load(mf)
|
| 511 |
+
import wandb
|
| 512 |
+
wandb.log({
|
| 513 |
+
"eval/success_rate": metrics.get("success_rate"),
|
| 514 |
+
"eval/avg_return": metrics.get("avg_return"),
|
| 515 |
+
"eval/std_return": metrics.get("std_return"),
|
| 516 |
+
"eval/episodes": metrics.get("episodes"),
|
| 517 |
+
}, step=global_step)
|
| 518 |
+
except Exception:
|
| 519 |
+
pass
|
| 520 |
+
print(f"Collected {args.eval_episodes} eval trajectories at global_step {global_step}")
|
| 521 |
+
except Exception as e:
|
| 522 |
+
print(f"Warning: eval trajectory collection failed at step {global_step}: {e}")
|
| 523 |
+
|
| 524 |
+
envs.close()
|
| 525 |
+
writer.close()
|
| 526 |
+
# Persist episodic log and optional plot for visible trend
|
| 527 |
+
try:
|
| 528 |
+
import csv
|
| 529 |
+
from pathlib import Path
|
| 530 |
+
out_dir = Path(f"runs/{run_name}")
|
| 531 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 532 |
+
csv_path = out_dir / "episodic_log.csv"
|
| 533 |
+
with csv_path.open("w", newline="") as f:
|
| 534 |
+
writer_csv = csv.writer(f)
|
| 535 |
+
writer_csv.writerow(["global_step", "episode_return"])
|
| 536 |
+
for s, r in zip(episode_steps, episode_returns):
|
| 537 |
+
writer_csv.writerow([int(s), float(r)])
|
| 538 |
+
print(f"Saved episodic CSV to {csv_path}")
|
| 539 |
+
except Exception as e:
|
| 540 |
+
print(f"Warning: failed to save episodic CSV: {e}")
|
| 541 |
+
|
| 542 |
+
if args.save_plots and len(episode_returns) > 0:
|
| 543 |
+
try:
|
| 544 |
+
import matplotlib.pyplot as plt
|
| 545 |
+
import numpy as np
|
| 546 |
+
def moving_avg(x, w=50):
|
| 547 |
+
if len(x) == 0:
|
| 548 |
+
return np.array([])
|
| 549 |
+
w = max(1, min(w, len(x)))
|
| 550 |
+
c = np.cumsum(np.insert(x, 0, 0))
|
| 551 |
+
return (c[w:] - c[:-w]) / float(w)
|
| 552 |
+
fig, ax = plt.subplots(1, 1, figsize=(8, 4))
|
| 553 |
+
ax.plot(episode_steps, episode_returns, alpha=0.3, label="return")
|
| 554 |
+
ma = moving_avg(episode_returns, w=50)
|
| 555 |
+
if len(ma) > 0:
|
| 556 |
+
ax.plot(episode_steps[49:], ma, label="MA@50")
|
| 557 |
+
ax.set_title("FrozenLake: Episodic Return")
|
| 558 |
+
ax.set_xlabel("global_step")
|
| 559 |
+
ax.set_ylabel("return")
|
| 560 |
+
ax.legend()
|
| 561 |
+
png_path = f"runs/{run_name}/training_curve.png"
|
| 562 |
+
fig.tight_layout()
|
| 563 |
+
plt.savefig(png_path)
|
| 564 |
+
plt.close(fig)
|
| 565 |
+
print(f"Saved training curve to {png_path}")
|
| 566 |
+
except Exception as e:
|
| 567 |
+
print(f"Warning: failed to save training plot: {e}")
|
cleanrl/cleanrl/ppo_frozenlake_nochangeenv.py
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO with small MLP for RAGEN FrozenLake using the existing env (no env edits)
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Tuple, Dict, Any
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
import gymnasium as gym
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
from torch.distributions.categorical import Categorical
|
| 17 |
+
|
| 18 |
+
import sys
|
| 19 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 20 |
+
|
| 21 |
+
from ragen.env.frozen_lake.env import FrozenLakeEnv
|
| 22 |
+
from ragen.env.frozen_lake.config import FrozenLakeEnvConfig
|
| 23 |
+
|
| 24 |
+
# python /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_frozenlake_nochangeenv.py --total-timesteps 2000000 --num-envs 8 --num-steps 128 --grid-size 4 --is-slippery --track
|
| 25 |
+
class FrozenLakeWrapper(gym.Env):
|
| 26 |
+
"""
|
| 27 |
+
Adapter to use ragen FrozenLakeEnv with Gymnasium vector API.
|
| 28 |
+
- Converts text observation to one-hot grid vector (6 tokens per cell).
|
| 29 |
+
- Maps agent actions [0..3] to env actions [1..4].
|
| 30 |
+
- Exposes proper observation_space and action_space.
|
| 31 |
+
"""
|
| 32 |
+
metadata = {"render_modes": ["rgb_array", "human", "ansi"]}
|
| 33 |
+
|
| 34 |
+
def __init__(self, env: FrozenLakeEnv):
|
| 35 |
+
super().__init__()
|
| 36 |
+
self._env = env
|
| 37 |
+
self._size = int(self._env.nrow) # square grid
|
| 38 |
+
self._tokens = ['P', '_', 'O', 'G', 'X', '√']
|
| 39 |
+
self._token_to_idx = {t: i for i, t in enumerate(self._tokens)}
|
| 40 |
+
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(self._size * self._size * len(self._tokens),), dtype=np.float32)
|
| 41 |
+
self.action_space = gym.spaces.Discrete(4)
|
| 42 |
+
|
| 43 |
+
def _encode_obs(self, text_obs: str) -> np.ndarray:
|
| 44 |
+
# text_obs is multi-line grid with tokens above
|
| 45 |
+
rows = text_obs.split('\n')
|
| 46 |
+
# handle any accidental extra whitespace
|
| 47 |
+
rows = [list(r) for r in rows if len(r) > 0]
|
| 48 |
+
h = len(rows)
|
| 49 |
+
w = len(rows[0]) if h > 0 else self._size
|
| 50 |
+
grid = np.zeros((h, w, len(self._tokens)), dtype=np.float32)
|
| 51 |
+
for i in range(h):
|
| 52 |
+
for j in range(w):
|
| 53 |
+
ch = rows[i][j]
|
| 54 |
+
idx = self._token_to_idx.get(ch, 0)
|
| 55 |
+
grid[i, j, idx] = 1.0
|
| 56 |
+
return grid.reshape(-1)
|
| 57 |
+
|
| 58 |
+
def reset(self, *, seed: int | None = None, options: Dict[str, Any] | None = None):
|
| 59 |
+
text_obs = self._env.reset(seed=seed)
|
| 60 |
+
obs = self._encode_obs(text_obs)
|
| 61 |
+
return obs, {}
|
| 62 |
+
|
| 63 |
+
def step(self, action: int):
|
| 64 |
+
# map 0..3 -> 1..4 for the underlying env
|
| 65 |
+
mapped = int(action) + 1
|
| 66 |
+
text_obs, reward, done, info = self._env.step(mapped)
|
| 67 |
+
obs = self._encode_obs(text_obs)
|
| 68 |
+
terminated = bool(done)
|
| 69 |
+
truncated = False
|
| 70 |
+
# propagate success if present
|
| 71 |
+
return obs, float(reward), terminated, truncated, info or {}
|
| 72 |
+
|
| 73 |
+
def render(self):
|
| 74 |
+
return self._env.render()
|
| 75 |
+
|
| 76 |
+
def close(self):
|
| 77 |
+
self._env.close()
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@dataclass
|
| 81 |
+
class Args:
|
| 82 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 83 |
+
seed: int = 1
|
| 84 |
+
torch_deterministic: bool = True
|
| 85 |
+
cuda: bool = True
|
| 86 |
+
track: bool = True
|
| 87 |
+
wandb_project_name: str = "cleanRL"
|
| 88 |
+
wandb_entity: str | None = None
|
| 89 |
+
capture_video: bool = False
|
| 90 |
+
|
| 91 |
+
# Algorithm
|
| 92 |
+
env_id: str = "FrozenLake"
|
| 93 |
+
total_timesteps: int = 200_000
|
| 94 |
+
learning_rate: float = 2.5e-4
|
| 95 |
+
num_envs: int = 8
|
| 96 |
+
num_steps: int = 128
|
| 97 |
+
anneal_lr: bool = True
|
| 98 |
+
gamma: float = 0.99
|
| 99 |
+
gae_lambda: float = 0.95
|
| 100 |
+
num_minibatches: int = 4
|
| 101 |
+
update_epochs: int = 4
|
| 102 |
+
norm_adv: bool = True
|
| 103 |
+
clip_coef: float = 0.2
|
| 104 |
+
clip_vloss: bool = True
|
| 105 |
+
ent_coef: float = 0.01
|
| 106 |
+
vf_coef: float = 0.5
|
| 107 |
+
max_grad_norm: float = 0.5
|
| 108 |
+
target_kl: float | None = None
|
| 109 |
+
|
| 110 |
+
# FrozenLake specific
|
| 111 |
+
grid_size: int = 4
|
| 112 |
+
is_slippery: bool = False
|
| 113 |
+
|
| 114 |
+
# runtime filled
|
| 115 |
+
batch_size: int = 0
|
| 116 |
+
minibatch_size: int = 0
|
| 117 |
+
num_iterations: int = 0
|
| 118 |
+
# eval config to mirror reference script
|
| 119 |
+
eval_splits: int = 20
|
| 120 |
+
eval_episodes: int = 4000
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def make_env(idx, run_name, seed, grid_size, is_slippery, capture_video=False):
|
| 124 |
+
def thunk():
|
| 125 |
+
config = FrozenLakeEnvConfig(size=grid_size, p=0.8, success_rate = 0.8, is_slippery=is_slippery, map_seed=seed + idx, render_mode='text')
|
| 126 |
+
# import pdb;pdb.set_trace()
|
| 127 |
+
env = FrozenLakeEnv(config)
|
| 128 |
+
env = FrozenLakeWrapper(env)
|
| 129 |
+
max_steps = int(grid_size * grid_size * 4)
|
| 130 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=max_steps)
|
| 131 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 132 |
+
if capture_video and idx == 0:
|
| 133 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 134 |
+
return env
|
| 135 |
+
return thunk
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 139 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 140 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 141 |
+
return layer
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
class Agent(nn.Module):
|
| 145 |
+
def __init__(self, envs):
|
| 146 |
+
super().__init__()
|
| 147 |
+
obs_shape = int(np.array(envs.single_observation_space.shape).prod())
|
| 148 |
+
hidden = 64
|
| 149 |
+
self.critic = nn.Sequential(
|
| 150 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 151 |
+
nn.Tanh(),
|
| 152 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 153 |
+
nn.Tanh(),
|
| 154 |
+
layer_init(nn.Linear(hidden, 1), std=1.0),
|
| 155 |
+
)
|
| 156 |
+
self.actor = nn.Sequential(
|
| 157 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 158 |
+
nn.Tanh(),
|
| 159 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 160 |
+
nn.Tanh(),
|
| 161 |
+
layer_init(nn.Linear(hidden, envs.single_action_space.n), std=0.01),
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
def get_value(self, x):
|
| 165 |
+
return self.critic(x)
|
| 166 |
+
|
| 167 |
+
def get_action_and_value(self, x, action=None):
|
| 168 |
+
logits = self.actor(x)
|
| 169 |
+
probs = Categorical(logits=logits)
|
| 170 |
+
if action is None:
|
| 171 |
+
action = probs.sample()
|
| 172 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
args = tyro.cli(Args)
|
| 177 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 178 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 179 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 180 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 181 |
+
|
| 182 |
+
if args.track:
|
| 183 |
+
import wandb
|
| 184 |
+
wandb.init(
|
| 185 |
+
project=args.wandb_project_name,
|
| 186 |
+
entity=args.wandb_entity,
|
| 187 |
+
config=vars(args),
|
| 188 |
+
name=run_name,
|
| 189 |
+
monitor_gym=True,
|
| 190 |
+
save_code=True,
|
| 191 |
+
)
|
| 192 |
+
try:
|
| 193 |
+
wandb.define_metric("global_step")
|
| 194 |
+
for prefix in ["train/*", "rollout/*", "eval/*", "losses/*", "charts/*", "perf/*"]:
|
| 195 |
+
wandb.define_metric(prefix, step_metric="global_step")
|
| 196 |
+
except Exception:
|
| 197 |
+
pass
|
| 198 |
+
|
| 199 |
+
# seeding
|
| 200 |
+
random.seed(args.seed)
|
| 201 |
+
np.random.seed(args.seed)
|
| 202 |
+
torch.manual_seed(args.seed)
|
| 203 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 204 |
+
|
| 205 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 206 |
+
|
| 207 |
+
# envs
|
| 208 |
+
envs = gym.vector.SyncVectorEnv([
|
| 209 |
+
make_env(i, run_name, args.seed, args.grid_size, args.is_slippery, args.capture_video)
|
| 210 |
+
for i in range(args.num_envs)
|
| 211 |
+
])
|
| 212 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete)
|
| 213 |
+
|
| 214 |
+
agent = Agent(envs).to(device)
|
| 215 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 216 |
+
|
| 217 |
+
# storage
|
| 218 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 219 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 220 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 221 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 222 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 223 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 224 |
+
|
| 225 |
+
# start
|
| 226 |
+
global_step = 0
|
| 227 |
+
start_time = time.time()
|
| 228 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 229 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 230 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 231 |
+
|
| 232 |
+
episode_returns = []
|
| 233 |
+
episode_steps = []
|
| 234 |
+
episode_successes = []
|
| 235 |
+
|
| 236 |
+
# Eval helper identical to reference
|
| 237 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes, step_tag):
|
| 238 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 239 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 240 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 241 |
+
env = make_env_fn()
|
| 242 |
+
collected = 0
|
| 243 |
+
summary_returns = []
|
| 244 |
+
summary_success = []
|
| 245 |
+
with out_path.open("w") as f:
|
| 246 |
+
while collected < n_episodes:
|
| 247 |
+
state, _ = env.reset(seed=args.seed + 100000 + collected)
|
| 248 |
+
traj_states = [state.tolist()]
|
| 249 |
+
traj_actions = []
|
| 250 |
+
traj_rewards = []
|
| 251 |
+
traj_dones = []
|
| 252 |
+
traj_success = []
|
| 253 |
+
done = False
|
| 254 |
+
step_count = 0
|
| 255 |
+
max_eval_steps = getattr(env, '_max_episode_steps', None) or int(args.grid_size * args.grid_size * 4)
|
| 256 |
+
while not done:
|
| 257 |
+
with torch.no_grad():
|
| 258 |
+
logits = agent_model.actor(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 259 |
+
action = int(torch.argmax(logits, dim=1).item())
|
| 260 |
+
next_state, reward, terminated, truncated, info = env.step(action)
|
| 261 |
+
traj_actions.append(int(action))
|
| 262 |
+
traj_rewards.append(float(reward))
|
| 263 |
+
step_count += 1
|
| 264 |
+
d = bool(terminated) or bool(truncated) or (step_count >= max_eval_steps)
|
| 265 |
+
traj_dones.append(d)
|
| 266 |
+
traj_success.append(bool(info.get('success', False)))
|
| 267 |
+
state = next_state
|
| 268 |
+
traj_states.append(state.tolist())
|
| 269 |
+
done = d
|
| 270 |
+
ep_ret = float(sum(traj_rewards))
|
| 271 |
+
ep_succ = bool(any(traj_success))
|
| 272 |
+
record = {
|
| 273 |
+
"states": traj_states,
|
| 274 |
+
"actions": traj_actions,
|
| 275 |
+
"rewards": traj_rewards,
|
| 276 |
+
"dones": traj_dones,
|
| 277 |
+
"success": traj_success,
|
| 278 |
+
"episode_return": ep_ret,
|
| 279 |
+
"episode_success": ep_succ,
|
| 280 |
+
}
|
| 281 |
+
f.write(json.dumps(record) + "\n")
|
| 282 |
+
collected += 1
|
| 283 |
+
summary_returns.append(ep_ret)
|
| 284 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 285 |
+
env.close()
|
| 286 |
+
try:
|
| 287 |
+
metrics = {
|
| 288 |
+
"global_step": int(step_tag),
|
| 289 |
+
"episodes": int(n_episodes),
|
| 290 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 291 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 292 |
+
"std_return": float(np.std(summary_returns)) if len(summary_returns) else 0.0,
|
| 293 |
+
}
|
| 294 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 295 |
+
json.dump(metrics, mf)
|
| 296 |
+
except Exception as e:
|
| 297 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 298 |
+
|
| 299 |
+
eval_every_iters = max(1, args.num_iterations // args.eval_splits)
|
| 300 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 301 |
+
# Anneal LR
|
| 302 |
+
if args.anneal_lr:
|
| 303 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 304 |
+
lrnow = frac * args.learning_rate
|
| 305 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 306 |
+
|
| 307 |
+
for step in range(0, args.num_steps):
|
| 308 |
+
global_step += args.num_envs
|
| 309 |
+
obs[step] = next_obs
|
| 310 |
+
dones[step] = next_done
|
| 311 |
+
|
| 312 |
+
with torch.no_grad():
|
| 313 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 314 |
+
values[step] = value.flatten()
|
| 315 |
+
actions[step] = action
|
| 316 |
+
logprobs[step] = logprob
|
| 317 |
+
|
| 318 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 319 |
+
next_done = np.logical_or(terminations, truncations)
|
| 320 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 321 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 322 |
+
# Episode stats logging as in reference
|
| 323 |
+
try:
|
| 324 |
+
mask = None
|
| 325 |
+
if isinstance(infos, dict):
|
| 326 |
+
if "_episode" in infos:
|
| 327 |
+
mask = np.asarray(infos["_episode"]).astype(bool)
|
| 328 |
+
elif "episode" in infos and isinstance(infos["episode"], dict) and "_l" in infos["episode"]:
|
| 329 |
+
mask = np.asarray(infos["episode"]["_l"]).astype(bool)
|
| 330 |
+
if mask is not None and np.any(mask):
|
| 331 |
+
r_arr = np.asarray(infos.get("episode", {}).get("r", np.zeros_like(mask, dtype=float)))
|
| 332 |
+
l_arr = np.asarray(infos.get("episode", {}).get("l", np.zeros_like(mask, dtype=int)))
|
| 333 |
+
succ_arr = np.asarray(infos.get("success", np.zeros_like(mask, dtype=bool))).astype(float)
|
| 334 |
+
for i in np.where(mask)[0]:
|
| 335 |
+
ep_r = float(r_arr[i])
|
| 336 |
+
ep_l = int(l_arr[i])
|
| 337 |
+
ep_succ = float(succ_arr[i])
|
| 338 |
+
episode_returns.append(ep_r)
|
| 339 |
+
episode_steps.append(global_step)
|
| 340 |
+
episode_successes.append(ep_succ)
|
| 341 |
+
if args.track:
|
| 342 |
+
try:
|
| 343 |
+
import wandb
|
| 344 |
+
log_dict = {
|
| 345 |
+
"global_step": int(global_step),
|
| 346 |
+
"rollout/ep_rew_mean": float(np.mean(r_arr[mask])) if np.any(mask) else None,
|
| 347 |
+
"rollout/ep_len_mean": float(np.mean(l_arr[mask])) if np.any(mask) else None,
|
| 348 |
+
"rollout/success_rate": float(np.mean(succ_arr[mask])) if np.any(mask) else None,
|
| 349 |
+
}
|
| 350 |
+
if np.any(mask):
|
| 351 |
+
last_idx = np.where(mask)[0][-1]
|
| 352 |
+
log_dict.update({
|
| 353 |
+
"train/episodic_return": float(r_arr[last_idx]),
|
| 354 |
+
"train/episodic_length": int(l_arr[last_idx]),
|
| 355 |
+
"train/success": float(succ_arr[last_idx]),
|
| 356 |
+
"train/success_rate_100": float(np.mean(episode_successes[-100:])) if len(episode_successes) >= 100 else None,
|
| 357 |
+
})
|
| 358 |
+
wandb.log(log_dict, step=global_step)
|
| 359 |
+
except Exception:
|
| 360 |
+
pass
|
| 361 |
+
except Exception:
|
| 362 |
+
pass
|
| 363 |
+
|
| 364 |
+
# GAE
|
| 365 |
+
with torch.no_grad():
|
| 366 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 367 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 368 |
+
lastgaelam = 0
|
| 369 |
+
for t in reversed(range(args.num_steps)):
|
| 370 |
+
if t == args.num_steps - 1:
|
| 371 |
+
nextnonterminal = 1.0 - next_done
|
| 372 |
+
nextvalues = next_value
|
| 373 |
+
else:
|
| 374 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 375 |
+
nextvalues = values[t + 1]
|
| 376 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 377 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 378 |
+
returns = advantages + values
|
| 379 |
+
|
| 380 |
+
# flatten batch
|
| 381 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 382 |
+
b_logprobs = logprobs.reshape(-1)
|
| 383 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 384 |
+
b_advantages = advantages.reshape(-1)
|
| 385 |
+
b_returns = returns.reshape(-1)
|
| 386 |
+
b_values = values.reshape(-1)
|
| 387 |
+
|
| 388 |
+
# update
|
| 389 |
+
b_inds = np.arange(args.batch_size)
|
| 390 |
+
clipfracs = []
|
| 391 |
+
for epoch in range(args.update_epochs):
|
| 392 |
+
np.random.shuffle(b_inds)
|
| 393 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 394 |
+
end = start + args.minibatch_size
|
| 395 |
+
mb_inds = b_inds[start:end]
|
| 396 |
+
|
| 397 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 398 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 399 |
+
ratio = logratio.exp()
|
| 400 |
+
|
| 401 |
+
with torch.no_grad():
|
| 402 |
+
old_approx_kl = (-logratio).mean()
|
| 403 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 404 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 405 |
+
|
| 406 |
+
mb_advantages = b_advantages[mb_inds]
|
| 407 |
+
if args.norm_adv:
|
| 408 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 409 |
+
|
| 410 |
+
pg_loss1 = -mb_advantages * ratio
|
| 411 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 412 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 413 |
+
|
| 414 |
+
newvalue = newvalue.view(-1)
|
| 415 |
+
if args.clip_vloss:
|
| 416 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 417 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 418 |
+
newvalue - b_values[mb_inds], -args.clip_coef, args.clip_coef,
|
| 419 |
+
)
|
| 420 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 421 |
+
v_loss = 0.5 * torch.max(v_loss_unclipped, v_loss_clipped).mean()
|
| 422 |
+
else:
|
| 423 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 424 |
+
|
| 425 |
+
entropy_loss = entropy.mean()
|
| 426 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 427 |
+
|
| 428 |
+
optimizer.zero_grad()
|
| 429 |
+
loss.backward()
|
| 430 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 431 |
+
optimizer.step()
|
| 432 |
+
|
| 433 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 434 |
+
break
|
| 435 |
+
|
| 436 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 437 |
+
var_y = np.var(y_true)
|
| 438 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 439 |
+
|
| 440 |
+
sps = int(global_step / (time.time() - start_time))
|
| 441 |
+
progress = 100 * iteration / args.num_iterations
|
| 442 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 443 |
+
f"SPS: {sps:5d} | "
|
| 444 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 445 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 446 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 447 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 448 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 449 |
+
if args.track:
|
| 450 |
+
try:
|
| 451 |
+
import wandb
|
| 452 |
+
wandb.log({
|
| 453 |
+
"global_step": int(global_step),
|
| 454 |
+
"train/value_loss": float(v_loss.item()),
|
| 455 |
+
"train/policy_loss": float(pg_loss.item()),
|
| 456 |
+
"train/entropy": float(entropy_loss.item()),
|
| 457 |
+
"train/old_approx_kl": float(old_approx_kl.item()),
|
| 458 |
+
"train/approx_kl": float(approx_kl.item()),
|
| 459 |
+
"train/clipfrac": float(np.mean(clipfracs)),
|
| 460 |
+
"losses/explained_variance": float(explained_var),
|
| 461 |
+
"charts/avg_reward": float(rewards.mean().item()),
|
| 462 |
+
"charts/avg_value": float(values.mean().item()),
|
| 463 |
+
"perf/SPS": int(sps),
|
| 464 |
+
"train/learning_rate": float(optimizer.param_groups[0]["lr"]),
|
| 465 |
+
}, step=global_step)
|
| 466 |
+
except Exception:
|
| 467 |
+
pass
|
| 468 |
+
|
| 469 |
+
# periodic evaluation collection
|
| 470 |
+
if iteration==1 or iteration % eval_every_iters == 0:
|
| 471 |
+
try:
|
| 472 |
+
eval_thunk = make_env(0, run_name, args.seed + 9999, args.grid_size, args.is_slippery, False)
|
| 473 |
+
collect_eval_trajectories(agent, eval_thunk, n_episodes=args.eval_episodes, step_tag=global_step)
|
| 474 |
+
if args.track:
|
| 475 |
+
try:
|
| 476 |
+
import json as _json
|
| 477 |
+
from pathlib import Path as _Path
|
| 478 |
+
mpath = _Path(f"runs/{run_name}/trajectories/step_{global_step}/metrics.json")
|
| 479 |
+
if mpath.exists():
|
| 480 |
+
with mpath.open("r") as mf:
|
| 481 |
+
metrics = _json.load(mf)
|
| 482 |
+
wandb.log({
|
| 483 |
+
"eval/success_rate": metrics.get("success_rate"),
|
| 484 |
+
"eval/avg_return": metrics.get("avg_return"),
|
| 485 |
+
"eval/std_return": metrics.get("std_return"),
|
| 486 |
+
"eval/episodes": metrics.get("episodes"),
|
| 487 |
+
}, step=global_step)
|
| 488 |
+
except Exception:
|
| 489 |
+
pass
|
| 490 |
+
print(f"Collected {args.eval_episodes} eval trajectories at global_step {global_step}")
|
| 491 |
+
except Exception as e:
|
| 492 |
+
print(f"Warning: eval trajectory collection failed at step {global_step}: {e}")
|
| 493 |
+
|
| 494 |
+
envs.close()
|
cleanrl/cleanrl/ppo_pettingzoo_ma_atari.py
ADDED
|
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/ppo/#ppo_pettingzoo_ma_ataripy
|
| 2 |
+
import argparse
|
| 3 |
+
import importlib
|
| 4 |
+
import os
|
| 5 |
+
import random
|
| 6 |
+
import time
|
| 7 |
+
from distutils.util import strtobool
|
| 8 |
+
|
| 9 |
+
import gym
|
| 10 |
+
import numpy as np
|
| 11 |
+
import supersuit as ss
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
from torch.distributions.categorical import Categorical
|
| 16 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def parse_args():
|
| 20 |
+
# fmt: off
|
| 21 |
+
parser = argparse.ArgumentParser()
|
| 22 |
+
parser.add_argument("--exp-name", type=str, default=os.path.basename(__file__).rstrip(".py"),
|
| 23 |
+
help="the name of this experiment")
|
| 24 |
+
parser.add_argument("--seed", type=int, default=1,
|
| 25 |
+
help="seed of the experiment")
|
| 26 |
+
parser.add_argument("--torch-deterministic", type=lambda x: bool(strtobool(x)), default=True, nargs="?", const=True,
|
| 27 |
+
help="if toggled, `torch.backends.cudnn.deterministic=False`")
|
| 28 |
+
parser.add_argument("--cuda", type=lambda x: bool(strtobool(x)), default=True, nargs="?", const=True,
|
| 29 |
+
help="if toggled, cuda will be enabled by default")
|
| 30 |
+
parser.add_argument("--track", type=lambda x: bool(strtobool(x)), default=False, nargs="?", const=True,
|
| 31 |
+
help="if toggled, this experiment will be tracked with Weights and Biases")
|
| 32 |
+
parser.add_argument("--wandb-project-name", type=str, default="cleanRL",
|
| 33 |
+
help="the wandb's project name")
|
| 34 |
+
parser.add_argument("--wandb-entity", type=str, default=None,
|
| 35 |
+
help="the entity (team) of wandb's project")
|
| 36 |
+
parser.add_argument("--capture_video", type=lambda x: bool(strtobool(x)), default=False, nargs="?", const=True,
|
| 37 |
+
help="whether to capture videos of the agent performances (check out `videos` folder)")
|
| 38 |
+
|
| 39 |
+
# Algorithm specific arguments
|
| 40 |
+
parser.add_argument("--env-id", type=str, default="pong_v3",
|
| 41 |
+
help="the id of the environment")
|
| 42 |
+
parser.add_argument("--total-timesteps", type=int, default=20000000,
|
| 43 |
+
help="total timesteps of the experiments")
|
| 44 |
+
parser.add_argument("--learning-rate", type=float, default=2.5e-4,
|
| 45 |
+
help="the learning rate of the optimizer")
|
| 46 |
+
parser.add_argument("--num-envs", type=int, default=16,
|
| 47 |
+
help="the number of parallel game environments")
|
| 48 |
+
parser.add_argument("--num-steps", type=int, default=128,
|
| 49 |
+
help="the number of steps to run in each environment per policy rollout")
|
| 50 |
+
parser.add_argument("--anneal-lr", type=lambda x: bool(strtobool(x)), default=True, nargs="?", const=True,
|
| 51 |
+
help="Toggle learning rate annealing for policy and value networks")
|
| 52 |
+
parser.add_argument("--gamma", type=float, default=0.99,
|
| 53 |
+
help="the discount factor gamma")
|
| 54 |
+
parser.add_argument("--gae-lambda", type=float, default=0.95,
|
| 55 |
+
help="the lambda for the general advantage estimation")
|
| 56 |
+
parser.add_argument("--num-minibatches", type=int, default=4,
|
| 57 |
+
help="the number of mini-batches")
|
| 58 |
+
parser.add_argument("--update-epochs", type=int, default=4,
|
| 59 |
+
help="the K epochs to update the policy")
|
| 60 |
+
parser.add_argument("--norm-adv", type=lambda x: bool(strtobool(x)), default=True, nargs="?", const=True,
|
| 61 |
+
help="Toggles advantages normalization")
|
| 62 |
+
parser.add_argument("--clip-coef", type=float, default=0.1,
|
| 63 |
+
help="the surrogate clipping coefficient")
|
| 64 |
+
parser.add_argument("--clip-vloss", type=lambda x: bool(strtobool(x)), default=True, nargs="?", const=True,
|
| 65 |
+
help="Toggles whether or not to use a clipped loss for the value function, as per the paper.")
|
| 66 |
+
parser.add_argument("--ent-coef", type=float, default=0.01,
|
| 67 |
+
help="coefficient of the entropy")
|
| 68 |
+
parser.add_argument("--vf-coef", type=float, default=0.5,
|
| 69 |
+
help="coefficient of the value function")
|
| 70 |
+
parser.add_argument("--max-grad-norm", type=float, default=0.5,
|
| 71 |
+
help="the maximum norm for the gradient clipping")
|
| 72 |
+
parser.add_argument("--target-kl", type=float, default=None,
|
| 73 |
+
help="the target KL divergence threshold")
|
| 74 |
+
args = parser.parse_args()
|
| 75 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 76 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 77 |
+
# fmt: on
|
| 78 |
+
return args
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 82 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 83 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 84 |
+
return layer
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
class Agent(nn.Module):
|
| 88 |
+
def __init__(self, envs):
|
| 89 |
+
super().__init__()
|
| 90 |
+
self.network = nn.Sequential(
|
| 91 |
+
layer_init(nn.Conv2d(6, 32, 8, stride=4)),
|
| 92 |
+
nn.ReLU(),
|
| 93 |
+
layer_init(nn.Conv2d(32, 64, 4, stride=2)),
|
| 94 |
+
nn.ReLU(),
|
| 95 |
+
layer_init(nn.Conv2d(64, 64, 3, stride=1)),
|
| 96 |
+
nn.ReLU(),
|
| 97 |
+
nn.Flatten(),
|
| 98 |
+
layer_init(nn.Linear(64 * 7 * 7, 512)),
|
| 99 |
+
nn.ReLU(),
|
| 100 |
+
)
|
| 101 |
+
self.actor = layer_init(nn.Linear(512, envs.single_action_space.n), std=0.01)
|
| 102 |
+
self.critic = layer_init(nn.Linear(512, 1), std=1)
|
| 103 |
+
|
| 104 |
+
def get_value(self, x):
|
| 105 |
+
x = x.clone()
|
| 106 |
+
x[:, :, :, [0, 1, 2, 3]] /= 255.0
|
| 107 |
+
return self.critic(self.network(x.permute((0, 3, 1, 2))))
|
| 108 |
+
|
| 109 |
+
def get_action_and_value(self, x, action=None):
|
| 110 |
+
x = x.clone()
|
| 111 |
+
x[:, :, :, [0, 1, 2, 3]] /= 255.0
|
| 112 |
+
hidden = self.network(x.permute((0, 3, 1, 2)))
|
| 113 |
+
logits = self.actor(hidden)
|
| 114 |
+
probs = Categorical(logits=logits)
|
| 115 |
+
if action is None:
|
| 116 |
+
action = probs.sample()
|
| 117 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(hidden)
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
if __name__ == "__main__":
|
| 121 |
+
args = parse_args()
|
| 122 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 123 |
+
if args.track:
|
| 124 |
+
import wandb
|
| 125 |
+
|
| 126 |
+
wandb.init(
|
| 127 |
+
project=args.wandb_project_name,
|
| 128 |
+
entity=args.wandb_entity,
|
| 129 |
+
sync_tensorboard=True,
|
| 130 |
+
config=vars(args),
|
| 131 |
+
name=run_name,
|
| 132 |
+
monitor_gym=True,
|
| 133 |
+
save_code=True,
|
| 134 |
+
)
|
| 135 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 136 |
+
writer.add_text(
|
| 137 |
+
"hyperparameters",
|
| 138 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# TRY NOT TO MODIFY: seeding
|
| 142 |
+
random.seed(args.seed)
|
| 143 |
+
np.random.seed(args.seed)
|
| 144 |
+
torch.manual_seed(args.seed)
|
| 145 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 146 |
+
|
| 147 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 148 |
+
|
| 149 |
+
# env setup
|
| 150 |
+
env = importlib.import_module(f"pettingzoo.atari.{args.env_id}").parallel_env()
|
| 151 |
+
env = ss.max_observation_v0(env, 2)
|
| 152 |
+
env = ss.frame_skip_v0(env, 4)
|
| 153 |
+
env = ss.clip_reward_v0(env, lower_bound=-1, upper_bound=1)
|
| 154 |
+
env = ss.color_reduction_v0(env, mode="B")
|
| 155 |
+
env = ss.resize_v1(env, x_size=84, y_size=84)
|
| 156 |
+
env = ss.frame_stack_v1(env, 4)
|
| 157 |
+
env = ss.agent_indicator_v0(env, type_only=False)
|
| 158 |
+
env = ss.pettingzoo_env_to_vec_env_v1(env)
|
| 159 |
+
envs = ss.concat_vec_envs_v1(env, args.num_envs // 2, num_cpus=0, base_class="gym")
|
| 160 |
+
envs.single_observation_space = envs.observation_space
|
| 161 |
+
envs.single_action_space = envs.action_space
|
| 162 |
+
envs.is_vector_env = True
|
| 163 |
+
envs = gym.wrappers.RecordEpisodeStatistics(envs)
|
| 164 |
+
if args.capture_video:
|
| 165 |
+
envs = gym.wrappers.RecordVideo(envs, f"videos/{run_name}")
|
| 166 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 167 |
+
|
| 168 |
+
agent = Agent(envs).to(device)
|
| 169 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 170 |
+
|
| 171 |
+
# ALGO Logic: Storage setup
|
| 172 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 173 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 174 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 175 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 176 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 177 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 178 |
+
|
| 179 |
+
# TRY NOT TO MODIFY: start the game
|
| 180 |
+
global_step = 0
|
| 181 |
+
start_time = time.time()
|
| 182 |
+
next_obs = torch.Tensor(envs.reset()).to(device)
|
| 183 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 184 |
+
num_updates = args.total_timesteps // args.batch_size
|
| 185 |
+
|
| 186 |
+
for update in range(1, num_updates + 1):
|
| 187 |
+
# Annealing the rate if instructed to do so.
|
| 188 |
+
if args.anneal_lr:
|
| 189 |
+
frac = 1.0 - (update - 1.0) / num_updates
|
| 190 |
+
lrnow = frac * args.learning_rate
|
| 191 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 192 |
+
|
| 193 |
+
for step in range(0, args.num_steps):
|
| 194 |
+
global_step += 1 * args.num_envs
|
| 195 |
+
obs[step] = next_obs
|
| 196 |
+
dones[step] = next_done
|
| 197 |
+
|
| 198 |
+
# ALGO LOGIC: action logic
|
| 199 |
+
with torch.no_grad():
|
| 200 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 201 |
+
values[step] = value.flatten()
|
| 202 |
+
actions[step] = action
|
| 203 |
+
logprobs[step] = logprob
|
| 204 |
+
|
| 205 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 206 |
+
next_obs, reward, done, info = envs.step(action.cpu().numpy())
|
| 207 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 208 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(done).to(device)
|
| 209 |
+
|
| 210 |
+
for idx, item in enumerate(info):
|
| 211 |
+
player_idx = idx % 2
|
| 212 |
+
if "episode" in item.keys():
|
| 213 |
+
print(f"global_step={global_step}, {player_idx}-episodic_return={item['episode']['r']}")
|
| 214 |
+
writer.add_scalar(f"charts/episodic_return-player{player_idx}", item["episode"]["r"], global_step)
|
| 215 |
+
writer.add_scalar(f"charts/episodic_length-player{player_idx}", item["episode"]["l"], global_step)
|
| 216 |
+
|
| 217 |
+
# bootstrap value if not done
|
| 218 |
+
with torch.no_grad():
|
| 219 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 220 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 221 |
+
lastgaelam = 0
|
| 222 |
+
for t in reversed(range(args.num_steps)):
|
| 223 |
+
if t == args.num_steps - 1:
|
| 224 |
+
nextnonterminal = 1.0 - next_done
|
| 225 |
+
nextvalues = next_value
|
| 226 |
+
else:
|
| 227 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 228 |
+
nextvalues = values[t + 1]
|
| 229 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 230 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 231 |
+
returns = advantages + values
|
| 232 |
+
|
| 233 |
+
# flatten the batch
|
| 234 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 235 |
+
b_logprobs = logprobs.reshape(-1)
|
| 236 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 237 |
+
b_advantages = advantages.reshape(-1)
|
| 238 |
+
b_returns = returns.reshape(-1)
|
| 239 |
+
b_values = values.reshape(-1)
|
| 240 |
+
|
| 241 |
+
# Optimizing the policy and value network
|
| 242 |
+
b_inds = np.arange(args.batch_size)
|
| 243 |
+
clipfracs = []
|
| 244 |
+
for epoch in range(args.update_epochs):
|
| 245 |
+
np.random.shuffle(b_inds)
|
| 246 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 247 |
+
end = start + args.minibatch_size
|
| 248 |
+
mb_inds = b_inds[start:end]
|
| 249 |
+
|
| 250 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 251 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 252 |
+
ratio = logratio.exp()
|
| 253 |
+
|
| 254 |
+
with torch.no_grad():
|
| 255 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 256 |
+
old_approx_kl = (-logratio).mean()
|
| 257 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 258 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 259 |
+
|
| 260 |
+
mb_advantages = b_advantages[mb_inds]
|
| 261 |
+
if args.norm_adv:
|
| 262 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 263 |
+
|
| 264 |
+
# Policy loss
|
| 265 |
+
pg_loss1 = -mb_advantages * ratio
|
| 266 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 267 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 268 |
+
|
| 269 |
+
# Value loss
|
| 270 |
+
newvalue = newvalue.view(-1)
|
| 271 |
+
if args.clip_vloss:
|
| 272 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 273 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 274 |
+
newvalue - b_values[mb_inds],
|
| 275 |
+
-args.clip_coef,
|
| 276 |
+
args.clip_coef,
|
| 277 |
+
)
|
| 278 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 279 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 280 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 281 |
+
else:
|
| 282 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 283 |
+
|
| 284 |
+
entropy_loss = entropy.mean()
|
| 285 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 286 |
+
|
| 287 |
+
optimizer.zero_grad()
|
| 288 |
+
loss.backward()
|
| 289 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 290 |
+
optimizer.step()
|
| 291 |
+
|
| 292 |
+
if args.target_kl is not None:
|
| 293 |
+
if approx_kl > args.target_kl:
|
| 294 |
+
break
|
| 295 |
+
|
| 296 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 297 |
+
var_y = np.var(y_true)
|
| 298 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 299 |
+
|
| 300 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 301 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 302 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 303 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 304 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 305 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 306 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 307 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 308 |
+
writer.add_scalar("losses/explained_variance", explained_var, global_step)
|
| 309 |
+
print("SPS:", int(global_step / (time.time() - start_time)))
|
| 310 |
+
writer.add_scalar("charts/SPS", int(global_step / (time.time() - start_time)), global_step)
|
| 311 |
+
|
| 312 |
+
envs.close()
|
| 313 |
+
writer.close()
|
cleanrl/cleanrl/ppo_sudoku.py
ADDED
|
@@ -0,0 +1,538 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO with small MLP for RAGEN Sudoku using the existing env (no env edits)
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Tuple, Dict, Any, List
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
import gymnasium as gym
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
from torch.distributions.categorical import Categorical
|
| 17 |
+
|
| 18 |
+
import sys
|
| 19 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 20 |
+
|
| 21 |
+
from ragen.env.sudoku.env import SudokuEnv
|
| 22 |
+
from ragen.env.sudoku.config import SudokuEnvConfig
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class SudokuWrapper(gym.Env):
|
| 26 |
+
"""
|
| 27 |
+
Adapter to use ragen SudokuEnv with Gymnasium vector API.
|
| 28 |
+
- Converts text observation (simple format) to one-hot grid vector ((GxG) * (G+1)).
|
| 29 |
+
- Maps discrete action id to action string "row,col,num" (1-indexed) for the env.
|
| 30 |
+
- Exposes proper observation_space and action_space.
|
| 31 |
+
"""
|
| 32 |
+
metadata = {"render_modes": ["rgb_array", "human", "ansi"]}
|
| 33 |
+
|
| 34 |
+
def __init__(self, env: SudokuEnv, grid_size: int):
|
| 35 |
+
super().__init__()
|
| 36 |
+
self._env = env
|
| 37 |
+
self._size = grid_size
|
| 38 |
+
# observation: one-hot per cell for value in {0..grid_size}, 0 denotes empty
|
| 39 |
+
self._val_dim = self._size + 1
|
| 40 |
+
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(self._size * self._size * self._val_dim,), dtype=np.float32)
|
| 41 |
+
# actions: (row, col, num) with row/col in [0..G-1], num in [1..G]
|
| 42 |
+
self._act_n = self._size * self._size * self._size
|
| 43 |
+
self.action_space = gym.spaces.Discrete(self._act_n)
|
| 44 |
+
|
| 45 |
+
def _encode_obs(self, text_obs: str) -> np.ndarray:
|
| 46 |
+
# Parse the 'simple' grid format; skip separator lines and '|' tokens
|
| 47 |
+
vals: List[int] = []
|
| 48 |
+
for line in text_obs.splitlines():
|
| 49 |
+
ls = line.strip()
|
| 50 |
+
if len(ls) == 0:
|
| 51 |
+
continue
|
| 52 |
+
# separator lines look like '-----' etc.
|
| 53 |
+
if set(ls) <= {'-'}:
|
| 54 |
+
continue
|
| 55 |
+
tokens = [t for t in ls.split() if t != '|']
|
| 56 |
+
# tolerate short lines (e.g., headers) by skipping
|
| 57 |
+
if len(tokens) == 0:
|
| 58 |
+
continue
|
| 59 |
+
for t in tokens:
|
| 60 |
+
if t == '.':
|
| 61 |
+
vals.append(0)
|
| 62 |
+
else:
|
| 63 |
+
# numeric token (handles multi-digit for 16x16)
|
| 64 |
+
try:
|
| 65 |
+
v = int(t)
|
| 66 |
+
except ValueError:
|
| 67 |
+
# unexpected token, treat as empty
|
| 68 |
+
v = 0
|
| 69 |
+
vals.append(v)
|
| 70 |
+
# Ensure we have exactly G*G cells; if more due to formatting, crop; if less, pad
|
| 71 |
+
target = self._size * self._size
|
| 72 |
+
if len(vals) < target:
|
| 73 |
+
vals.extend([0] * (target - len(vals)))
|
| 74 |
+
if len(vals) > target:
|
| 75 |
+
vals = vals[:target]
|
| 76 |
+
# One-hot encode
|
| 77 |
+
grid = np.zeros((target, self._val_dim), dtype=np.float32)
|
| 78 |
+
for i, v in enumerate(vals):
|
| 79 |
+
v_clamped = int(v)
|
| 80 |
+
if v_clamped < 0 or v_clamped > self._size:
|
| 81 |
+
v_clamped = 0
|
| 82 |
+
grid[i, v_clamped] = 1.0
|
| 83 |
+
return grid.reshape(-1)
|
| 84 |
+
|
| 85 |
+
@staticmethod
|
| 86 |
+
def _decode_action(action_id: int, grid_size: int) -> Tuple[int, int, int]:
|
| 87 |
+
# Map discrete id -> (row, col, num) with 0-index row/col, 1-index num
|
| 88 |
+
g = grid_size
|
| 89 |
+
row = action_id // (g * g)
|
| 90 |
+
rem = action_id % (g * g)
|
| 91 |
+
col = rem // g
|
| 92 |
+
num = (rem % g) + 1
|
| 93 |
+
return row, col, num
|
| 94 |
+
|
| 95 |
+
def reset(self, *, seed: int | None = None, options: Dict[str, Any] | None = None):
|
| 96 |
+
text_obs = self._env.reset(seed=seed)
|
| 97 |
+
obs = self._encode_obs(text_obs)
|
| 98 |
+
return obs, {}
|
| 99 |
+
|
| 100 |
+
def step(self, action: int):
|
| 101 |
+
row, col, num = self._decode_action(int(action), self._size)
|
| 102 |
+
# env expects 1-indexed row/col in action string
|
| 103 |
+
act_str = f"{row+1},{col+1},{num}"
|
| 104 |
+
text_obs, reward, done, info = self._env.step(act_str)
|
| 105 |
+
obs = self._encode_obs(text_obs)
|
| 106 |
+
terminated = bool(done)
|
| 107 |
+
truncated = False
|
| 108 |
+
return obs, float(reward), terminated, truncated, info or {}
|
| 109 |
+
|
| 110 |
+
def render(self):
|
| 111 |
+
return self._env.render()
|
| 112 |
+
|
| 113 |
+
def close(self):
|
| 114 |
+
self._env.close()
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
@dataclass
|
| 118 |
+
class Args:
|
| 119 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 120 |
+
seed: int = 1
|
| 121 |
+
torch_deterministic: bool = True
|
| 122 |
+
cuda: bool = True
|
| 123 |
+
track: bool = True
|
| 124 |
+
wandb_project_name: str = "cleanRL"
|
| 125 |
+
wandb_entity: str | None = None
|
| 126 |
+
capture_video: bool = False
|
| 127 |
+
|
| 128 |
+
# Algorithm
|
| 129 |
+
env_id: str = "Sudoku"
|
| 130 |
+
total_timesteps: int = 2000_000
|
| 131 |
+
learning_rate: float = 3e-4
|
| 132 |
+
num_envs: int = 8
|
| 133 |
+
num_steps: int = 128
|
| 134 |
+
anneal_lr: bool = True
|
| 135 |
+
gamma: float = 0.99
|
| 136 |
+
gae_lambda: float = 0.95
|
| 137 |
+
num_minibatches: int = 4
|
| 138 |
+
update_epochs: int = 4
|
| 139 |
+
norm_adv: bool = True
|
| 140 |
+
clip_coef: float = 0.2
|
| 141 |
+
clip_vloss: bool = True
|
| 142 |
+
ent_coef: float = 0.01
|
| 143 |
+
vf_coef: float = 0.5
|
| 144 |
+
max_grad_norm: float = 0.5
|
| 145 |
+
target_kl: float | None = None
|
| 146 |
+
|
| 147 |
+
# Sudoku specific
|
| 148 |
+
grid_size: int = 4 # 4 or 9 recommended
|
| 149 |
+
difficulty: str = "easy" # easy/medium/hard
|
| 150 |
+
|
| 151 |
+
# runtime filled
|
| 152 |
+
batch_size: int = 0
|
| 153 |
+
minibatch_size: int = 0
|
| 154 |
+
num_iterations: int = 0
|
| 155 |
+
|
| 156 |
+
# eval
|
| 157 |
+
eval_splits: int = 2
|
| 158 |
+
eval_episodes: int = 4000
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
def make_env(idx, run_name, seed, grid_size, difficulty, capture_video=False):
|
| 162 |
+
def thunk():
|
| 163 |
+
config = SudokuEnvConfig(
|
| 164 |
+
grid_size=grid_size,
|
| 165 |
+
difficulty=difficulty,
|
| 166 |
+
render_mode='text',
|
| 167 |
+
render_format='simple', # easier to parse; no env modification
|
| 168 |
+
)
|
| 169 |
+
env = SudokuEnv(config)
|
| 170 |
+
env = SudokuWrapper(env, grid_size)
|
| 171 |
+
# Use env's own max_steps default if available, otherwise a sane cap
|
| 172 |
+
max_steps = int(grid_size * grid_size * 6)
|
| 173 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=max_steps)
|
| 174 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 175 |
+
if capture_video and idx == 0:
|
| 176 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 177 |
+
return env
|
| 178 |
+
return thunk
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 182 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 183 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 184 |
+
return layer
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
class Agent(nn.Module):
|
| 188 |
+
def __init__(self, envs):
|
| 189 |
+
super().__init__()
|
| 190 |
+
obs_shape = int(np.array(envs.single_observation_space.shape).prod())
|
| 191 |
+
hidden = 128
|
| 192 |
+
self.critic = nn.Sequential(
|
| 193 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 194 |
+
nn.Tanh(),
|
| 195 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 196 |
+
nn.Tanh(),
|
| 197 |
+
layer_init(nn.Linear(hidden, 1), std=1.0),
|
| 198 |
+
)
|
| 199 |
+
self.actor = nn.Sequential(
|
| 200 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 201 |
+
nn.Tanh(),
|
| 202 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 203 |
+
nn.Tanh(),
|
| 204 |
+
layer_init(nn.Linear(hidden, envs.single_action_space.n), std=0.01),
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
def get_value(self, x):
|
| 208 |
+
return self.critic(x)
|
| 209 |
+
|
| 210 |
+
def get_action_and_value(self, x, action=None):
|
| 211 |
+
logits = self.actor(x)
|
| 212 |
+
probs = Categorical(logits=logits)
|
| 213 |
+
if action is None:
|
| 214 |
+
action = probs.sample()
|
| 215 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
if __name__ == "__main__":
|
| 219 |
+
args = tyro.cli(Args)
|
| 220 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 221 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 222 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 223 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 224 |
+
|
| 225 |
+
if args.track:
|
| 226 |
+
import wandb
|
| 227 |
+
wandb.init(
|
| 228 |
+
project=args.wandb_project_name,
|
| 229 |
+
entity=args.wandb_entity,
|
| 230 |
+
config=vars(args),
|
| 231 |
+
name=run_name,
|
| 232 |
+
monitor_gym=True,
|
| 233 |
+
save_code=True,
|
| 234 |
+
)
|
| 235 |
+
try:
|
| 236 |
+
wandb.define_metric("global_step")
|
| 237 |
+
for prefix in ["train/*", "rollout/*", "eval/*", "losses/*", "charts/*", "perf/*"]:
|
| 238 |
+
wandb.define_metric(prefix, step_metric="global_step")
|
| 239 |
+
except Exception:
|
| 240 |
+
pass
|
| 241 |
+
|
| 242 |
+
# seeding
|
| 243 |
+
random.seed(args.seed)
|
| 244 |
+
np.random.seed(args.seed)
|
| 245 |
+
torch.manual_seed(args.seed)
|
| 246 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 247 |
+
|
| 248 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 249 |
+
|
| 250 |
+
# envs
|
| 251 |
+
envs = gym.vector.SyncVectorEnv([
|
| 252 |
+
make_env(i, run_name, args.seed, args.grid_size, args.difficulty, args.capture_video)
|
| 253 |
+
for i in range(args.num_envs)
|
| 254 |
+
])
|
| 255 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete)
|
| 256 |
+
|
| 257 |
+
agent = Agent(envs).to(device)
|
| 258 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 259 |
+
|
| 260 |
+
# storage
|
| 261 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 262 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 263 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 264 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 265 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 266 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 267 |
+
|
| 268 |
+
# start
|
| 269 |
+
global_step = 0
|
| 270 |
+
start_time = time.time()
|
| 271 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 272 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 273 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 274 |
+
|
| 275 |
+
episode_returns = []
|
| 276 |
+
episode_steps = []
|
| 277 |
+
episode_successes = []
|
| 278 |
+
|
| 279 |
+
# Eval helper identical to FrozenLake script
|
| 280 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes, step_tag):
|
| 281 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 282 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 283 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 284 |
+
env = make_env_fn()
|
| 285 |
+
collected = 0
|
| 286 |
+
summary_returns = []
|
| 287 |
+
summary_success = []
|
| 288 |
+
with out_path.open("w") as f:
|
| 289 |
+
while collected < n_episodes:
|
| 290 |
+
state, _ = env.reset(seed=args.seed + collected)
|
| 291 |
+
traj_states = [state.tolist()]
|
| 292 |
+
traj_actions = []
|
| 293 |
+
traj_rewards = []
|
| 294 |
+
traj_dones = []
|
| 295 |
+
traj_success = []
|
| 296 |
+
done = False
|
| 297 |
+
step_count = 0
|
| 298 |
+
max_eval_steps = getattr(env, '_max_episode_steps', None) or int(args.grid_size * args.grid_size * 6)
|
| 299 |
+
while not done:
|
| 300 |
+
with torch.no_grad():
|
| 301 |
+
logits = agent_model.actor(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 302 |
+
# action = int(torch.argmax(logits, dim=1).item())
|
| 303 |
+
probs = Categorical(logits=logits)
|
| 304 |
+
action = int(probs.sample().item())
|
| 305 |
+
next_state, reward, terminated, truncated, info = env.step(action)
|
| 306 |
+
traj_actions.append(int(action))
|
| 307 |
+
traj_rewards.append(float(reward))
|
| 308 |
+
step_count += 1
|
| 309 |
+
d = bool(terminated) or bool(truncated) or (step_count >= max_eval_steps)
|
| 310 |
+
traj_dones.append(d)
|
| 311 |
+
traj_success.append(bool(info.get('success', False)))
|
| 312 |
+
state = next_state
|
| 313 |
+
traj_states.append(state.tolist())
|
| 314 |
+
done = d
|
| 315 |
+
ep_ret = float(sum(traj_rewards))
|
| 316 |
+
ep_succ = bool(any(traj_success))
|
| 317 |
+
record = {
|
| 318 |
+
"states": traj_states,
|
| 319 |
+
"actions": traj_actions,
|
| 320 |
+
"rewards": traj_rewards,
|
| 321 |
+
"dones": traj_dones,
|
| 322 |
+
"success": traj_success,
|
| 323 |
+
"episode_return": ep_ret,
|
| 324 |
+
"episode_success": ep_succ,
|
| 325 |
+
}
|
| 326 |
+
f.write(json.dumps(record) + "\n")
|
| 327 |
+
collected += 1
|
| 328 |
+
summary_returns.append(ep_ret)
|
| 329 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 330 |
+
env.close()
|
| 331 |
+
try:
|
| 332 |
+
metrics = {
|
| 333 |
+
"global_step": int(step_tag),
|
| 334 |
+
"episodes": int(n_episodes),
|
| 335 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 336 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 337 |
+
"std_return": float(np.std(summary_returns)) if len(summary_returns) else 0.0,
|
| 338 |
+
}
|
| 339 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 340 |
+
json.dump(metrics, mf)
|
| 341 |
+
except Exception as e:
|
| 342 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 343 |
+
|
| 344 |
+
eval_every_iters = max(1, args.num_iterations // args.eval_splits)
|
| 345 |
+
|
| 346 |
+
# training loop
|
| 347 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 348 |
+
# Anneal LR
|
| 349 |
+
if args.anneal_lr:
|
| 350 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 351 |
+
optimizer.param_groups[0]["lr"] = frac * args.learning_rate
|
| 352 |
+
|
| 353 |
+
for step in range(0, args.num_steps):
|
| 354 |
+
global_step += args.num_envs
|
| 355 |
+
obs[step] = next_obs
|
| 356 |
+
dones[step] = next_done
|
| 357 |
+
|
| 358 |
+
with torch.no_grad():
|
| 359 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 360 |
+
values[step] = value.flatten()
|
| 361 |
+
actions[step] = action
|
| 362 |
+
logprobs[step] = logprob
|
| 363 |
+
|
| 364 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 365 |
+
next_done = np.logical_or(terminations, truncations)
|
| 366 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 367 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 368 |
+
# Episode stats logging as in FrozenLake
|
| 369 |
+
try:
|
| 370 |
+
mask = None
|
| 371 |
+
if isinstance(infos, dict):
|
| 372 |
+
if "_episode" in infos:
|
| 373 |
+
mask = np.asarray(infos["_episode"]).astype(bool)
|
| 374 |
+
elif "episode" in infos and isinstance(infos["episode"], dict) and "_l" in infos["episode"]:
|
| 375 |
+
mask = np.asarray(infos["episode"]["_l"]).astype(bool)
|
| 376 |
+
if mask is not None and np.any(mask):
|
| 377 |
+
r_arr = np.asarray(infos.get("episode", {}).get("r", np.zeros_like(mask, dtype=float)))
|
| 378 |
+
l_arr = np.asarray(infos.get("episode", {}).get("l", np.zeros_like(mask, dtype=int)))
|
| 379 |
+
succ_arr = np.asarray(infos.get("success", np.zeros_like(mask, dtype=bool))).astype(float)
|
| 380 |
+
for i in np.where(mask)[0]:
|
| 381 |
+
ep_r = float(r_arr[i])
|
| 382 |
+
ep_l = int(l_arr[i])
|
| 383 |
+
ep_succ = float(succ_arr[i])
|
| 384 |
+
episode_returns.append(ep_r)
|
| 385 |
+
episode_steps.append(global_step)
|
| 386 |
+
episode_successes.append(ep_succ)
|
| 387 |
+
if args.track:
|
| 388 |
+
try:
|
| 389 |
+
import wandb
|
| 390 |
+
log_dict = {
|
| 391 |
+
"global_step": int(global_step),
|
| 392 |
+
"rollout/ep_rew_mean": float(np.mean(r_arr[mask])) if np.any(mask) else None,
|
| 393 |
+
"rollout/ep_len_mean": float(np.mean(l_arr[mask])) if np.any(mask) else None,
|
| 394 |
+
"rollout/success_rate": float(np.mean(succ_arr[mask])) if np.any(mask) else None,
|
| 395 |
+
}
|
| 396 |
+
if np.any(mask):
|
| 397 |
+
last_idx = np.where(mask)[0][-1]
|
| 398 |
+
log_dict.update({
|
| 399 |
+
"train/episodic_return": float(r_arr[last_idx]),
|
| 400 |
+
"train/episodic_length": int(l_arr[last_idx]),
|
| 401 |
+
"train/success": float(succ_arr[last_idx]),
|
| 402 |
+
"train/success_rate_100": float(np.mean(episode_successes[-100:])) if len(episode_successes) >= 100 else None,
|
| 403 |
+
})
|
| 404 |
+
wandb.log(log_dict, step=global_step)
|
| 405 |
+
except Exception:
|
| 406 |
+
pass
|
| 407 |
+
except Exception:
|
| 408 |
+
pass
|
| 409 |
+
|
| 410 |
+
# GAE
|
| 411 |
+
with torch.no_grad():
|
| 412 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 413 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 414 |
+
lastgaelam = 0
|
| 415 |
+
for t in reversed(range(args.num_steps)):
|
| 416 |
+
if t == args.num_steps - 1:
|
| 417 |
+
nextnonterminal = 1.0 - next_done
|
| 418 |
+
nextvalues = next_value
|
| 419 |
+
else:
|
| 420 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 421 |
+
nextvalues = values[t + 1]
|
| 422 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 423 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 424 |
+
returns = advantages + values
|
| 425 |
+
|
| 426 |
+
# flatten batch
|
| 427 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 428 |
+
b_logprobs = logprobs.reshape(-1)
|
| 429 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 430 |
+
b_advantages = advantages.reshape(-1)
|
| 431 |
+
b_returns = returns.reshape(-1)
|
| 432 |
+
b_values = values.reshape(-1)
|
| 433 |
+
|
| 434 |
+
# update
|
| 435 |
+
b_inds = np.arange(args.batch_size)
|
| 436 |
+
for epoch in range(args.update_epochs):
|
| 437 |
+
np.random.shuffle(b_inds)
|
| 438 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 439 |
+
end = start + args.minibatch_size
|
| 440 |
+
mb_inds = b_inds[start:end]
|
| 441 |
+
|
| 442 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 443 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 444 |
+
ratio = logratio.exp()
|
| 445 |
+
|
| 446 |
+
with torch.no_grad():
|
| 447 |
+
old_approx_kl = (-logratio).mean()
|
| 448 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 449 |
+
|
| 450 |
+
mb_advantages = b_advantages[mb_inds]
|
| 451 |
+
if args.norm_adv:
|
| 452 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 453 |
+
|
| 454 |
+
pg_loss1 = -mb_advantages * ratio
|
| 455 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 456 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 457 |
+
|
| 458 |
+
newvalue = newvalue.view(-1)
|
| 459 |
+
if args.clip_vloss:
|
| 460 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 461 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 462 |
+
newvalue - b_values[mb_inds], -args.clip_coef, args.clip_coef,
|
| 463 |
+
)
|
| 464 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 465 |
+
v_loss = 0.5 * torch.max(v_loss_unclipped, v_loss_clipped).mean()
|
| 466 |
+
else:
|
| 467 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 468 |
+
|
| 469 |
+
entropy_loss = entropy.mean()
|
| 470 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 471 |
+
|
| 472 |
+
optimizer.zero_grad()
|
| 473 |
+
loss.backward()
|
| 474 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 475 |
+
optimizer.step()
|
| 476 |
+
|
| 477 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 478 |
+
break
|
| 479 |
+
|
| 480 |
+
# logging
|
| 481 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 482 |
+
var_y = np.var(y_true)
|
| 483 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 484 |
+
|
| 485 |
+
sps = int(global_step / (time.time() - start_time))
|
| 486 |
+
progress = 100 * iteration / args.num_iterations
|
| 487 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 488 |
+
f"SPS: {sps:5d} | "
|
| 489 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 490 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 491 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 492 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 493 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 494 |
+
if args.track:
|
| 495 |
+
try:
|
| 496 |
+
import wandb
|
| 497 |
+
wandb.log({
|
| 498 |
+
"global_step": int(global_step),
|
| 499 |
+
"train/value_loss": float(v_loss.item()),
|
| 500 |
+
"train/policy_loss": float(pg_loss.item()),
|
| 501 |
+
"train/entropy": float(entropy_loss.item()),
|
| 502 |
+
"train/old_approx_kl": float(old_approx_kl.item()),
|
| 503 |
+
"train/approx_kl": float(approx_kl.item()),
|
| 504 |
+
"losses/explained_variance": float(explained_var),
|
| 505 |
+
"charts/avg_reward": float(rewards.mean().item()),
|
| 506 |
+
"charts/avg_value": float(values.mean().item()),
|
| 507 |
+
"perf/SPS": int(sps),
|
| 508 |
+
"train/learning_rate": float(optimizer.param_groups[0]["lr"]),
|
| 509 |
+
}, step=global_step)
|
| 510 |
+
except Exception:
|
| 511 |
+
pass
|
| 512 |
+
|
| 513 |
+
# periodic evaluation collection
|
| 514 |
+
if iteration % eval_every_iters == 0:
|
| 515 |
+
try:
|
| 516 |
+
eval_thunk = make_env(0, run_name, args.seed + 9999, args.grid_size, args.difficulty, False)
|
| 517 |
+
collect_eval_trajectories(agent, eval_thunk, n_episodes=args.eval_episodes, step_tag=global_step)
|
| 518 |
+
if args.track:
|
| 519 |
+
try:
|
| 520 |
+
import json as _json
|
| 521 |
+
from pathlib import Path as _Path
|
| 522 |
+
mpath = _Path(f"runs/{run_name}/trajectories/step_{global_step}/metrics.json")
|
| 523 |
+
if mpath.exists():
|
| 524 |
+
with mpath.open("r") as mf:
|
| 525 |
+
metrics = _json.load(mf)
|
| 526 |
+
wandb.log({
|
| 527 |
+
"eval/success_rate": metrics.get("success_rate"),
|
| 528 |
+
"eval/avg_return": metrics.get("avg_return"),
|
| 529 |
+
"eval/std_return": metrics.get("std_return"),
|
| 530 |
+
"eval/episodes": metrics.get("episodes"),
|
| 531 |
+
}, step=global_step)
|
| 532 |
+
except Exception:
|
| 533 |
+
pass
|
| 534 |
+
print(f"Collected {args.eval_episodes} eval trajectories at global_step {global_step}")
|
| 535 |
+
except Exception as e:
|
| 536 |
+
print(f"Warning: eval trajectory collection failed at step {global_step}: {e}")
|
| 537 |
+
|
| 538 |
+
envs.close()
|
cleanrl/cleanrl/ppo_trxl/enjoy.py
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from dataclasses import dataclass
|
| 2 |
+
|
| 3 |
+
import gymnasium as gym
|
| 4 |
+
import torch
|
| 5 |
+
import tyro
|
| 6 |
+
from ppo_trxl import Agent, make_env
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class Args:
|
| 11 |
+
hub: bool = False
|
| 12 |
+
"""whether to load the model from the huggingface hub or from the local disk"""
|
| 13 |
+
name: str = "Endless-MortarMayhem-v0_12.nn"
|
| 14 |
+
"""path to the model file"""
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
if __name__ == "__main__":
|
| 18 |
+
# Parse command line arguments and retrieve model path
|
| 19 |
+
cli_args = tyro.cli(Args)
|
| 20 |
+
if cli_args.hub:
|
| 21 |
+
try:
|
| 22 |
+
from huggingface_hub import hf_hub_download
|
| 23 |
+
|
| 24 |
+
path = hf_hub_download(repo_id="LilHairdy/cleanrl_memory_gym", filename=cli_args.name)
|
| 25 |
+
except:
|
| 26 |
+
raise RuntimeError(
|
| 27 |
+
"Cannot load model from the huggingface hub. Please install the huggingface_hub pypi package and verify the model name. You can also download the model from the hub manually and load it from disk."
|
| 28 |
+
)
|
| 29 |
+
else:
|
| 30 |
+
path = cli_args.name
|
| 31 |
+
|
| 32 |
+
# Load the pre-trained model and the original args used to train it
|
| 33 |
+
checkpoint = torch.load(path)
|
| 34 |
+
args = checkpoint["args"]
|
| 35 |
+
args = type("Args", (), args)
|
| 36 |
+
|
| 37 |
+
# Init environment and reset
|
| 38 |
+
env = make_env(args.env_id, 0, False, "", "human")()
|
| 39 |
+
obs, _ = env.reset()
|
| 40 |
+
env.render()
|
| 41 |
+
|
| 42 |
+
# Determine maximum episode steps
|
| 43 |
+
max_episode_steps = env.spec.max_episode_steps
|
| 44 |
+
if not max_episode_steps:
|
| 45 |
+
max_episode_steps = env.max_episode_steps
|
| 46 |
+
if max_episode_steps <= 0:
|
| 47 |
+
max_episode_steps = 1024 # Memory Gym envs have max_episode_steps set to -1
|
| 48 |
+
# May episode impacts positional encoding, so make sure to set this accordingly
|
| 49 |
+
|
| 50 |
+
# Setup agent and load its model parameters
|
| 51 |
+
action_space_shape = (
|
| 52 |
+
(env.action_space.n,) if isinstance(env.action_space, gym.spaces.Discrete) else tuple(env.action_space.nvec)
|
| 53 |
+
)
|
| 54 |
+
agent = Agent(args, env.observation_space, action_space_shape, max_episode_steps)
|
| 55 |
+
agent.load_state_dict(checkpoint["model_weights"])
|
| 56 |
+
|
| 57 |
+
# Setup Transformer-XL memory, mask and indices
|
| 58 |
+
memory = torch.zeros((1, max_episode_steps, args.trxl_num_layers, args.trxl_dim), dtype=torch.float32)
|
| 59 |
+
memory_mask = torch.tril(torch.ones((args.trxl_memory_length, args.trxl_memory_length)), diagonal=-1)
|
| 60 |
+
repetitions = torch.repeat_interleave(
|
| 61 |
+
torch.arange(0, args.trxl_memory_length).unsqueeze(0), args.trxl_memory_length - 1, dim=0
|
| 62 |
+
).long()
|
| 63 |
+
memory_indices = torch.stack(
|
| 64 |
+
[torch.arange(i, i + args.trxl_memory_length) for i in range(max_episode_steps - args.trxl_memory_length + 1)]
|
| 65 |
+
).long()
|
| 66 |
+
memory_indices = torch.cat((repetitions, memory_indices))
|
| 67 |
+
|
| 68 |
+
# Run episode
|
| 69 |
+
done = False
|
| 70 |
+
t = 0
|
| 71 |
+
while not done:
|
| 72 |
+
# Prepare observation and memory
|
| 73 |
+
obs = torch.Tensor(obs).unsqueeze(0)
|
| 74 |
+
memory_window = memory[0, memory_indices[t].unsqueeze(0)]
|
| 75 |
+
t_ = max(0, min(t, args.trxl_memory_length - 1))
|
| 76 |
+
mask = memory_mask[t_].unsqueeze(0)
|
| 77 |
+
indices = memory_indices[t].unsqueeze(0)
|
| 78 |
+
# Forward agent
|
| 79 |
+
action, _, _, _, new_memory = agent.get_action_and_value(obs, memory_window, mask, indices)
|
| 80 |
+
memory[:, t] = new_memory
|
| 81 |
+
# Step
|
| 82 |
+
obs, reward, termination, truncation, info = env.step(action.cpu().squeeze().numpy())
|
| 83 |
+
env.render()
|
| 84 |
+
done = termination or truncation
|
| 85 |
+
t += 1
|
| 86 |
+
|
| 87 |
+
if "r" in info["episode"].keys():
|
| 88 |
+
print(f"Episode return: {info['episode']['r'][0]}, Episode length: {info['episode']['l'][0]}")
|
| 89 |
+
else:
|
| 90 |
+
print(f"Episode return: {info['reward']}, Episode length: {info['length']}")
|
| 91 |
+
env.close()
|
cleanrl/cleanrl/ppo_trxl/uv.lock
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
cleanrl/cleanrl/pqn_atari_envpool.py
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/pqn/#pqn_atari_envpoolpy
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from collections import deque
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
|
| 8 |
+
import envpool
|
| 9 |
+
import gym
|
| 10 |
+
import numpy as np
|
| 11 |
+
import torch
|
| 12 |
+
import torch.nn as nn
|
| 13 |
+
import torch.nn.functional as F
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@dataclass
|
| 20 |
+
class Args:
|
| 21 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 22 |
+
"""the name of this experiment"""
|
| 23 |
+
seed: int = 1
|
| 24 |
+
"""seed of the experiment"""
|
| 25 |
+
torch_deterministic: bool = True
|
| 26 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 27 |
+
cuda: bool = True
|
| 28 |
+
"""if toggled, cuda will be enabled by default"""
|
| 29 |
+
track: bool = False
|
| 30 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 31 |
+
wandb_project_name: str = "cleanRL"
|
| 32 |
+
"""the wandb's project name"""
|
| 33 |
+
wandb_entity: str = None
|
| 34 |
+
"""the entity (team) of wandb's project"""
|
| 35 |
+
capture_video: bool = False
|
| 36 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 37 |
+
|
| 38 |
+
# Algorithm specific arguments
|
| 39 |
+
env_id: str = "Breakout-v5"
|
| 40 |
+
"""the id of the environment"""
|
| 41 |
+
total_timesteps: int = 10000000
|
| 42 |
+
"""total timesteps of the experiments"""
|
| 43 |
+
learning_rate: float = 2.5e-4
|
| 44 |
+
"""the learning rate of the optimizer"""
|
| 45 |
+
num_envs: int = 8
|
| 46 |
+
"""the number of parallel game environments"""
|
| 47 |
+
num_steps: int = 128
|
| 48 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 49 |
+
anneal_lr: bool = True
|
| 50 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 51 |
+
gamma: float = 0.99
|
| 52 |
+
"""the discount factor gamma"""
|
| 53 |
+
num_minibatches: int = 4
|
| 54 |
+
"""the number of mini-batches"""
|
| 55 |
+
update_epochs: int = 4
|
| 56 |
+
"""the K epochs to update the policy"""
|
| 57 |
+
max_grad_norm: float = 10.0
|
| 58 |
+
"""the maximum norm for the gradient clipping"""
|
| 59 |
+
start_e: float = 1
|
| 60 |
+
"""the starting epsilon for exploration"""
|
| 61 |
+
end_e: float = 0.01
|
| 62 |
+
"""the ending epsilon for exploration"""
|
| 63 |
+
exploration_fraction: float = 0.10
|
| 64 |
+
"""the fraction of `total_timesteps` it takes from start_e to end_e"""
|
| 65 |
+
q_lambda: float = 0.65
|
| 66 |
+
"""the lambda for the Q-Learning algorithm"""
|
| 67 |
+
|
| 68 |
+
# to be filled in runtime
|
| 69 |
+
batch_size: int = 0
|
| 70 |
+
"""the batch size (computed in runtime)"""
|
| 71 |
+
minibatch_size: int = 0
|
| 72 |
+
"""the mini-batch size (computed in runtime)"""
|
| 73 |
+
num_iterations: int = 0
|
| 74 |
+
"""the number of iterations (computed in runtime)"""
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
class RecordEpisodeStatistics(gym.Wrapper):
|
| 78 |
+
def __init__(self, env, deque_size=100):
|
| 79 |
+
super().__init__(env)
|
| 80 |
+
self.num_envs = getattr(env, "num_envs", 1)
|
| 81 |
+
self.episode_returns = None
|
| 82 |
+
self.episode_lengths = None
|
| 83 |
+
|
| 84 |
+
def reset(self, **kwargs):
|
| 85 |
+
observations = super().reset(**kwargs)
|
| 86 |
+
self.episode_returns = np.zeros(self.num_envs, dtype=np.float32)
|
| 87 |
+
self.episode_lengths = np.zeros(self.num_envs, dtype=np.int32)
|
| 88 |
+
self.lives = np.zeros(self.num_envs, dtype=np.int32)
|
| 89 |
+
self.returned_episode_returns = np.zeros(self.num_envs, dtype=np.float32)
|
| 90 |
+
self.returned_episode_lengths = np.zeros(self.num_envs, dtype=np.int32)
|
| 91 |
+
return observations
|
| 92 |
+
|
| 93 |
+
def step(self, action):
|
| 94 |
+
observations, rewards, dones, infos = super().step(action)
|
| 95 |
+
self.episode_returns += infos["reward"]
|
| 96 |
+
self.episode_lengths += 1
|
| 97 |
+
self.returned_episode_returns[:] = self.episode_returns
|
| 98 |
+
self.returned_episode_lengths[:] = self.episode_lengths
|
| 99 |
+
self.episode_returns *= 1 - infos["terminated"]
|
| 100 |
+
self.episode_lengths *= 1 - infos["terminated"]
|
| 101 |
+
infos["r"] = self.returned_episode_returns
|
| 102 |
+
infos["l"] = self.returned_episode_lengths
|
| 103 |
+
return (
|
| 104 |
+
observations,
|
| 105 |
+
rewards,
|
| 106 |
+
dones,
|
| 107 |
+
infos,
|
| 108 |
+
)
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 112 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 113 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 114 |
+
return layer
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
class QNetwork(nn.Module):
|
| 118 |
+
def __init__(self, env):
|
| 119 |
+
super().__init__()
|
| 120 |
+
self.network = nn.Sequential(
|
| 121 |
+
layer_init(nn.Conv2d(4, 32, 8, stride=4)),
|
| 122 |
+
nn.LayerNorm([32, 20, 20]),
|
| 123 |
+
nn.ReLU(),
|
| 124 |
+
layer_init(nn.Conv2d(32, 64, 4, stride=2)),
|
| 125 |
+
nn.LayerNorm([64, 9, 9]),
|
| 126 |
+
nn.ReLU(),
|
| 127 |
+
layer_init(nn.Conv2d(64, 64, 3, stride=1)),
|
| 128 |
+
nn.LayerNorm([64, 7, 7]),
|
| 129 |
+
nn.ReLU(),
|
| 130 |
+
nn.Flatten(),
|
| 131 |
+
layer_init(nn.Linear(3136, 512)),
|
| 132 |
+
nn.LayerNorm(512),
|
| 133 |
+
nn.ReLU(),
|
| 134 |
+
layer_init(nn.Linear(512, env.single_action_space.n)),
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
def forward(self, x):
|
| 138 |
+
return self.network(x / 255.0)
|
| 139 |
+
|
| 140 |
+
|
| 141 |
+
def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
|
| 142 |
+
slope = (end_e - start_e) / duration
|
| 143 |
+
return max(slope * t + start_e, end_e)
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
if __name__ == "__main__":
|
| 147 |
+
args = tyro.cli(Args)
|
| 148 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 149 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 150 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 151 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 152 |
+
if args.track:
|
| 153 |
+
import wandb
|
| 154 |
+
|
| 155 |
+
wandb.init(
|
| 156 |
+
project=args.wandb_project_name,
|
| 157 |
+
entity=args.wandb_entity,
|
| 158 |
+
sync_tensorboard=True,
|
| 159 |
+
config=vars(args),
|
| 160 |
+
name=run_name,
|
| 161 |
+
monitor_gym=True,
|
| 162 |
+
save_code=True,
|
| 163 |
+
)
|
| 164 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 165 |
+
writer.add_text(
|
| 166 |
+
"hyperparameters",
|
| 167 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
# TRY NOT TO MODIFY: seeding
|
| 171 |
+
random.seed(args.seed)
|
| 172 |
+
np.random.seed(args.seed)
|
| 173 |
+
torch.manual_seed(args.seed)
|
| 174 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 175 |
+
|
| 176 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 177 |
+
|
| 178 |
+
# env setup
|
| 179 |
+
envs = envpool.make(
|
| 180 |
+
args.env_id,
|
| 181 |
+
env_type="gym",
|
| 182 |
+
num_envs=args.num_envs,
|
| 183 |
+
episodic_life=True,
|
| 184 |
+
reward_clip=True,
|
| 185 |
+
seed=args.seed,
|
| 186 |
+
)
|
| 187 |
+
envs.num_envs = args.num_envs
|
| 188 |
+
envs.single_action_space = envs.action_space
|
| 189 |
+
envs.single_observation_space = envs.observation_space
|
| 190 |
+
envs = RecordEpisodeStatistics(envs)
|
| 191 |
+
assert isinstance(envs.action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 192 |
+
|
| 193 |
+
q_network = QNetwork(envs).to(device)
|
| 194 |
+
optimizer = optim.RAdam(q_network.parameters(), lr=args.learning_rate)
|
| 195 |
+
|
| 196 |
+
# ALGO Logic: Storage setup
|
| 197 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 198 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 199 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 200 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 201 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 202 |
+
avg_returns = deque(maxlen=20)
|
| 203 |
+
|
| 204 |
+
# TRY NOT TO MODIFY: start the game
|
| 205 |
+
global_step = 0
|
| 206 |
+
start_time = time.time()
|
| 207 |
+
next_obs = torch.Tensor(envs.reset()).to(device)
|
| 208 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 209 |
+
|
| 210 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 211 |
+
# Annealing the rate if instructed to do so.
|
| 212 |
+
if args.anneal_lr:
|
| 213 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 214 |
+
lrnow = frac * args.learning_rate
|
| 215 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 216 |
+
|
| 217 |
+
for step in range(0, args.num_steps):
|
| 218 |
+
global_step += args.num_envs
|
| 219 |
+
obs[step] = next_obs
|
| 220 |
+
dones[step] = next_done
|
| 221 |
+
|
| 222 |
+
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
|
| 223 |
+
|
| 224 |
+
random_actions = torch.randint(0, envs.single_action_space.n, (args.num_envs,)).to(device)
|
| 225 |
+
with torch.no_grad():
|
| 226 |
+
q_values = q_network(next_obs)
|
| 227 |
+
max_actions = torch.argmax(q_values, dim=1)
|
| 228 |
+
values[step] = q_values[torch.arange(args.num_envs), max_actions].flatten()
|
| 229 |
+
|
| 230 |
+
explore = torch.rand((args.num_envs,)).to(device) < epsilon
|
| 231 |
+
action = torch.where(explore, random_actions, max_actions)
|
| 232 |
+
actions[step] = action
|
| 233 |
+
|
| 234 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 235 |
+
next_obs, reward, next_done, info = envs.step(action.cpu().numpy())
|
| 236 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 237 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 238 |
+
|
| 239 |
+
for idx, d in enumerate(next_done):
|
| 240 |
+
if d and info["lives"][idx] == 0:
|
| 241 |
+
print(f"global_step={global_step}, episodic_return={info['r'][idx]}")
|
| 242 |
+
avg_returns.append(info["r"][idx])
|
| 243 |
+
writer.add_scalar("charts/avg_episodic_return", np.average(avg_returns), global_step)
|
| 244 |
+
writer.add_scalar("charts/episodic_return", info["r"][idx], global_step)
|
| 245 |
+
writer.add_scalar("charts/episodic_length", info["l"][idx], global_step)
|
| 246 |
+
|
| 247 |
+
# Compute Q(lambda) targets
|
| 248 |
+
with torch.no_grad():
|
| 249 |
+
returns = torch.zeros_like(rewards).to(device)
|
| 250 |
+
for t in reversed(range(args.num_steps)):
|
| 251 |
+
if t == args.num_steps - 1:
|
| 252 |
+
next_value, _ = torch.max(q_network(next_obs), dim=-1)
|
| 253 |
+
nextnonterminal = 1.0 - next_done
|
| 254 |
+
returns[t] = rewards[t] + args.gamma * next_value * nextnonterminal
|
| 255 |
+
else:
|
| 256 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 257 |
+
next_value = values[t + 1]
|
| 258 |
+
returns[t] = (
|
| 259 |
+
rewards[t]
|
| 260 |
+
+ args.gamma * (args.q_lambda * returns[t + 1] + (1 - args.q_lambda) * next_value) * nextnonterminal
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
# flatten the batch
|
| 264 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 265 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 266 |
+
b_returns = returns.reshape(-1)
|
| 267 |
+
|
| 268 |
+
# Optimizing the Q-network
|
| 269 |
+
b_inds = np.arange(args.batch_size)
|
| 270 |
+
for epoch in range(args.update_epochs):
|
| 271 |
+
np.random.shuffle(b_inds)
|
| 272 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 273 |
+
end = start + args.minibatch_size
|
| 274 |
+
mb_inds = b_inds[start:end]
|
| 275 |
+
|
| 276 |
+
old_val = q_network(b_obs[mb_inds]).gather(1, b_actions[mb_inds].unsqueeze(-1).long()).squeeze()
|
| 277 |
+
loss = F.mse_loss(b_returns[mb_inds], old_val)
|
| 278 |
+
|
| 279 |
+
# optimize the model
|
| 280 |
+
optimizer.zero_grad()
|
| 281 |
+
loss.backward()
|
| 282 |
+
nn.utils.clip_grad_norm_(q_network.parameters(), args.max_grad_norm)
|
| 283 |
+
optimizer.step()
|
| 284 |
+
|
| 285 |
+
writer.add_scalar("losses/td_loss", loss, global_step)
|
| 286 |
+
writer.add_scalar("losses/q_values", old_val.mean().item(), global_step)
|
| 287 |
+
print("SPS:", int(global_step / (time.time() - start_time)))
|
| 288 |
+
writer.add_scalar("charts/SPS", int(global_step / (time.time() - start_time)), global_step)
|
| 289 |
+
|
| 290 |
+
envs.close()
|
| 291 |
+
writer.close()
|
cleanrl/cleanrl/qdagger_dqn_atari_jax_impalacnn.py
ADDED
|
@@ -0,0 +1,475 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/qdagger/#qdagger_dqn_atari_jax_impalacnnpy
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from collections import deque
|
| 6 |
+
from dataclasses import dataclass
|
| 7 |
+
from typing import Sequence
|
| 8 |
+
|
| 9 |
+
# see https://github.com/google/jax/discussions/6332#discussioncomment-1279991
|
| 10 |
+
os.environ["XLA_PYTHON_CLIENT_MEM_FRACTION"] = "0.7"
|
| 11 |
+
|
| 12 |
+
import flax
|
| 13 |
+
import flax.linen as nn
|
| 14 |
+
import gymnasium as gym
|
| 15 |
+
import jax
|
| 16 |
+
import jax.numpy as jnp
|
| 17 |
+
import numpy as np
|
| 18 |
+
import optax
|
| 19 |
+
import tyro
|
| 20 |
+
from flax.training.train_state import TrainState
|
| 21 |
+
from huggingface_hub import hf_hub_download
|
| 22 |
+
from rich.progress import track
|
| 23 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 24 |
+
|
| 25 |
+
from cleanrl.dqn_atari_jax import QNetwork as TeacherModel
|
| 26 |
+
from cleanrl_utils.atari_wrappers import (
|
| 27 |
+
ClipRewardEnv,
|
| 28 |
+
EpisodicLifeEnv,
|
| 29 |
+
FireResetEnv,
|
| 30 |
+
MaxAndSkipEnv,
|
| 31 |
+
NoopResetEnv,
|
| 32 |
+
)
|
| 33 |
+
from cleanrl_utils.buffers import ReplayBuffer
|
| 34 |
+
from cleanrl_utils.evals.dqn_jax_eval import evaluate
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
@dataclass
|
| 38 |
+
class Args:
|
| 39 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 40 |
+
"""the name of this experiment"""
|
| 41 |
+
seed: int = 1
|
| 42 |
+
"""seed of the experiment"""
|
| 43 |
+
track: bool = False
|
| 44 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 45 |
+
wandb_project_name: str = "cleanRL"
|
| 46 |
+
"""the wandb's project name"""
|
| 47 |
+
wandb_entity: str = None
|
| 48 |
+
"""the entity (team) of wandb's project"""
|
| 49 |
+
capture_video: bool = False
|
| 50 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 51 |
+
save_model: bool = False
|
| 52 |
+
"""whether to save model into the `runs/{run_name}` folder"""
|
| 53 |
+
upload_model: bool = False
|
| 54 |
+
"""whether to upload the saved model to huggingface"""
|
| 55 |
+
hf_entity: str = ""
|
| 56 |
+
"""the user or org name of the model repository from the Hugging Face Hub"""
|
| 57 |
+
|
| 58 |
+
# Algorithm specific arguments
|
| 59 |
+
env_id: str = "BreakoutNoFrameskip-v4"
|
| 60 |
+
"""the id of the environment"""
|
| 61 |
+
total_timesteps: int = 10000000
|
| 62 |
+
"""total timesteps of the experiments"""
|
| 63 |
+
learning_rate: float = 1e-4
|
| 64 |
+
"""the learning rate of the optimizer"""
|
| 65 |
+
num_envs: int = 1
|
| 66 |
+
"""the number of parallel game environments"""
|
| 67 |
+
buffer_size: int = 1000000
|
| 68 |
+
"""the replay memory buffer size"""
|
| 69 |
+
gamma: float = 0.99
|
| 70 |
+
"""the discount factor gamma"""
|
| 71 |
+
tau: float = 1.0
|
| 72 |
+
"""the target network update rate"""
|
| 73 |
+
target_network_frequency: int = 1000
|
| 74 |
+
"""the timesteps it takes to update the target network"""
|
| 75 |
+
batch_size: int = 32
|
| 76 |
+
"""the batch size of sample from the reply memory"""
|
| 77 |
+
start_e: float = 1.0
|
| 78 |
+
"""the starting epsilon for exploration"""
|
| 79 |
+
end_e: float = 0.01
|
| 80 |
+
"""the ending epsilon for exploration"""
|
| 81 |
+
exploration_fraction: float = 0.10
|
| 82 |
+
"""the fraction of `total-timesteps` it takes from start-e to go end-e"""
|
| 83 |
+
learning_starts: int = 80000
|
| 84 |
+
"""timestep to start learning"""
|
| 85 |
+
train_frequency: int = 4
|
| 86 |
+
"""the frequency of training"""
|
| 87 |
+
|
| 88 |
+
# QDagger specific arguments
|
| 89 |
+
teacher_policy_hf_repo: str = None
|
| 90 |
+
"""the huggingface repo of the teacher policy"""
|
| 91 |
+
teacher_model_exp_name: str = "dqn_atari_jax"
|
| 92 |
+
"""the experiment name of the teacher model"""
|
| 93 |
+
teacher_eval_episodes: int = 10
|
| 94 |
+
"""the number of episodes to run the teacher policy evaluate"""
|
| 95 |
+
teacher_steps: int = 500000
|
| 96 |
+
"""the number of steps to run the teacher policy to generate the replay buffer"""
|
| 97 |
+
offline_steps: int = 500000
|
| 98 |
+
"""the number of steps to run the student policy with the teacher's replay buffer"""
|
| 99 |
+
temperature: float = 1.0
|
| 100 |
+
"""the temperature parameter for qdagger"""
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def make_env(env_id, seed, idx, capture_video, run_name):
|
| 104 |
+
def thunk():
|
| 105 |
+
if capture_video and idx == 0:
|
| 106 |
+
env = gym.make(env_id, render_mode="rgb_array")
|
| 107 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 108 |
+
else:
|
| 109 |
+
env = gym.make(env_id)
|
| 110 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 111 |
+
env = NoopResetEnv(env, noop_max=30)
|
| 112 |
+
env = MaxAndSkipEnv(env, skip=4)
|
| 113 |
+
env = EpisodicLifeEnv(env)
|
| 114 |
+
if "FIRE" in env.unwrapped.get_action_meanings():
|
| 115 |
+
env = FireResetEnv(env)
|
| 116 |
+
env = ClipRewardEnv(env)
|
| 117 |
+
env = gym.wrappers.ResizeObservation(env, (84, 84))
|
| 118 |
+
env = gym.wrappers.GrayScaleObservation(env)
|
| 119 |
+
env = gym.wrappers.FrameStack(env, 4)
|
| 120 |
+
env.action_space.seed(seed)
|
| 121 |
+
|
| 122 |
+
return env
|
| 123 |
+
|
| 124 |
+
return thunk
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
# taken from https://github.com/AIcrowd/neurips2020-procgen-starter-kit/blob/142d09586d2272a17f44481a115c4bd817cf6a94/models/impala_cnn_torch.py
|
| 128 |
+
class ResidualBlock(nn.Module):
|
| 129 |
+
channels: int
|
| 130 |
+
|
| 131 |
+
@nn.compact
|
| 132 |
+
def __call__(self, x):
|
| 133 |
+
inputs = x
|
| 134 |
+
x = nn.relu(x)
|
| 135 |
+
x = nn.Conv(
|
| 136 |
+
self.channels,
|
| 137 |
+
kernel_size=(3, 3),
|
| 138 |
+
)(x)
|
| 139 |
+
x = nn.relu(x)
|
| 140 |
+
x = nn.Conv(
|
| 141 |
+
self.channels,
|
| 142 |
+
kernel_size=(3, 3),
|
| 143 |
+
)(x)
|
| 144 |
+
return x + inputs
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
class ConvSequence(nn.Module):
|
| 148 |
+
channels: int
|
| 149 |
+
|
| 150 |
+
@nn.compact
|
| 151 |
+
def __call__(self, x):
|
| 152 |
+
x = nn.Conv(
|
| 153 |
+
self.channels,
|
| 154 |
+
kernel_size=(3, 3),
|
| 155 |
+
)(x)
|
| 156 |
+
x = nn.max_pool(x, window_shape=(3, 3), strides=(2, 2), padding="SAME")
|
| 157 |
+
x = ResidualBlock(self.channels)(x)
|
| 158 |
+
x = ResidualBlock(self.channels)(x)
|
| 159 |
+
return x
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
# ALGO LOGIC: initialize agent here:
|
| 163 |
+
class QNetwork(nn.Module):
|
| 164 |
+
action_dim: int
|
| 165 |
+
channelss: Sequence[int] = (16, 32, 32)
|
| 166 |
+
|
| 167 |
+
@nn.compact
|
| 168 |
+
def __call__(self, x):
|
| 169 |
+
x = jnp.transpose(x, (0, 2, 3, 1))
|
| 170 |
+
x = x / (255.0)
|
| 171 |
+
for channels in self.channelss:
|
| 172 |
+
x = ConvSequence(channels)(x)
|
| 173 |
+
x = nn.relu(x)
|
| 174 |
+
x = x.reshape((x.shape[0], -1))
|
| 175 |
+
x = nn.Dense(256)(x)
|
| 176 |
+
x = nn.relu(x)
|
| 177 |
+
x = nn.Dense(self.action_dim)(x)
|
| 178 |
+
return x
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
class TrainState(TrainState):
|
| 182 |
+
target_params: flax.core.FrozenDict
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def linear_schedule(start_e: float, end_e: float, duration: int, t: int):
|
| 186 |
+
slope = (end_e - start_e) / duration
|
| 187 |
+
return max(slope * t + start_e, end_e)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
if __name__ == "__main__":
|
| 191 |
+
args = tyro.cli(Args)
|
| 192 |
+
assert args.num_envs == 1, "vectorized envs are not supported at the moment"
|
| 193 |
+
if args.teacher_policy_hf_repo is None:
|
| 194 |
+
args.teacher_policy_hf_repo = f"cleanrl/{args.env_id}-{args.teacher_model_exp_name}-seed1"
|
| 195 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 196 |
+
if args.track:
|
| 197 |
+
import wandb
|
| 198 |
+
|
| 199 |
+
wandb.init(
|
| 200 |
+
project=args.wandb_project_name,
|
| 201 |
+
entity=args.wandb_entity,
|
| 202 |
+
sync_tensorboard=True,
|
| 203 |
+
config=vars(args),
|
| 204 |
+
name=run_name,
|
| 205 |
+
monitor_gym=True,
|
| 206 |
+
save_code=True,
|
| 207 |
+
)
|
| 208 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 209 |
+
writer.add_text(
|
| 210 |
+
"hyperparameters",
|
| 211 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 212 |
+
)
|
| 213 |
+
|
| 214 |
+
# TRY NOT TO MODIFY: seeding
|
| 215 |
+
random.seed(args.seed)
|
| 216 |
+
np.random.seed(args.seed)
|
| 217 |
+
key = jax.random.PRNGKey(args.seed)
|
| 218 |
+
key, q_key = jax.random.split(key, 2)
|
| 219 |
+
|
| 220 |
+
# env setup
|
| 221 |
+
envs = gym.vector.SyncVectorEnv(
|
| 222 |
+
[make_env(args.env_id, args.seed + i, i, args.capture_video, run_name) for i in range(args.num_envs)]
|
| 223 |
+
)
|
| 224 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 225 |
+
|
| 226 |
+
q_network = QNetwork(channelss=(16, 32, 32), action_dim=envs.single_action_space.n)
|
| 227 |
+
|
| 228 |
+
q_state = TrainState.create(
|
| 229 |
+
apply_fn=q_network.apply,
|
| 230 |
+
params=q_network.init(q_key, envs.observation_space.sample()),
|
| 231 |
+
target_params=q_network.init(q_key, envs.observation_space.sample()),
|
| 232 |
+
tx=optax.adam(learning_rate=args.learning_rate),
|
| 233 |
+
)
|
| 234 |
+
q_network.apply = jax.jit(q_network.apply)
|
| 235 |
+
|
| 236 |
+
# QDAGGER LOGIC:
|
| 237 |
+
teacher_model_path = hf_hub_download(
|
| 238 |
+
repo_id=args.teacher_policy_hf_repo, filename=f"{args.teacher_model_exp_name}.cleanrl_model"
|
| 239 |
+
)
|
| 240 |
+
teacher_model = TeacherModel(action_dim=envs.single_action_space.n)
|
| 241 |
+
teacher_model_key = jax.random.PRNGKey(args.seed)
|
| 242 |
+
teacher_params = teacher_model.init(teacher_model_key, envs.observation_space.sample())
|
| 243 |
+
with open(teacher_model_path, "rb") as f:
|
| 244 |
+
teacher_params = flax.serialization.from_bytes(teacher_params, f.read())
|
| 245 |
+
teacher_model.apply = jax.jit(teacher_model.apply)
|
| 246 |
+
|
| 247 |
+
# evaluate the teacher model
|
| 248 |
+
teacher_episodic_returns = evaluate(
|
| 249 |
+
teacher_model_path,
|
| 250 |
+
make_env,
|
| 251 |
+
args.env_id,
|
| 252 |
+
eval_episodes=args.teacher_eval_episodes,
|
| 253 |
+
run_name=f"{run_name}-teacher-eval",
|
| 254 |
+
Model=TeacherModel,
|
| 255 |
+
epsilon=args.end_e,
|
| 256 |
+
capture_video=False,
|
| 257 |
+
)
|
| 258 |
+
writer.add_scalar("charts/teacher/avg_episodic_return", np.mean(teacher_episodic_returns), 0)
|
| 259 |
+
|
| 260 |
+
# collect teacher data for args.teacher_steps
|
| 261 |
+
# we assume we don't have access to the teacher's replay buffer
|
| 262 |
+
# see Fig. A.19 in Agarwal et al. 2022 for more detail
|
| 263 |
+
teacher_rb = ReplayBuffer(
|
| 264 |
+
args.buffer_size,
|
| 265 |
+
envs.single_observation_space,
|
| 266 |
+
envs.single_action_space,
|
| 267 |
+
"cpu",
|
| 268 |
+
optimize_memory_usage=True,
|
| 269 |
+
handle_timeout_termination=False,
|
| 270 |
+
)
|
| 271 |
+
|
| 272 |
+
obs, _ = envs.reset(seed=args.seed)
|
| 273 |
+
for global_step in track(range(args.teacher_steps), description="filling teacher's replay buffer"):
|
| 274 |
+
epsilon = linear_schedule(args.start_e, args.end_e, args.teacher_steps, global_step)
|
| 275 |
+
if random.random() < epsilon:
|
| 276 |
+
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
|
| 277 |
+
else:
|
| 278 |
+
q_values = teacher_model.apply(teacher_params, obs)
|
| 279 |
+
actions = q_values.argmax(axis=-1)
|
| 280 |
+
actions = jax.device_get(actions)
|
| 281 |
+
next_obs, rewards, terminated, truncated, infos = envs.step(actions)
|
| 282 |
+
real_next_obs = next_obs.copy()
|
| 283 |
+
for idx, d in enumerate(truncated):
|
| 284 |
+
if d:
|
| 285 |
+
real_next_obs[idx] = infos["final_observation"][idx]
|
| 286 |
+
teacher_rb.add(obs, real_next_obs, actions, rewards, terminated, infos)
|
| 287 |
+
obs = next_obs
|
| 288 |
+
|
| 289 |
+
def kl_divergence_with_logits(target_logits, prediction_logits):
|
| 290 |
+
"""Implementation of on-policy distillation loss."""
|
| 291 |
+
out = -nn.softmax(target_logits) * (nn.log_softmax(prediction_logits) - nn.log_softmax(target_logits))
|
| 292 |
+
return jnp.sum(out)
|
| 293 |
+
|
| 294 |
+
@jax.jit
|
| 295 |
+
def update(q_state, observations, actions, next_observations, rewards, dones, distill_coeff):
|
| 296 |
+
q_next_target = q_network.apply(q_state.target_params, next_observations) # (batch_size, num_actions)
|
| 297 |
+
q_next_target = jnp.max(q_next_target, axis=-1) # (batch_size,)
|
| 298 |
+
td_target = rewards + (1 - dones) * args.gamma * q_next_target
|
| 299 |
+
teacher_q_values = teacher_model.apply(teacher_params, observations)
|
| 300 |
+
|
| 301 |
+
def loss(params, td_target, teacher_q_values, distill_coeff):
|
| 302 |
+
student_q_values = q_network.apply(params, observations) # (batch_size, num_actions)
|
| 303 |
+
q_pred = student_q_values[np.arange(student_q_values.shape[0]), actions.squeeze()] # (batch_size,)
|
| 304 |
+
q_loss = ((q_pred - td_target) ** 2).mean()
|
| 305 |
+
teacher_q_values = teacher_q_values / args.temperature
|
| 306 |
+
student_q_values = student_q_values / args.temperature
|
| 307 |
+
distill_loss = jnp.mean(jax.vmap(kl_divergence_with_logits)(teacher_q_values, student_q_values))
|
| 308 |
+
overall_loss = q_loss + distill_coeff * distill_loss
|
| 309 |
+
return overall_loss, (q_loss, q_pred, distill_loss)
|
| 310 |
+
|
| 311 |
+
(loss_value, (q_loss, q_pred, distill_loss)), grads = jax.value_and_grad(loss, has_aux=True)(
|
| 312 |
+
q_state.params, td_target, teacher_q_values, distill_coeff
|
| 313 |
+
)
|
| 314 |
+
q_state = q_state.apply_gradients(grads=grads)
|
| 315 |
+
return loss_value, q_loss, q_pred, distill_loss, q_state
|
| 316 |
+
|
| 317 |
+
# offline training phase: train the student model using the qdagger loss
|
| 318 |
+
for global_step in track(range(args.offline_steps), description="offline student training"):
|
| 319 |
+
data = teacher_rb.sample(args.batch_size)
|
| 320 |
+
# perform a gradient-descent step
|
| 321 |
+
loss, q_loss, old_val, distill_loss, q_state = update(
|
| 322 |
+
q_state,
|
| 323 |
+
data.observations.numpy(),
|
| 324 |
+
data.actions.numpy(),
|
| 325 |
+
data.next_observations.numpy(),
|
| 326 |
+
data.rewards.flatten().numpy(),
|
| 327 |
+
data.dones.flatten().numpy(),
|
| 328 |
+
1.0,
|
| 329 |
+
)
|
| 330 |
+
|
| 331 |
+
# update the target network
|
| 332 |
+
if global_step % args.target_network_frequency == 0:
|
| 333 |
+
q_state = q_state.replace(target_params=optax.incremental_update(q_state.params, q_state.target_params, args.tau))
|
| 334 |
+
|
| 335 |
+
if global_step % 100 == 0:
|
| 336 |
+
writer.add_scalar("charts/offline/loss", jax.device_get(loss), global_step)
|
| 337 |
+
writer.add_scalar("charts/offline/q_loss", jax.device_get(q_loss), global_step)
|
| 338 |
+
writer.add_scalar("charts/offline/distill_loss", jax.device_get(distill_loss), global_step)
|
| 339 |
+
|
| 340 |
+
if global_step % 100000 == 0:
|
| 341 |
+
# evaluate the student model
|
| 342 |
+
model_path = f"runs/{run_name}/{args.exp_name}-offline-{global_step}.cleanrl_model"
|
| 343 |
+
with open(model_path, "wb") as f:
|
| 344 |
+
f.write(flax.serialization.to_bytes(q_state.params))
|
| 345 |
+
print(f"model saved to {model_path}")
|
| 346 |
+
|
| 347 |
+
episodic_returns = evaluate(
|
| 348 |
+
model_path,
|
| 349 |
+
make_env,
|
| 350 |
+
args.env_id,
|
| 351 |
+
eval_episodes=10,
|
| 352 |
+
run_name=f"{run_name}-eval",
|
| 353 |
+
Model=QNetwork,
|
| 354 |
+
epsilon=args.end_e,
|
| 355 |
+
)
|
| 356 |
+
print(episodic_returns)
|
| 357 |
+
writer.add_scalar("charts/offline/avg_episodic_return", np.mean(episodic_returns), global_step)
|
| 358 |
+
|
| 359 |
+
rb = ReplayBuffer(
|
| 360 |
+
args.buffer_size,
|
| 361 |
+
envs.single_observation_space,
|
| 362 |
+
envs.single_action_space,
|
| 363 |
+
"cpu",
|
| 364 |
+
optimize_memory_usage=True,
|
| 365 |
+
handle_timeout_termination=False,
|
| 366 |
+
)
|
| 367 |
+
start_time = time.time()
|
| 368 |
+
|
| 369 |
+
# TRY NOT TO MODIFY: start the game
|
| 370 |
+
envs = gym.vector.SyncVectorEnv(
|
| 371 |
+
[make_env(args.env_id, args.seed + i, i, args.capture_video, run_name) for i in range(args.num_envs)]
|
| 372 |
+
)
|
| 373 |
+
obs, _ = envs.reset(seed=args.seed)
|
| 374 |
+
episodic_returns = deque(maxlen=10)
|
| 375 |
+
# online training phase
|
| 376 |
+
for global_step in track(range(args.total_timesteps), description="online student training"):
|
| 377 |
+
global_step += args.offline_steps
|
| 378 |
+
# ALGO LOGIC: put action logic here
|
| 379 |
+
epsilon = linear_schedule(args.start_e, args.end_e, args.exploration_fraction * args.total_timesteps, global_step)
|
| 380 |
+
if random.random() < epsilon:
|
| 381 |
+
actions = np.array([envs.single_action_space.sample() for _ in range(envs.num_envs)])
|
| 382 |
+
else:
|
| 383 |
+
q_values = q_network.apply(q_state.params, obs)
|
| 384 |
+
actions = q_values.argmax(axis=-1)
|
| 385 |
+
actions = jax.device_get(actions)
|
| 386 |
+
|
| 387 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 388 |
+
next_obs, rewards, terminated, truncated, infos = envs.step(actions)
|
| 389 |
+
|
| 390 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 391 |
+
if "final_info" in infos:
|
| 392 |
+
for info in infos["final_info"]:
|
| 393 |
+
# Skip the envs that are not done
|
| 394 |
+
if "episode" not in info:
|
| 395 |
+
continue
|
| 396 |
+
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
|
| 397 |
+
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
|
| 398 |
+
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
|
| 399 |
+
writer.add_scalar("charts/epsilon", epsilon, global_step)
|
| 400 |
+
episodic_returns.append(info["episode"]["r"])
|
| 401 |
+
break
|
| 402 |
+
|
| 403 |
+
# TRY NOT TO MODIFY: save data to reply buffer; handle `final_observation`
|
| 404 |
+
real_next_obs = next_obs.copy()
|
| 405 |
+
for idx, d in enumerate(truncated):
|
| 406 |
+
if d:
|
| 407 |
+
real_next_obs[idx] = infos["final_observation"][idx]
|
| 408 |
+
rb.add(obs, real_next_obs, actions, rewards, terminated, infos)
|
| 409 |
+
|
| 410 |
+
# TRY NOT TO MODIFY: CRUCIAL step easy to overlook
|
| 411 |
+
obs = next_obs
|
| 412 |
+
|
| 413 |
+
# ALGO LOGIC: training.
|
| 414 |
+
if global_step > args.learning_starts:
|
| 415 |
+
if global_step % args.train_frequency == 0:
|
| 416 |
+
data = rb.sample(args.batch_size)
|
| 417 |
+
# perform a gradient-descent step
|
| 418 |
+
if len(episodic_returns) < 10:
|
| 419 |
+
distill_coeff = 1.0
|
| 420 |
+
else:
|
| 421 |
+
distill_coeff = max(1 - np.mean(episodic_returns) / np.mean(teacher_episodic_returns), 0)
|
| 422 |
+
loss, q_loss, old_val, distill_loss, q_state = update(
|
| 423 |
+
q_state,
|
| 424 |
+
data.observations.numpy(),
|
| 425 |
+
data.actions.numpy(),
|
| 426 |
+
data.next_observations.numpy(),
|
| 427 |
+
data.rewards.flatten().numpy(),
|
| 428 |
+
data.dones.flatten().numpy(),
|
| 429 |
+
distill_coeff,
|
| 430 |
+
)
|
| 431 |
+
|
| 432 |
+
if global_step % 100 == 0:
|
| 433 |
+
writer.add_scalar("losses/loss", jax.device_get(loss), global_step)
|
| 434 |
+
writer.add_scalar("losses/td_loss", jax.device_get(q_loss), global_step)
|
| 435 |
+
writer.add_scalar("losses/distill_loss", jax.device_get(distill_loss), global_step)
|
| 436 |
+
writer.add_scalar("losses/q_values", jax.device_get(old_val).mean(), global_step)
|
| 437 |
+
writer.add_scalar("charts/distill_coeff", distill_coeff, global_step)
|
| 438 |
+
print("SPS:", int(global_step / (time.time() - start_time)))
|
| 439 |
+
print(distill_coeff)
|
| 440 |
+
writer.add_scalar("charts/SPS", int(global_step / (time.time() - start_time)), global_step)
|
| 441 |
+
|
| 442 |
+
# update the target network
|
| 443 |
+
if global_step % args.target_network_frequency == 0:
|
| 444 |
+
q_state = q_state.replace(
|
| 445 |
+
target_params=optax.incremental_update(q_state.params, q_state.target_params, args.tau)
|
| 446 |
+
)
|
| 447 |
+
|
| 448 |
+
if args.save_model:
|
| 449 |
+
model_path = f"runs/{run_name}/{args.exp_name}.cleanrl_model"
|
| 450 |
+
with open(model_path, "wb") as f:
|
| 451 |
+
f.write(flax.serialization.to_bytes(q_state.params))
|
| 452 |
+
print(f"model saved to {model_path}")
|
| 453 |
+
from cleanrl_utils.evals.dqn_jax_eval import evaluate
|
| 454 |
+
|
| 455 |
+
episodic_returns = evaluate(
|
| 456 |
+
model_path,
|
| 457 |
+
make_env,
|
| 458 |
+
args.env_id,
|
| 459 |
+
eval_episodes=10,
|
| 460 |
+
run_name=f"{run_name}-eval",
|
| 461 |
+
Model=QNetwork,
|
| 462 |
+
epsilon=args.end_e,
|
| 463 |
+
)
|
| 464 |
+
for idx, episodic_return in enumerate(episodic_returns):
|
| 465 |
+
writer.add_scalar("eval/episodic_return", episodic_return, idx)
|
| 466 |
+
|
| 467 |
+
if args.upload_model:
|
| 468 |
+
from cleanrl_utils.huggingface import push_to_hub
|
| 469 |
+
|
| 470 |
+
repo_name = f"{args.env_id}-{args.exp_name}-seed{args.seed}"
|
| 471 |
+
repo_id = f"{args.hf_entity}/{repo_name}" if args.hf_entity else repo_name
|
| 472 |
+
push_to_hub(args, episodic_returns, repo_id, "Qdagger", f"runs/{run_name}", f"videos/{run_name}-eval")
|
| 473 |
+
|
| 474 |
+
envs.close()
|
| 475 |
+
writer.close()
|
cleanrl/cleanrl/rainbow_atari.py
ADDED
|
@@ -0,0 +1,529 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# docs and experiment results can be found at https://docs.cleanrl.dev/rl-algorithms/rainbow/#rainbow_ataripy
|
| 2 |
+
import collections
|
| 3 |
+
import math
|
| 4 |
+
import os
|
| 5 |
+
import random
|
| 6 |
+
import time
|
| 7 |
+
from collections import deque
|
| 8 |
+
from dataclasses import dataclass
|
| 9 |
+
|
| 10 |
+
import gymnasium as gym
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.nn.functional as F
|
| 15 |
+
import torch.optim as optim
|
| 16 |
+
import tyro
|
| 17 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 18 |
+
|
| 19 |
+
from cleanrl_utils.atari_wrappers import (
|
| 20 |
+
ClipRewardEnv,
|
| 21 |
+
EpisodicLifeEnv,
|
| 22 |
+
FireResetEnv,
|
| 23 |
+
MaxAndSkipEnv,
|
| 24 |
+
NoopResetEnv,
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
@dataclass
|
| 29 |
+
class Args:
|
| 30 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 31 |
+
"""the name of this experiment"""
|
| 32 |
+
seed: int = 1
|
| 33 |
+
"""seed of the experiment"""
|
| 34 |
+
torch_deterministic: bool = True
|
| 35 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 36 |
+
cuda: bool = True
|
| 37 |
+
"""if toggled, cuda will be enabled by default"""
|
| 38 |
+
track: bool = False
|
| 39 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 40 |
+
wandb_project_name: str = "cleanRL"
|
| 41 |
+
"""the wandb's project name"""
|
| 42 |
+
wandb_entity: str = None
|
| 43 |
+
"""the entity (team) of wandb's project"""
|
| 44 |
+
capture_video: bool = False
|
| 45 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 46 |
+
save_model: bool = False
|
| 47 |
+
"""whether to save model into the `runs/{run_name}` folder"""
|
| 48 |
+
upload_model: bool = False
|
| 49 |
+
"""whether to upload the saved model to huggingface"""
|
| 50 |
+
hf_entity: str = ""
|
| 51 |
+
"""the user or org name of the model repository from the Hugging Face Hub"""
|
| 52 |
+
|
| 53 |
+
env_id: str = "BreakoutNoFrameskip-v4"
|
| 54 |
+
"""the id of the environment"""
|
| 55 |
+
total_timesteps: int = 10000000
|
| 56 |
+
"""total timesteps of the experiments"""
|
| 57 |
+
learning_rate: float = 0.0000625
|
| 58 |
+
"""the learning rate of the optimizer"""
|
| 59 |
+
num_envs: int = 1
|
| 60 |
+
"""the number of parallel game environments"""
|
| 61 |
+
buffer_size: int = 1000000
|
| 62 |
+
"""the replay memory buffer size"""
|
| 63 |
+
gamma: float = 0.99
|
| 64 |
+
"""the discount factor gamma"""
|
| 65 |
+
tau: float = 1.0
|
| 66 |
+
"""the target network update rate"""
|
| 67 |
+
target_network_frequency: int = 8000
|
| 68 |
+
"""the timesteps it takes to update the target network"""
|
| 69 |
+
batch_size: int = 32
|
| 70 |
+
"""the batch size of sample from the reply memory"""
|
| 71 |
+
start_e: float = 1
|
| 72 |
+
"""the starting epsilon for exploration"""
|
| 73 |
+
end_e: float = 0.01
|
| 74 |
+
"""the ending epsilon for exploration"""
|
| 75 |
+
exploration_fraction: float = 0.10
|
| 76 |
+
"""the fraction of `total-timesteps` it takes from start-e to go end-e"""
|
| 77 |
+
learning_starts: int = 80000
|
| 78 |
+
"""timestep to start learning"""
|
| 79 |
+
train_frequency: int = 4
|
| 80 |
+
"""the frequency of training"""
|
| 81 |
+
n_step: int = 3
|
| 82 |
+
"""the number of steps to look ahead for n-step Q learning"""
|
| 83 |
+
prioritized_replay_alpha: float = 0.5
|
| 84 |
+
"""alpha parameter for prioritized replay buffer"""
|
| 85 |
+
prioritized_replay_beta: float = 0.4
|
| 86 |
+
"""beta parameter for prioritized replay buffer"""
|
| 87 |
+
prioritized_replay_eps: float = 1e-6
|
| 88 |
+
"""epsilon parameter for prioritized replay buffer"""
|
| 89 |
+
n_atoms: int = 51
|
| 90 |
+
"""the number of atoms"""
|
| 91 |
+
v_min: float = -10
|
| 92 |
+
"""the return lower bound"""
|
| 93 |
+
v_max: float = 10
|
| 94 |
+
"""the return upper bound"""
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def make_env(env_id, seed, idx, capture_video, run_name):
|
| 98 |
+
def thunk():
|
| 99 |
+
if capture_video and idx == 0:
|
| 100 |
+
env = gym.make(env_id, render_mode="rgb_array")
|
| 101 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 102 |
+
else:
|
| 103 |
+
env = gym.make(env_id)
|
| 104 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 105 |
+
|
| 106 |
+
env = NoopResetEnv(env, noop_max=30)
|
| 107 |
+
env = MaxAndSkipEnv(env, skip=4)
|
| 108 |
+
env = EpisodicLifeEnv(env)
|
| 109 |
+
if "FIRE" in env.unwrapped.get_action_meanings():
|
| 110 |
+
env = FireResetEnv(env)
|
| 111 |
+
env = ClipRewardEnv(env)
|
| 112 |
+
env = gym.wrappers.ResizeObservation(env, (84, 84))
|
| 113 |
+
env = gym.wrappers.GrayScaleObservation(env)
|
| 114 |
+
env = gym.wrappers.FrameStack(env, 4)
|
| 115 |
+
|
| 116 |
+
env.action_space.seed(seed)
|
| 117 |
+
return env
|
| 118 |
+
|
| 119 |
+
return thunk
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
class NoisyLinear(nn.Module):
|
| 123 |
+
def __init__(self, in_features, out_features, std_init=0.5):
|
| 124 |
+
super().__init__()
|
| 125 |
+
self.in_features = in_features
|
| 126 |
+
self.out_features = out_features
|
| 127 |
+
self.std_init = std_init
|
| 128 |
+
|
| 129 |
+
self.weight_mu = nn.Parameter(torch.FloatTensor(out_features, in_features))
|
| 130 |
+
self.weight_sigma = nn.Parameter(torch.FloatTensor(out_features, in_features))
|
| 131 |
+
self.register_buffer("weight_epsilon", torch.FloatTensor(out_features, in_features))
|
| 132 |
+
self.bias_mu = nn.Parameter(torch.FloatTensor(out_features))
|
| 133 |
+
self.bias_sigma = nn.Parameter(torch.FloatTensor(out_features))
|
| 134 |
+
self.register_buffer("bias_epsilon", torch.FloatTensor(out_features))
|
| 135 |
+
# factorized gaussian noise
|
| 136 |
+
self.reset_parameters()
|
| 137 |
+
self.reset_noise()
|
| 138 |
+
|
| 139 |
+
def reset_parameters(self):
|
| 140 |
+
mu_range = 1 / math.sqrt(self.in_features)
|
| 141 |
+
self.weight_mu.data.uniform_(-mu_range, mu_range)
|
| 142 |
+
self.weight_sigma.data.fill_(self.std_init / math.sqrt(self.in_features))
|
| 143 |
+
self.bias_mu.data.uniform_(-mu_range, mu_range)
|
| 144 |
+
self.bias_sigma.data.fill_(self.std_init / math.sqrt(self.out_features))
|
| 145 |
+
|
| 146 |
+
def reset_noise(self):
|
| 147 |
+
self.weight_epsilon.normal_()
|
| 148 |
+
self.bias_epsilon.normal_()
|
| 149 |
+
|
| 150 |
+
def forward(self, input):
|
| 151 |
+
if self.training:
|
| 152 |
+
weight = self.weight_mu + self.weight_sigma * self.weight_epsilon
|
| 153 |
+
bias = self.bias_mu + self.bias_sigma * self.bias_epsilon
|
| 154 |
+
else:
|
| 155 |
+
weight = self.weight_mu
|
| 156 |
+
bias = self.bias_mu
|
| 157 |
+
return F.linear(input, weight, bias)
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
# ALGO LOGIC: initialize agent here:
|
| 161 |
+
class NoisyDuelingDistributionalNetwork(nn.Module):
|
| 162 |
+
def __init__(self, env, n_atoms, v_min, v_max):
|
| 163 |
+
super().__init__()
|
| 164 |
+
self.n_atoms = n_atoms
|
| 165 |
+
self.v_min = v_min
|
| 166 |
+
self.v_max = v_max
|
| 167 |
+
self.delta_z = (v_max - v_min) / (n_atoms - 1)
|
| 168 |
+
self.n_actions = env.single_action_space.n
|
| 169 |
+
self.register_buffer("support", torch.linspace(v_min, v_max, n_atoms))
|
| 170 |
+
|
| 171 |
+
self.network = nn.Sequential(
|
| 172 |
+
nn.Conv2d(4, 32, 8, stride=4),
|
| 173 |
+
nn.ReLU(),
|
| 174 |
+
nn.Conv2d(32, 64, 4, stride=2),
|
| 175 |
+
nn.ReLU(),
|
| 176 |
+
nn.Conv2d(64, 64, 3, stride=1),
|
| 177 |
+
nn.ReLU(),
|
| 178 |
+
nn.Flatten(),
|
| 179 |
+
)
|
| 180 |
+
conv_output_size = 3136
|
| 181 |
+
|
| 182 |
+
self.value_head = nn.Sequential(NoisyLinear(conv_output_size, 512), nn.ReLU(), NoisyLinear(512, n_atoms))
|
| 183 |
+
|
| 184 |
+
self.advantage_head = nn.Sequential(
|
| 185 |
+
NoisyLinear(conv_output_size, 512), nn.ReLU(), NoisyLinear(512, n_atoms * self.n_actions)
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
def forward(self, x):
|
| 189 |
+
h = self.network(x / 255.0)
|
| 190 |
+
value = self.value_head(h).view(-1, 1, self.n_atoms)
|
| 191 |
+
advantage = self.advantage_head(h).view(-1, self.n_actions, self.n_atoms)
|
| 192 |
+
q_atoms = value + advantage - advantage.mean(dim=1, keepdim=True)
|
| 193 |
+
q_dist = F.softmax(q_atoms, dim=2)
|
| 194 |
+
return q_dist
|
| 195 |
+
|
| 196 |
+
def reset_noise(self):
|
| 197 |
+
for layer in self.value_head:
|
| 198 |
+
if isinstance(layer, NoisyLinear):
|
| 199 |
+
layer.reset_noise()
|
| 200 |
+
for layer in self.advantage_head:
|
| 201 |
+
if isinstance(layer, NoisyLinear):
|
| 202 |
+
layer.reset_noise()
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
PrioritizedBatch = collections.namedtuple(
|
| 206 |
+
"PrioritizedBatch", ["observations", "actions", "rewards", "next_observations", "dones", "indices", "weights"]
|
| 207 |
+
)
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
# adapted from: https://github.com/openai/baselines/blob/master/baselines/common/segment_tree.py
|
| 211 |
+
class SumSegmentTree:
|
| 212 |
+
def __init__(self, capacity):
|
| 213 |
+
self.capacity = capacity
|
| 214 |
+
self.tree_size = 2 * capacity - 1
|
| 215 |
+
self.tree = np.zeros(self.tree_size, dtype=np.float32)
|
| 216 |
+
|
| 217 |
+
def _propagate(self, idx):
|
| 218 |
+
parent = (idx - 1) // 2
|
| 219 |
+
while parent >= 0:
|
| 220 |
+
self.tree[parent] = self.tree[parent * 2 + 1] + self.tree[parent * 2 + 2]
|
| 221 |
+
parent = (parent - 1) // 2
|
| 222 |
+
|
| 223 |
+
def update(self, idx, value):
|
| 224 |
+
tree_idx = idx + self.capacity - 1
|
| 225 |
+
self.tree[tree_idx] = value
|
| 226 |
+
self._propagate(tree_idx)
|
| 227 |
+
|
| 228 |
+
def total(self):
|
| 229 |
+
return self.tree[0]
|
| 230 |
+
|
| 231 |
+
def retrieve(self, value):
|
| 232 |
+
idx = 0
|
| 233 |
+
while idx * 2 + 1 < self.tree_size:
|
| 234 |
+
left = idx * 2 + 1
|
| 235 |
+
right = left + 1
|
| 236 |
+
if value <= self.tree[left]:
|
| 237 |
+
idx = left
|
| 238 |
+
else:
|
| 239 |
+
value -= self.tree[left]
|
| 240 |
+
idx = right
|
| 241 |
+
return idx - (self.capacity - 1)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
# adapted from: https://github.com/openai/baselines/blob/master/baselines/common/segment_tree.py
|
| 245 |
+
class MinSegmentTree:
|
| 246 |
+
def __init__(self, capacity):
|
| 247 |
+
self.capacity = capacity
|
| 248 |
+
self.tree_size = 2 * capacity - 1
|
| 249 |
+
self.tree = np.full(self.tree_size, float("inf"), dtype=np.float32)
|
| 250 |
+
|
| 251 |
+
def _propagate(self, idx):
|
| 252 |
+
parent = (idx - 1) // 2
|
| 253 |
+
while parent >= 0:
|
| 254 |
+
self.tree[parent] = min(self.tree[parent * 2 + 1], self.tree[parent * 2 + 2])
|
| 255 |
+
parent = (parent - 1) // 2
|
| 256 |
+
|
| 257 |
+
def update(self, idx, value):
|
| 258 |
+
tree_idx = idx + self.capacity - 1
|
| 259 |
+
self.tree[tree_idx] = value
|
| 260 |
+
self._propagate(tree_idx)
|
| 261 |
+
|
| 262 |
+
def min(self):
|
| 263 |
+
return self.tree[0]
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
class PrioritizedReplayBuffer:
|
| 267 |
+
def __init__(self, capacity, obs_shape, device, n_step, gamma, alpha=0.6, beta=0.4, eps=1e-6):
|
| 268 |
+
self.capacity = capacity
|
| 269 |
+
self.device = device
|
| 270 |
+
self.n_step = n_step
|
| 271 |
+
self.gamma = gamma
|
| 272 |
+
self.alpha = alpha
|
| 273 |
+
self.beta = beta
|
| 274 |
+
self.eps = eps
|
| 275 |
+
|
| 276 |
+
self.buffer_obs = np.zeros((capacity,) + obs_shape, dtype=np.uint8)
|
| 277 |
+
self.buffer_next_obs = np.zeros((capacity,) + obs_shape, dtype=np.uint8)
|
| 278 |
+
self.buffer_actions = np.zeros(capacity, dtype=np.int64)
|
| 279 |
+
self.buffer_rewards = np.zeros(capacity, dtype=np.float32)
|
| 280 |
+
self.buffer_dones = np.zeros(capacity, dtype=np.bool_)
|
| 281 |
+
|
| 282 |
+
self.pos = 0
|
| 283 |
+
self.size = 0
|
| 284 |
+
self.max_priority = 1.0
|
| 285 |
+
|
| 286 |
+
self.sum_tree = SumSegmentTree(capacity)
|
| 287 |
+
self.min_tree = MinSegmentTree(capacity)
|
| 288 |
+
|
| 289 |
+
# For n-step returns
|
| 290 |
+
self.n_step_buffer = deque(maxlen=n_step)
|
| 291 |
+
|
| 292 |
+
def _get_n_step_info(self):
|
| 293 |
+
reward = 0.0
|
| 294 |
+
next_obs = self.n_step_buffer[-1][3]
|
| 295 |
+
done = self.n_step_buffer[-1][4]
|
| 296 |
+
|
| 297 |
+
for i in range(len(self.n_step_buffer)):
|
| 298 |
+
reward += self.gamma**i * self.n_step_buffer[i][2]
|
| 299 |
+
if self.n_step_buffer[i][4]:
|
| 300 |
+
next_obs = self.n_step_buffer[i][3]
|
| 301 |
+
done = True
|
| 302 |
+
break
|
| 303 |
+
return reward, next_obs, done
|
| 304 |
+
|
| 305 |
+
def add(self, obs, action, reward, next_obs, done):
|
| 306 |
+
self.n_step_buffer.append((obs, action, reward, next_obs, done))
|
| 307 |
+
|
| 308 |
+
if len(self.n_step_buffer) < self.n_step:
|
| 309 |
+
return
|
| 310 |
+
|
| 311 |
+
reward, next_obs, done = self._get_n_step_info()
|
| 312 |
+
obs = self.n_step_buffer[0][0]
|
| 313 |
+
action = self.n_step_buffer[0][1]
|
| 314 |
+
|
| 315 |
+
idx = self.pos
|
| 316 |
+
self.buffer_obs[idx] = obs
|
| 317 |
+
self.buffer_next_obs[idx] = next_obs
|
| 318 |
+
self.buffer_actions[idx] = action
|
| 319 |
+
self.buffer_rewards[idx] = reward
|
| 320 |
+
self.buffer_dones[idx] = done
|
| 321 |
+
|
| 322 |
+
priority = self.max_priority**self.alpha
|
| 323 |
+
self.sum_tree.update(idx, priority)
|
| 324 |
+
self.min_tree.update(idx, priority)
|
| 325 |
+
|
| 326 |
+
self.pos = (self.pos + 1) % self.capacity
|
| 327 |
+
self.size = min(self.size + 1, self.capacity)
|
| 328 |
+
|
| 329 |
+
if done:
|
| 330 |
+
self.n_step_buffer.clear()
|
| 331 |
+
|
| 332 |
+
def sample(self, batch_size):
|
| 333 |
+
indices = []
|
| 334 |
+
p_total = self.sum_tree.total()
|
| 335 |
+
segment = p_total / batch_size
|
| 336 |
+
|
| 337 |
+
for i in range(batch_size):
|
| 338 |
+
a = segment * i
|
| 339 |
+
b = segment * (i + 1)
|
| 340 |
+
upperbound = np.random.uniform(a, b)
|
| 341 |
+
idx = self.sum_tree.retrieve(upperbound)
|
| 342 |
+
indices.append(idx)
|
| 343 |
+
|
| 344 |
+
samples = {
|
| 345 |
+
"observations": torch.from_numpy(self.buffer_obs[indices]).to(self.device),
|
| 346 |
+
"actions": torch.from_numpy(self.buffer_actions[indices]).to(self.device).unsqueeze(1),
|
| 347 |
+
"rewards": torch.from_numpy(self.buffer_rewards[indices]).to(self.device).unsqueeze(1),
|
| 348 |
+
"next_observations": torch.from_numpy(self.buffer_next_obs[indices]).to(self.device),
|
| 349 |
+
"dones": torch.from_numpy(self.buffer_dones[indices]).to(self.device).unsqueeze(1),
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
probs = np.array([self.sum_tree.tree[idx + self.capacity - 1] for idx in indices])
|
| 353 |
+
weights = (self.size * probs / p_total) ** -self.beta
|
| 354 |
+
weights = weights / weights.max()
|
| 355 |
+
samples["weights"] = torch.from_numpy(weights).to(self.device).unsqueeze(1)
|
| 356 |
+
samples["indices"] = indices
|
| 357 |
+
|
| 358 |
+
return PrioritizedBatch(**samples)
|
| 359 |
+
|
| 360 |
+
def update_priorities(self, indices, priorities):
|
| 361 |
+
priorities = np.abs(priorities) + self.eps
|
| 362 |
+
self.max_priority = max(self.max_priority, priorities.max())
|
| 363 |
+
|
| 364 |
+
for idx, priority in zip(indices, priorities):
|
| 365 |
+
priority = priority**self.alpha
|
| 366 |
+
self.sum_tree.update(idx, priority)
|
| 367 |
+
self.min_tree.update(idx, priority)
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
if __name__ == "__main__":
|
| 371 |
+
args = tyro.cli(Args)
|
| 372 |
+
assert args.num_envs == 1, "vectorized envs are not supported at the moment"
|
| 373 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 374 |
+
if args.track:
|
| 375 |
+
import wandb
|
| 376 |
+
|
| 377 |
+
wandb.init(
|
| 378 |
+
project=args.wandb_project_name,
|
| 379 |
+
entity=args.wandb_entity,
|
| 380 |
+
sync_tensorboard=True,
|
| 381 |
+
config=vars(args),
|
| 382 |
+
name=run_name,
|
| 383 |
+
monitor_gym=True,
|
| 384 |
+
save_code=True,
|
| 385 |
+
)
|
| 386 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 387 |
+
writer.add_text(
|
| 388 |
+
"hyperparameters",
|
| 389 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
# TRY NOT TO MODIFY: seeding
|
| 393 |
+
random.seed(args.seed)
|
| 394 |
+
np.random.seed(args.seed)
|
| 395 |
+
torch.manual_seed(args.seed)
|
| 396 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 397 |
+
|
| 398 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 399 |
+
|
| 400 |
+
# env setup
|
| 401 |
+
envs = gym.vector.SyncVectorEnv(
|
| 402 |
+
[make_env(args.env_id, args.seed + i, i, args.capture_video, run_name) for i in range(args.num_envs)]
|
| 403 |
+
)
|
| 404 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 405 |
+
|
| 406 |
+
q_network = NoisyDuelingDistributionalNetwork(envs, args.n_atoms, args.v_min, args.v_max).to(device)
|
| 407 |
+
optimizer = optim.Adam(q_network.parameters(), lr=args.learning_rate, eps=1.5e-4)
|
| 408 |
+
target_network = NoisyDuelingDistributionalNetwork(envs, args.n_atoms, args.v_min, args.v_max).to(device)
|
| 409 |
+
target_network.load_state_dict(q_network.state_dict())
|
| 410 |
+
|
| 411 |
+
rb = PrioritizedReplayBuffer(
|
| 412 |
+
args.buffer_size,
|
| 413 |
+
envs.single_observation_space.shape,
|
| 414 |
+
device,
|
| 415 |
+
args.n_step,
|
| 416 |
+
args.gamma,
|
| 417 |
+
args.prioritized_replay_alpha,
|
| 418 |
+
args.prioritized_replay_beta,
|
| 419 |
+
args.prioritized_replay_eps,
|
| 420 |
+
)
|
| 421 |
+
|
| 422 |
+
start_time = time.time()
|
| 423 |
+
|
| 424 |
+
# TRY NOT TO MODIFY: start the game
|
| 425 |
+
obs, _ = envs.reset(seed=args.seed)
|
| 426 |
+
for global_step in range(args.total_timesteps):
|
| 427 |
+
# anneal PER beta to 1
|
| 428 |
+
rb.beta = min(
|
| 429 |
+
1.0, args.prioritized_replay_beta + global_step * (1.0 - args.prioritized_replay_beta) / args.total_timesteps
|
| 430 |
+
)
|
| 431 |
+
|
| 432 |
+
# ALGO LOGIC: put action logic here
|
| 433 |
+
with torch.no_grad():
|
| 434 |
+
q_dist = q_network(torch.Tensor(obs).to(device))
|
| 435 |
+
q_values = torch.sum(q_dist * q_network.support, dim=2)
|
| 436 |
+
actions = torch.argmax(q_values, dim=1).cpu().numpy()
|
| 437 |
+
|
| 438 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 439 |
+
next_obs, rewards, terminations, truncations, infos = envs.step(actions)
|
| 440 |
+
|
| 441 |
+
if "final_info" in infos:
|
| 442 |
+
for info in infos["final_info"]:
|
| 443 |
+
if info and "episode" in info:
|
| 444 |
+
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
|
| 445 |
+
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
|
| 446 |
+
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
|
| 447 |
+
|
| 448 |
+
# TRY NOT TO MODIFY: save data to reply buffer; handle `final_observation`
|
| 449 |
+
real_next_obs = next_obs.copy()
|
| 450 |
+
for idx, trunc in enumerate(truncations):
|
| 451 |
+
if trunc:
|
| 452 |
+
real_next_obs[idx] = infos["final_observation"][idx]
|
| 453 |
+
rb.add(obs, actions, rewards, real_next_obs, terminations)
|
| 454 |
+
|
| 455 |
+
# TRY NOT TO MODIFY: CRUCIAL step easy to overlook
|
| 456 |
+
obs = next_obs
|
| 457 |
+
|
| 458 |
+
# ALGO LOGIC: training.
|
| 459 |
+
if global_step > args.learning_starts:
|
| 460 |
+
if global_step % args.train_frequency == 0:
|
| 461 |
+
# reset the noise for both networks
|
| 462 |
+
q_network.reset_noise()
|
| 463 |
+
target_network.reset_noise()
|
| 464 |
+
data = rb.sample(args.batch_size)
|
| 465 |
+
|
| 466 |
+
with torch.no_grad():
|
| 467 |
+
next_dist = target_network(data.next_observations) # [B, num_actions, n_atoms]
|
| 468 |
+
support = target_network.support # [n_atoms]
|
| 469 |
+
next_q_values = torch.sum(next_dist * support, dim=2) # [B, num_actions]
|
| 470 |
+
|
| 471 |
+
# double q-learning
|
| 472 |
+
next_dist_online = q_network(data.next_observations) # [B, num_actions, n_atoms]
|
| 473 |
+
next_q_online = torch.sum(next_dist_online * support, dim=2) # [B, num_actions]
|
| 474 |
+
best_actions = torch.argmax(next_q_online, dim=1) # [B]
|
| 475 |
+
next_pmfs = next_dist[torch.arange(args.batch_size), best_actions] # [B, n_atoms]
|
| 476 |
+
|
| 477 |
+
# compute the n-step Bellman update.
|
| 478 |
+
gamma_n = args.gamma**args.n_step
|
| 479 |
+
next_atoms = data.rewards + gamma_n * support * (1 - data.dones.float())
|
| 480 |
+
tz = next_atoms.clamp(q_network.v_min, q_network.v_max)
|
| 481 |
+
|
| 482 |
+
# projection
|
| 483 |
+
delta_z = q_network.delta_z
|
| 484 |
+
b = (tz - q_network.v_min) / delta_z # shape: [B, n_atoms]
|
| 485 |
+
l = b.floor().clamp(0, args.n_atoms - 1)
|
| 486 |
+
u = b.ceil().clamp(0, args.n_atoms - 1)
|
| 487 |
+
|
| 488 |
+
# (l == u).float() handles the case where bj is exactly an integer
|
| 489 |
+
# example bj = 1, then the upper ceiling should be uj= 2, and lj= 1
|
| 490 |
+
d_m_l = (u.float() + (l == b).float() - b) * next_pmfs # [B, n_atoms]
|
| 491 |
+
d_m_u = (b - l) * next_pmfs # [B, n_atoms]
|
| 492 |
+
|
| 493 |
+
target_pmfs = torch.zeros_like(next_pmfs)
|
| 494 |
+
for i in range(target_pmfs.size(0)):
|
| 495 |
+
target_pmfs[i].index_add_(0, l[i].long(), d_m_l[i])
|
| 496 |
+
target_pmfs[i].index_add_(0, u[i].long(), d_m_u[i])
|
| 497 |
+
|
| 498 |
+
dist = q_network(data.observations) # [B, num_actions, n_atoms]
|
| 499 |
+
pred_dist = dist.gather(1, data.actions.unsqueeze(-1).expand(-1, -1, args.n_atoms)).squeeze(1)
|
| 500 |
+
log_pred = torch.log(pred_dist.clamp(min=1e-5, max=1 - 1e-5))
|
| 501 |
+
|
| 502 |
+
loss_per_sample = -(target_pmfs * log_pred).sum(dim=1)
|
| 503 |
+
loss = (loss_per_sample * data.weights.squeeze()).mean()
|
| 504 |
+
|
| 505 |
+
# update priorities
|
| 506 |
+
new_priorities = loss_per_sample.detach().cpu().numpy()
|
| 507 |
+
rb.update_priorities(data.indices, new_priorities)
|
| 508 |
+
|
| 509 |
+
if global_step % 100 == 0:
|
| 510 |
+
writer.add_scalar("losses/td_loss", loss.item(), global_step)
|
| 511 |
+
q_values = (pred_dist * q_network.support).sum(dim=1) # [B]
|
| 512 |
+
writer.add_scalar("losses/q_values", q_values.mean().item(), global_step)
|
| 513 |
+
sps = int(global_step / (time.time() - start_time))
|
| 514 |
+
print("SPS:", sps)
|
| 515 |
+
writer.add_scalar("charts/SPS", sps, global_step)
|
| 516 |
+
writer.add_scalar("charts/beta", rb.beta, global_step)
|
| 517 |
+
|
| 518 |
+
# optimize the model
|
| 519 |
+
optimizer.zero_grad()
|
| 520 |
+
loss.backward()
|
| 521 |
+
optimizer.step()
|
| 522 |
+
|
| 523 |
+
# update target network
|
| 524 |
+
if global_step % args.target_network_frequency == 0:
|
| 525 |
+
for target_param, param in zip(target_network.parameters(), q_network.parameters()):
|
| 526 |
+
target_param.data.copy_(args.tau * param.data + (1.0 - args.tau) * target_param.data)
|
| 527 |
+
|
| 528 |
+
envs.close()
|
| 529 |
+
writer.close()
|
cleanrl/cleanrl/scout_dqn/noisy_dqn_2048_5000score.py
ADDED
|
@@ -0,0 +1,737 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# NoisyNet DQN (dueling CNN) for RAGEN 2048
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Dict, Any, Tuple
|
| 8 |
+
from collections import deque
|
| 9 |
+
|
| 10 |
+
import gymnasium as gym
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
import json
|
| 17 |
+
|
| 18 |
+
import sys
|
| 19 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 20 |
+
|
| 21 |
+
from ragen.env.game_2048.env import Game2048Env
|
| 22 |
+
from ragen.env.game_2048.config import Game2048EnvConfig
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
class Game2048Wrapper(gym.Env):
|
| 26 |
+
metadata = {"render_modes": ["text"]}
|
| 27 |
+
|
| 28 |
+
def __init__(self, env: Game2048Env, n_channels: int = 16):
|
| 29 |
+
super().__init__()
|
| 30 |
+
self._env = env
|
| 31 |
+
self._n_channels = int(n_channels)
|
| 32 |
+
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(self._n_channels, 4, 4), dtype=np.float32)
|
| 33 |
+
self.action_space = self._env.action_space
|
| 34 |
+
self._last_info: Dict[str, Any] | None = None
|
| 35 |
+
|
| 36 |
+
def _encode_grid(self, grid: np.ndarray) -> np.ndarray:
|
| 37 |
+
grid_flat = grid.flatten()
|
| 38 |
+
with np.errstate(divide='ignore'):
|
| 39 |
+
power_grid = np.log2(grid_flat, where=(grid_flat > 0)).astype(int)
|
| 40 |
+
power_grid[grid_flat == 0] = 0
|
| 41 |
+
power_grid = np.clip(power_grid, 0, self._n_channels - 1)
|
| 42 |
+
one_hot = np.eye(self._n_channels)[power_grid]
|
| 43 |
+
obs = one_hot.reshape(4, 4, self._n_channels).transpose(2, 0, 1)
|
| 44 |
+
return obs.astype(np.float32)
|
| 45 |
+
|
| 46 |
+
def reset(self, *, seed: int | None = None, options: Dict[str, Any] | None = None):
|
| 47 |
+
text_obs, info = self._env.reset(seed=seed, options=options)
|
| 48 |
+
self._last_info = info
|
| 49 |
+
grid = info.get('grid', np.zeros((4, 4), dtype=np.int64))
|
| 50 |
+
obs = self._encode_grid(grid)
|
| 51 |
+
# augment info with max_tile for downstream logging
|
| 52 |
+
ret_info = {k: v for k, v in (info or {}).items() if k != 'grid'}
|
| 53 |
+
try:
|
| 54 |
+
ret_info['max_tile'] = int(np.max(grid))
|
| 55 |
+
except Exception:
|
| 56 |
+
ret_info['max_tile'] = int(ret_info.get('max_tile', 0))
|
| 57 |
+
return obs, ret_info
|
| 58 |
+
|
| 59 |
+
def step(self, action: int):
|
| 60 |
+
# text_obs, reward, terminated, truncated, info = self._env.step(int(action))
|
| 61 |
+
text_obs, reward, done, info = self._env.step(int(action))
|
| 62 |
+
self._last_info = info
|
| 63 |
+
grid = info.get('grid', np.zeros((4, 4), dtype=np.int64))
|
| 64 |
+
obs = self._encode_grid(grid)
|
| 65 |
+
# augment info with max_tile for downstream logging
|
| 66 |
+
ret_info = {k: v for k, v in (info or {}).items() if k != 'grid'}
|
| 67 |
+
try:
|
| 68 |
+
ret_info['max_tile'] = int(np.max(grid))
|
| 69 |
+
except Exception:
|
| 70 |
+
ret_info['max_tile'] = int(ret_info.get('max_tile', 0))
|
| 71 |
+
# return obs, float(reward), bool(terminated), bool(truncated), ret_info
|
| 72 |
+
terminated = bool(done)
|
| 73 |
+
truncated = False
|
| 74 |
+
return obs, float(reward), terminated, truncated, ret_info
|
| 75 |
+
|
| 76 |
+
def get_action_mask(self) -> np.ndarray:
|
| 77 |
+
if self._last_info is None:
|
| 78 |
+
return np.ones((4,), dtype=bool)
|
| 79 |
+
mask = self._last_info.get('action_mask', None)
|
| 80 |
+
if mask is None:
|
| 81 |
+
return np.ones((4,), dtype=bool)
|
| 82 |
+
return np.asarray(mask, dtype=bool)
|
| 83 |
+
|
| 84 |
+
def render(self):
|
| 85 |
+
return self._env.render()
|
| 86 |
+
|
| 87 |
+
def close(self):
|
| 88 |
+
self._env.close()
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@dataclass
|
| 92 |
+
class Args:
|
| 93 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 94 |
+
seed: int = 1
|
| 95 |
+
torch_deterministic: bool = True
|
| 96 |
+
cuda: bool = True
|
| 97 |
+
track: bool = True
|
| 98 |
+
wandb_project_name: str = "2048-RL"
|
| 99 |
+
wandb_entity: str | None = None
|
| 100 |
+
capture_video: bool = False
|
| 101 |
+
|
| 102 |
+
# Algorithm
|
| 103 |
+
env_id: str = "Game2048NoisyDQN"
|
| 104 |
+
total_timesteps: int = 3_000_000
|
| 105 |
+
learning_rate: float = 2.5e-4
|
| 106 |
+
gamma: float = 0.997
|
| 107 |
+
batch_size: int = 256
|
| 108 |
+
buffer_size: int = 300_000
|
| 109 |
+
target_network_frequency: int = 8000
|
| 110 |
+
train_frequency: int = 4
|
| 111 |
+
learning_starts: int = 20_000
|
| 112 |
+
|
| 113 |
+
# Epsilon-greedy (used lightly for warmup; noisy nets handle exploration)
|
| 114 |
+
start_e: float = 1.0
|
| 115 |
+
end_e: float = 0.05
|
| 116 |
+
exploration_fraction: float = 0.8
|
| 117 |
+
|
| 118 |
+
# Model
|
| 119 |
+
dueling: bool = True
|
| 120 |
+
# reward_transform 和 clip 由 Environment Config 控制,此处仅作 Args 占位
|
| 121 |
+
reward_clip_abs: float | None = None
|
| 122 |
+
reward_transform: str = "log2" # choices: "none", "log2"
|
| 123 |
+
|
| 124 |
+
# n-step and PER
|
| 125 |
+
n_step: int = 3
|
| 126 |
+
per_alpha: float = 0.6
|
| 127 |
+
per_beta_start: float = 0.4
|
| 128 |
+
per_beta_frames: int = 1_000_000
|
| 129 |
+
per_eps: float = 1e-6
|
| 130 |
+
|
| 131 |
+
# Env config
|
| 132 |
+
two_prob: float = 0.9
|
| 133 |
+
max_steps_env: int = 1000
|
| 134 |
+
|
| 135 |
+
# Eval config
|
| 136 |
+
eval_splits: int = 1
|
| 137 |
+
eval_episodes: int = 400
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def make_env(run_name: str, seed: int, args: Args, capture_video: bool = False):
|
| 141 |
+
# === Adapt: 开启环境内部 Log Reward ===
|
| 142 |
+
cfg = Game2048EnvConfig(size=4, two_prob=args.two_prob, use_log_reward=True)
|
| 143 |
+
base = Game2048Env(cfg)
|
| 144 |
+
env = Game2048Wrapper(base)
|
| 145 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=args.max_steps_env)
|
| 146 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 147 |
+
if capture_video:
|
| 148 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 149 |
+
return env
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class NoisyLinear(nn.Module):
|
| 153 |
+
def __init__(self, in_features: int, out_features: int, std_init: float = 0.5):
|
| 154 |
+
super().__init__()
|
| 155 |
+
self.in_features = in_features
|
| 156 |
+
self.out_features = out_features
|
| 157 |
+
self.weight_mu = nn.Parameter(torch.empty(out_features, in_features))
|
| 158 |
+
self.weight_sigma = nn.Parameter(torch.empty(out_features, in_features))
|
| 159 |
+
self.register_buffer('weight_epsilon', torch.empty(out_features, in_features))
|
| 160 |
+
self.bias_mu = nn.Parameter(torch.empty(out_features))
|
| 161 |
+
self.bias_sigma = nn.Parameter(torch.empty(out_features))
|
| 162 |
+
self.register_buffer('bias_epsilon', torch.empty(out_features))
|
| 163 |
+
self.std_init = std_init / np.sqrt(in_features)
|
| 164 |
+
self.reset_parameters()
|
| 165 |
+
self.reset_noise()
|
| 166 |
+
|
| 167 |
+
def reset_parameters(self):
|
| 168 |
+
mu_range = 1 / np.sqrt(self.in_features)
|
| 169 |
+
self.weight_mu.data.uniform_(-mu_range, mu_range)
|
| 170 |
+
self.weight_sigma.data.fill_(self.std_init)
|
| 171 |
+
self.bias_mu.data.uniform_(-mu_range, mu_range)
|
| 172 |
+
self.bias_sigma.data.fill_(self.std_init)
|
| 173 |
+
|
| 174 |
+
def reset_noise(self):
|
| 175 |
+
epsilon_in = torch.randn(self.in_features, device=self.weight_mu.device)
|
| 176 |
+
epsilon_out = torch.randn(self.out_features, device=self.weight_mu.device)
|
| 177 |
+
self.weight_epsilon.copy_(epsilon_out.ger(epsilon_in))
|
| 178 |
+
self.bias_epsilon.copy_(epsilon_out)
|
| 179 |
+
|
| 180 |
+
def forward(self, x):
|
| 181 |
+
if self.training:
|
| 182 |
+
w = self.weight_mu + self.weight_sigma * self.weight_epsilon
|
| 183 |
+
b = self.bias_mu + self.bias_sigma * self.bias_epsilon
|
| 184 |
+
else:
|
| 185 |
+
w = self.weight_mu
|
| 186 |
+
b = self.bias_mu
|
| 187 |
+
return torch.nn.functional.linear(x, w, b)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 191 |
+
if isinstance(layer, NoisyLinear):
|
| 192 |
+
nn.init.orthogonal_(layer.weight_mu, std)
|
| 193 |
+
nn.init.constant_(layer.bias_mu, bias_const)
|
| 194 |
+
layer.weight_sigma.data.fill_(layer.std_init)
|
| 195 |
+
layer.bias_sigma.data.fill_(layer.std_init)
|
| 196 |
+
else:
|
| 197 |
+
nn.init.orthogonal_(layer.weight, std)
|
| 198 |
+
nn.init.constant_(layer.bias, bias_const)
|
| 199 |
+
return layer
|
| 200 |
+
|
| 201 |
+
|
| 202 |
+
class QConvNoisy(nn.Module):
|
| 203 |
+
def __init__(self, obs_shape: Tuple[int, int, int], act_dim: int, dueling: bool = True):
|
| 204 |
+
super().__init__()
|
| 205 |
+
c, h, w = obs_shape
|
| 206 |
+
self.dueling = dueling
|
| 207 |
+
self._act_dim = act_dim
|
| 208 |
+
self.features = nn.Sequential(
|
| 209 |
+
layer_init(nn.Conv2d(c, 64, 2, 1, 0)),
|
| 210 |
+
nn.ReLU(),
|
| 211 |
+
layer_init(nn.Conv2d(64, 128, 2, 1, 1)),
|
| 212 |
+
nn.ReLU(),
|
| 213 |
+
layer_init(nn.Conv2d(128, 128, 2, 1, 0)),
|
| 214 |
+
nn.ReLU(),
|
| 215 |
+
nn.Flatten(),
|
| 216 |
+
)
|
| 217 |
+
# compute fc_in via dummy
|
| 218 |
+
with torch.no_grad():
|
| 219 |
+
dummy = torch.zeros(1, c, h, w)
|
| 220 |
+
fc_in = int(self.features(dummy).shape[1])
|
| 221 |
+
if self.dueling:
|
| 222 |
+
self.adv_head = nn.Sequential(
|
| 223 |
+
layer_init(NoisyLinear(fc_in, 512)),
|
| 224 |
+
nn.ReLU(),
|
| 225 |
+
layer_init(NoisyLinear(512, act_dim), std=0.01),
|
| 226 |
+
)
|
| 227 |
+
self.val_head = nn.Sequential(
|
| 228 |
+
layer_init(NoisyLinear(fc_in, 512)),
|
| 229 |
+
nn.ReLU(),
|
| 230 |
+
layer_init(NoisyLinear(512, 1), std=0.01),
|
| 231 |
+
)
|
| 232 |
+
else:
|
| 233 |
+
self.head = nn.Sequential(
|
| 234 |
+
layer_init(NoisyLinear(fc_in, 512)),
|
| 235 |
+
nn.ReLU(),
|
| 236 |
+
layer_init(NoisyLinear(512, act_dim), std=0.01),
|
| 237 |
+
)
|
| 238 |
+
|
| 239 |
+
def reset_noise(self):
|
| 240 |
+
for m in self.modules():
|
| 241 |
+
if isinstance(m, NoisyLinear):
|
| 242 |
+
m.reset_noise()
|
| 243 |
+
|
| 244 |
+
def forward(self, x: torch.Tensor) -> torch.Tensor:
|
| 245 |
+
x = self.features(x)
|
| 246 |
+
if self.dueling:
|
| 247 |
+
adv = self.adv_head(x)
|
| 248 |
+
val = self.val_head(x)
|
| 249 |
+
q = val + adv - adv.mean(dim=1, keepdim=True)
|
| 250 |
+
return q
|
| 251 |
+
else:
|
| 252 |
+
q = self.head(x)
|
| 253 |
+
return q
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
class SumTree:
|
| 257 |
+
def __init__(self, capacity: int):
|
| 258 |
+
self.capacity = 1
|
| 259 |
+
while self.capacity < capacity:
|
| 260 |
+
self.capacity *= 2
|
| 261 |
+
self.tree = np.zeros(2 * self.capacity, dtype=np.float32)
|
| 262 |
+
self.size = 0
|
| 263 |
+
self.ptr = 0
|
| 264 |
+
|
| 265 |
+
def add(self, p: float):
|
| 266 |
+
idx = self.ptr + self.capacity
|
| 267 |
+
self.update(idx, p)
|
| 268 |
+
self.ptr = (self.ptr + 1) % self.capacity
|
| 269 |
+
self.size = min(self.size + 1, self.capacity)
|
| 270 |
+
return idx
|
| 271 |
+
|
| 272 |
+
def update(self, idx: int, p: float):
|
| 273 |
+
change = p - self.tree[idx]
|
| 274 |
+
self.tree[idx] = p
|
| 275 |
+
idx //= 2
|
| 276 |
+
while idx >= 1:
|
| 277 |
+
self.tree[idx] += change
|
| 278 |
+
idx //= 2
|
| 279 |
+
|
| 280 |
+
def total(self) -> float:
|
| 281 |
+
return float(self.tree[1])
|
| 282 |
+
|
| 283 |
+
def get(self, s: float) -> int:
|
| 284 |
+
idx = 1
|
| 285 |
+
while idx < self.capacity:
|
| 286 |
+
left = 2 * idx
|
| 287 |
+
if s <= self.tree[left]:
|
| 288 |
+
idx = left
|
| 289 |
+
else:
|
| 290 |
+
s -= self.tree[left]
|
| 291 |
+
idx = left + 1
|
| 292 |
+
return idx
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
class PrioritizedReplayBuffer:
|
| 296 |
+
def __init__(self, capacity: int, obs_shape: Tuple[int, int, int], alpha: float = 0.6, eps: float = 1e-6):
|
| 297 |
+
self.capacity = capacity
|
| 298 |
+
self.alpha = alpha
|
| 299 |
+
self.eps = eps
|
| 300 |
+
self.tree = SumTree(capacity)
|
| 301 |
+
self.obs_buf = np.zeros((capacity,) + obs_shape, dtype=np.float32)
|
| 302 |
+
self.next_obs_buf = np.zeros((capacity,) + obs_shape, dtype=np.float32)
|
| 303 |
+
self.act_buf = np.zeros((capacity,), dtype=np.int64)
|
| 304 |
+
self.rew_buf = np.zeros((capacity,), dtype=np.float32)
|
| 305 |
+
self.done_buf = np.zeros((capacity,), dtype=np.float32)
|
| 306 |
+
self.max_prio = 1.0
|
| 307 |
+
|
| 308 |
+
def _store_index(self) -> int:
|
| 309 |
+
idx_leaf = self.tree.add(self.max_prio ** self.alpha)
|
| 310 |
+
idx = (idx_leaf - self.tree.capacity) % self.capacity
|
| 311 |
+
return idx, idx_leaf
|
| 312 |
+
|
| 313 |
+
def add(self, obs: np.ndarray, act: int, rew: float, done: bool, next_obs: np.ndarray):
|
| 314 |
+
idx, idx_leaf = self._store_index()
|
| 315 |
+
self.obs_buf[idx] = obs
|
| 316 |
+
self.next_obs_buf[idx] = next_obs
|
| 317 |
+
self.act_buf[idx] = act
|
| 318 |
+
self.rew_buf[idx] = rew
|
| 319 |
+
self.done_buf[idx] = 1.0 if done else 0.0
|
| 320 |
+
return idx_leaf
|
| 321 |
+
|
| 322 |
+
def can_sample(self, batch_size: int) -> bool:
|
| 323 |
+
return self.tree.size >= batch_size
|
| 324 |
+
|
| 325 |
+
def sample(self, batch_size: int, beta: float):
|
| 326 |
+
total_p = self.tree.total()
|
| 327 |
+
if (not np.isfinite(total_p)) or (total_p <= 0.0):
|
| 328 |
+
size = max(1, self.tree.size)
|
| 329 |
+
idxs = np.random.randint(0, size, size=batch_size)
|
| 330 |
+
idx_leaves = (idxs + self.tree.capacity).astype(np.int64)
|
| 331 |
+
weights = np.ones((batch_size,), dtype=np.float32)
|
| 332 |
+
return (
|
| 333 |
+
self.obs_buf[idxs],
|
| 334 |
+
self.act_buf[idxs],
|
| 335 |
+
self.rew_buf[idxs],
|
| 336 |
+
self.done_buf[idxs],
|
| 337 |
+
self.next_obs_buf[idxs],
|
| 338 |
+
idx_leaves,
|
| 339 |
+
weights,
|
| 340 |
+
)
|
| 341 |
+
seg = total_p / float(batch_size)
|
| 342 |
+
idx_leaves = []
|
| 343 |
+
idxs = []
|
| 344 |
+
priorities = []
|
| 345 |
+
for i in range(batch_size):
|
| 346 |
+
a = seg * i
|
| 347 |
+
b = seg * (i + 1)
|
| 348 |
+
s = np.random.uniform(a, b)
|
| 349 |
+
idx_leaf = self.tree.get(s)
|
| 350 |
+
idx = (idx_leaf - self.tree.capacity) % self.capacity
|
| 351 |
+
p = float(self.tree.tree[idx_leaf])
|
| 352 |
+
idx_leaves.append(idx_leaf)
|
| 353 |
+
idxs.append(idx)
|
| 354 |
+
priorities.append(p)
|
| 355 |
+
probs = np.asarray(priorities, dtype=np.float32) / float(total_p)
|
| 356 |
+
probs = np.clip(probs, 1e-12, None)
|
| 357 |
+
weights = (self.tree.size * probs) ** (-beta)
|
| 358 |
+
weights = weights / (weights.max() + 1e-8)
|
| 359 |
+
return (
|
| 360 |
+
self.obs_buf[idxs],
|
| 361 |
+
self.act_buf[idxs],
|
| 362 |
+
self.rew_buf[idxs],
|
| 363 |
+
self.done_buf[idxs],
|
| 364 |
+
self.next_obs_buf[idxs],
|
| 365 |
+
np.asarray(idx_leaves, dtype=np.int64),
|
| 366 |
+
np.asarray(weights, dtype=np.float32),
|
| 367 |
+
)
|
| 368 |
+
|
| 369 |
+
def update_priorities(self, idx_leaves: np.ndarray, td_errors: np.ndarray):
|
| 370 |
+
td = np.abs(td_errors)
|
| 371 |
+
td = np.where(np.isfinite(td), td, self.eps)
|
| 372 |
+
td = np.clip(td + self.eps, self.eps, 1e3)
|
| 373 |
+
self.max_prio = max(self.max_prio, float(td.max()))
|
| 374 |
+
for idx_leaf, p in zip(idx_leaves, td):
|
| 375 |
+
self.tree.update(int(idx_leaf), float(p) ** self.alpha)
|
| 376 |
+
|
| 377 |
+
|
| 378 |
+
class NStepBuffer:
|
| 379 |
+
def __init__(self, n: int, gamma: float):
|
| 380 |
+
self.n = int(max(1, n))
|
| 381 |
+
self.gamma = float(gamma)
|
| 382 |
+
self.states = []
|
| 383 |
+
self.actions = []
|
| 384 |
+
self.rewards = []
|
| 385 |
+
self.dones = []
|
| 386 |
+
self.next_states = []
|
| 387 |
+
|
| 388 |
+
def push(self, s, a, r, d, next_s):
|
| 389 |
+
self.states.append(s)
|
| 390 |
+
self.actions.append(a)
|
| 391 |
+
self.rewards.append(r)
|
| 392 |
+
self.dones.append(d)
|
| 393 |
+
self.next_states.append(next_s)
|
| 394 |
+
if len(self.states) >= self.n:
|
| 395 |
+
return self._pop()
|
| 396 |
+
return None
|
| 397 |
+
|
| 398 |
+
def _pop(self):
|
| 399 |
+
m = min(self.n, len(self.states))
|
| 400 |
+
R = 0.0
|
| 401 |
+
cut = m
|
| 402 |
+
for i in range(m):
|
| 403 |
+
R += (self.gamma ** i) * self.rewards[i]
|
| 404 |
+
if self.dones[i]:
|
| 405 |
+
cut = i + 1
|
| 406 |
+
break
|
| 407 |
+
s0 = self.states[0]
|
| 408 |
+
a0 = self.actions[0]
|
| 409 |
+
dN = any(self.dones[: cut])
|
| 410 |
+
last_idx = cut - 1
|
| 411 |
+
sN = self.next_states[last_idx]
|
| 412 |
+
self.states.pop(0)
|
| 413 |
+
self.actions.pop(0)
|
| 414 |
+
self.rewards.pop(0)
|
| 415 |
+
self.dones.pop(0)
|
| 416 |
+
self.next_states.pop(0)
|
| 417 |
+
return s0, a0, R, dN, sN
|
| 418 |
+
|
| 419 |
+
def flush(self):
|
| 420 |
+
out = []
|
| 421 |
+
while len(self.states) > 0:
|
| 422 |
+
out_tr = self._pop()
|
| 423 |
+
if out_tr is not None:
|
| 424 |
+
out.append(out_tr)
|
| 425 |
+
return out
|
| 426 |
+
|
| 427 |
+
|
| 428 |
+
if __name__ == "__main__":
|
| 429 |
+
args = tyro.cli(Args)
|
| 430 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 431 |
+
|
| 432 |
+
if args.track:
|
| 433 |
+
import wandb
|
| 434 |
+
wandb.init(
|
| 435 |
+
project=args.wandb_project_name,
|
| 436 |
+
entity=args.wandb_entity,
|
| 437 |
+
config=vars(args),
|
| 438 |
+
name=run_name,
|
| 439 |
+
monitor_gym=True,
|
| 440 |
+
save_code=True,
|
| 441 |
+
)
|
| 442 |
+
try:
|
| 443 |
+
wandb.define_metric("global_step")
|
| 444 |
+
for prefix in ["train/*", "rollout/*", "eval/*", "losses/*", "charts/*", "perf/*"]:
|
| 445 |
+
wandb.define_metric(prefix, step_metric="global_step")
|
| 446 |
+
except Exception:
|
| 447 |
+
pass
|
| 448 |
+
|
| 449 |
+
random.seed(args.seed)
|
| 450 |
+
np.random.seed(args.seed)
|
| 451 |
+
torch.manual_seed(args.seed)
|
| 452 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 453 |
+
|
| 454 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 455 |
+
|
| 456 |
+
env = make_env(run_name, args.seed, args, args.capture_video)
|
| 457 |
+
obs_shape = env.observation_space.shape
|
| 458 |
+
act_dim = env.action_space.n
|
| 459 |
+
|
| 460 |
+
policy_net = QConvNoisy(obs_shape, act_dim, dueling=args.dueling).to(device)
|
| 461 |
+
target_net = QConvNoisy(obs_shape, act_dim, dueling=args.dueling).to(device)
|
| 462 |
+
target_net.load_state_dict(policy_net.state_dict())
|
| 463 |
+
target_net.eval()
|
| 464 |
+
|
| 465 |
+
optimizer = optim.Adam(policy_net.parameters(), lr=args.learning_rate)
|
| 466 |
+
|
| 467 |
+
rb = PrioritizedReplayBuffer(args.buffer_size, obs_shape, alpha=args.per_alpha, eps=args.per_eps)
|
| 468 |
+
nbuf = NStepBuffer(args.n_step, args.gamma)
|
| 469 |
+
|
| 470 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes: int, step_tag: int):
|
| 471 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 472 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 473 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 474 |
+
env_eval = make_env_fn()
|
| 475 |
+
collected = 0
|
| 476 |
+
summary_returns = []
|
| 477 |
+
summary_success = []
|
| 478 |
+
with out_path.open("w") as f:
|
| 479 |
+
while collected < n_episodes:
|
| 480 |
+
state, info = env_eval.reset(seed=args.seed + 100000 + collected)
|
| 481 |
+
current_info = info or {}
|
| 482 |
+
traj_states = [np.asarray(state).tolist()]
|
| 483 |
+
traj_actions = []
|
| 484 |
+
traj_rewards = []
|
| 485 |
+
traj_dones = []
|
| 486 |
+
traj_success = []
|
| 487 |
+
done = False
|
| 488 |
+
step_count = 0
|
| 489 |
+
max_eval_steps = getattr(env_eval, '_max_episode_steps', None) or args.max_steps_env
|
| 490 |
+
while not done:
|
| 491 |
+
with torch.no_grad():
|
| 492 |
+
q = agent_model(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 493 |
+
mask_np = current_info.get('action_mask', np.ones(act_dim, dtype=bool))
|
| 494 |
+
mask = torch.tensor(mask_np, device=device, dtype=torch.bool).unsqueeze(0)
|
| 495 |
+
masked_q = torch.where(mask, q, torch.full_like(q, -1e9))
|
| 496 |
+
action = int(torch.argmax(masked_q, dim=1).item())
|
| 497 |
+
next_state, reward, terminated, truncated, info = env_eval.step(action)
|
| 498 |
+
traj_actions.append(int(action))
|
| 499 |
+
|
| 500 |
+
# === Adapt: 使用 Raw Reward (Pre-regularization) ===
|
| 501 |
+
# 确保 Eval 阶段记录的是原始分数
|
| 502 |
+
raw_r = info.get('raw_reward', reward) if info else reward
|
| 503 |
+
traj_rewards.append(float(raw_r))
|
| 504 |
+
|
| 505 |
+
step_count += 1
|
| 506 |
+
d = bool(terminated) or bool(truncated) or (step_count >= max_eval_steps)
|
| 507 |
+
traj_dones.append(d)
|
| 508 |
+
traj_success.append(bool((info or {}).get('success', False)))
|
| 509 |
+
state = next_state
|
| 510 |
+
current_info = info or {}
|
| 511 |
+
traj_states.append(np.asarray(state).tolist())
|
| 512 |
+
done = d
|
| 513 |
+
ep_ret = float(sum(traj_rewards))
|
| 514 |
+
ep_succ = bool(any(traj_success))
|
| 515 |
+
record = {
|
| 516 |
+
"states": traj_states,
|
| 517 |
+
"actions": traj_actions,
|
| 518 |
+
"rewards": traj_rewards,
|
| 519 |
+
"dones": traj_dones,
|
| 520 |
+
"success": traj_success,
|
| 521 |
+
"episode_return": ep_ret,
|
| 522 |
+
"episode_success": ep_succ,
|
| 523 |
+
}
|
| 524 |
+
f.write(json.dumps(record) + "\n")
|
| 525 |
+
collected += 1
|
| 526 |
+
summary_returns.append(ep_ret)
|
| 527 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 528 |
+
env_eval.close()
|
| 529 |
+
try:
|
| 530 |
+
metrics = {
|
| 531 |
+
"global_step": int(step_tag),
|
| 532 |
+
"episodes": int(n_episodes),
|
| 533 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 534 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 535 |
+
"std_return": float(np.std(summary_returns)) if len(summary_returns) else 0.0,
|
| 536 |
+
}
|
| 537 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 538 |
+
json.dump(metrics, mf)
|
| 539 |
+
except Exception as e:
|
| 540 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 541 |
+
|
| 542 |
+
exploration_steps = max(1, int(args.exploration_fraction * args.total_timesteps))
|
| 543 |
+
|
| 544 |
+
def epsilon_by_step(t: int):
|
| 545 |
+
return args.end_e + (args.start_e - args.end_e) * max(0.0, (exploration_steps - t) / exploration_steps)
|
| 546 |
+
|
| 547 |
+
global_step = 0
|
| 548 |
+
start_time = time.time()
|
| 549 |
+
|
| 550 |
+
obs, info = env.reset(seed=args.seed)
|
| 551 |
+
current_info = info or {}
|
| 552 |
+
ep_return = 0.0
|
| 553 |
+
ep_len = 0
|
| 554 |
+
ep_success_window = deque(maxlen=100)
|
| 555 |
+
ep_return_window = deque(maxlen=100)
|
| 556 |
+
step_reward_window = deque(maxlen=2048)
|
| 557 |
+
|
| 558 |
+
eval_every_steps = max(1, args.total_timesteps // args.eval_splits)
|
| 559 |
+
|
| 560 |
+
while global_step < args.total_timesteps:
|
| 561 |
+
epsilon = epsilon_by_step(global_step)
|
| 562 |
+
with torch.no_grad():
|
| 563 |
+
q_values = policy_net(torch.tensor(obs, dtype=torch.float32, device=device).unsqueeze(0))
|
| 564 |
+
mask_np = current_info.get('action_mask', np.ones(act_dim, dtype=bool))
|
| 565 |
+
mask = torch.tensor(mask_np, device=device, dtype=torch.bool).unsqueeze(0)
|
| 566 |
+
masked_q = torch.where(mask, q_values, torch.full_like(q_values, -1e9))
|
| 567 |
+
action_greedy = int(torch.argmax(masked_q, dim=1).item())
|
| 568 |
+
if (global_step < args.learning_starts) and (np.random.rand() < 0.5):
|
| 569 |
+
valid = np.where(mask_np)[0]
|
| 570 |
+
if len(valid) > 0:
|
| 571 |
+
action = int(np.random.choice(valid))
|
| 572 |
+
else:
|
| 573 |
+
action = int(np.random.randint(0, act_dim))
|
| 574 |
+
else:
|
| 575 |
+
action = action_greedy
|
| 576 |
+
|
| 577 |
+
next_obs, reward, terminated, truncated, info = env.step(action)
|
| 578 |
+
done = bool(terminated) or bool(truncated)
|
| 579 |
+
|
| 580 |
+
# === Adapt: 移除手动正则化,直接使用 Env 返回的 reward ===
|
| 581 |
+
r = float(reward)
|
| 582 |
+
# (已删除原有的 if/elif 手动 log2/clip 逻辑,防止双重 log)
|
| 583 |
+
|
| 584 |
+
n_out = nbuf.push(obs.astype(np.float32), int(action), float(r), bool(done), next_obs.astype(np.float32))
|
| 585 |
+
if n_out is not None:
|
| 586 |
+
s0, a0, Rn, dN, sN = n_out
|
| 587 |
+
rb.add(s0, a0, Rn, dN, sN)
|
| 588 |
+
|
| 589 |
+
obs = next_obs
|
| 590 |
+
current_info = info or {}
|
| 591 |
+
|
| 592 |
+
# === Adapt: 记录 Raw Score (来自 info) ===
|
| 593 |
+
raw_r = float(info.get('raw_reward', reward))
|
| 594 |
+
ep_return += raw_r
|
| 595 |
+
|
| 596 |
+
try:
|
| 597 |
+
step_reward_window.append(float(reward)) # Keep tracking training reward stability
|
| 598 |
+
except Exception:
|
| 599 |
+
pass
|
| 600 |
+
ep_len += 1
|
| 601 |
+
global_step += 1
|
| 602 |
+
|
| 603 |
+
if (global_step > args.learning_starts) and rb.can_sample(args.batch_size) and (global_step % args.train_frequency == 0):
|
| 604 |
+
frac = min(1.0, global_step / float(max(1, args.per_beta_frames)))
|
| 605 |
+
beta = args.per_beta_start + (1.0 - args.per_beta_start) * frac
|
| 606 |
+
|
| 607 |
+
batch_obs, batch_act, batch_rew, batch_done, batch_next_obs, idx_leaves, weights = rb.sample(args.batch_size, beta)
|
| 608 |
+
b_obs = torch.tensor(batch_obs, dtype=torch.float32, device=device)
|
| 609 |
+
b_act = torch.tensor(batch_act, dtype=torch.int64, device=device)
|
| 610 |
+
b_rew = torch.tensor(batch_rew, dtype=torch.float32, device=device)
|
| 611 |
+
b_done = torch.tensor(batch_done, dtype=torch.float32, device=device)
|
| 612 |
+
b_next_obs = torch.tensor(batch_next_obs, dtype=torch.float32, device=device)
|
| 613 |
+
b_w = torch.tensor(weights, dtype=torch.float32, device=device)
|
| 614 |
+
|
| 615 |
+
with torch.no_grad():
|
| 616 |
+
next_actions = policy_net(b_next_obs).argmax(dim=1)
|
| 617 |
+
next_q = target_net(b_next_obs).gather(1, next_actions.view(-1, 1)).squeeze(1)
|
| 618 |
+
target_q = b_rew + (args.gamma ** args.n_step) * (1.0 - b_done) * next_q
|
| 619 |
+
|
| 620 |
+
current_q = policy_net(b_obs).gather(1, b_act.view(-1, 1)).squeeze(1)
|
| 621 |
+
td_error = target_q - current_q
|
| 622 |
+
per_loss = torch.abs(td_error).detach().cpu().numpy()
|
| 623 |
+
loss_unreduced = torch.nn.functional.smooth_l1_loss(current_q, target_q, reduction='none')
|
| 624 |
+
loss = (b_w * loss_unreduced).mean()
|
| 625 |
+
|
| 626 |
+
optimizer.zero_grad()
|
| 627 |
+
loss.backward()
|
| 628 |
+
nn.utils.clip_grad_norm_(policy_net.parameters(), max_norm=10.0)
|
| 629 |
+
optimizer.step()
|
| 630 |
+
|
| 631 |
+
policy_net.reset_noise()
|
| 632 |
+
target_net.reset_noise()
|
| 633 |
+
|
| 634 |
+
rb.update_priorities(idx_leaves, td_error.detach().cpu().numpy())
|
| 635 |
+
|
| 636 |
+
if args.track:
|
| 637 |
+
try:
|
| 638 |
+
import wandb
|
| 639 |
+
# compute PPO-compatible metrics (use None where N/A)
|
| 640 |
+
try:
|
| 641 |
+
avg_reward_val = float(np.mean(step_reward_window)) if len(step_reward_window) > 0 else 0.0
|
| 642 |
+
except Exception:
|
| 643 |
+
avg_reward_val = 0.0
|
| 644 |
+
wandb.log({
|
| 645 |
+
"global_step": int(global_step),
|
| 646 |
+
"train/loss": float(loss.item()),
|
| 647 |
+
# PPO-compatible keys below (None when not applicable to DQN)
|
| 648 |
+
"train/value_loss": None,
|
| 649 |
+
"train/policy_loss": None,
|
| 650 |
+
"train/entropy": None,
|
| 651 |
+
"losses/explained_variance": None,
|
| 652 |
+
"charts/avg_reward": avg_reward_val,
|
| 653 |
+
"charts/avg_value": None,
|
| 654 |
+
"train/learning_rate": float(optimizer.param_groups[0]["lr"]),
|
| 655 |
+
"charts/epsilon": float(epsilon),
|
| 656 |
+
"perf/SPS": int(global_step / (time.time() - start_time)),
|
| 657 |
+
}, step=global_step)
|
| 658 |
+
except Exception:
|
| 659 |
+
pass
|
| 660 |
+
|
| 661 |
+
if global_step % args.target_network_frequency == 0:
|
| 662 |
+
target_net.load_state_dict(policy_net.state_dict())
|
| 663 |
+
|
| 664 |
+
if done:
|
| 665 |
+
succ = bool((info or {}).get('success', False))
|
| 666 |
+
max_tile = int((info or {}).get('max_tile', 0))
|
| 667 |
+
ep_success_window.append(1.0 if succ else 0.0)
|
| 668 |
+
ep_return_window.append(float(ep_return))
|
| 669 |
+
for out_tr in nbuf.flush():
|
| 670 |
+
s0, a0, Rn, dN, sN = out_tr
|
| 671 |
+
rb.add(s0, a0, Rn, dN, sN)
|
| 672 |
+
# print per-episode process metrics (match PPO format)
|
| 673 |
+
try:
|
| 674 |
+
if max_tile is not None:
|
| 675 |
+
print(f"global_step={global_step}, episodic_return={ep_return:.1f}, length={ep_len}, max_tile={int(max_tile)}, success={succ}")
|
| 676 |
+
else:
|
| 677 |
+
print(f"global_step={global_step}, episodic_return={ep_return:.1f}, length={ep_len}, success={succ}")
|
| 678 |
+
except Exception:
|
| 679 |
+
pass
|
| 680 |
+
if args.track:
|
| 681 |
+
try:
|
| 682 |
+
import wandb
|
| 683 |
+
# average episode return over recent 100 episodes
|
| 684 |
+
try:
|
| 685 |
+
avg_ep_ret = float(np.mean(ep_return_window)) if len(ep_return_window) > 0 else 0.0
|
| 686 |
+
except Exception:
|
| 687 |
+
avg_ep_ret = float(ep_return)
|
| 688 |
+
wandb.log({
|
| 689 |
+
"global_step": int(global_step),
|
| 690 |
+
"rollout/episodic_return": float(ep_return),
|
| 691 |
+
"rollout/episodic_length": int(ep_len),
|
| 692 |
+
"rollout/success": float(1.0 if succ else 0.0),
|
| 693 |
+
"rollout/max_tile": int(max_tile),
|
| 694 |
+
"rollout/success_rate_100": float(np.mean(ep_success_window)) if len(ep_success_window) > 0 else None,
|
| 695 |
+
# mirror PPO charts/* keys
|
| 696 |
+
"charts/episodic_return": float(ep_return),
|
| 697 |
+
"charts/episodic_length": int(ep_len),
|
| 698 |
+
"charts/success": float(1.0 if succ else 0.0),
|
| 699 |
+
"charts/max_tile": int(max_tile),
|
| 700 |
+
"charts/avg_episode_return": avg_ep_ret,
|
| 701 |
+
}, step=global_step)
|
| 702 |
+
except Exception:
|
| 703 |
+
pass
|
| 704 |
+
obs, info = env.reset()
|
| 705 |
+
current_info = info or {}
|
| 706 |
+
ep_return, ep_len = 0.0, 0
|
| 707 |
+
|
| 708 |
+
if global_step % 1000 == 0:
|
| 709 |
+
sps = int(global_step / (time.time() - start_time))
|
| 710 |
+
sr100 = float(np.mean(ep_success_window)) if len(ep_success_window) > 0 else 0.0
|
| 711 |
+
print(f"Step {global_step} | SPS: {sps} | Epsilon: {epsilon:.3f} | SR@100: {sr100:.3f}")
|
| 712 |
+
|
| 713 |
+
if (global_step % eval_every_steps == 0):
|
| 714 |
+
try:
|
| 715 |
+
def eval_thunk():
|
| 716 |
+
return make_env(run_name, args.seed + 9999, args, False)
|
| 717 |
+
collect_eval_trajectories(policy_net, eval_thunk, n_episodes=args.eval_episodes, step_tag=global_step)
|
| 718 |
+
if args.track:
|
| 719 |
+
try:
|
| 720 |
+
import wandb
|
| 721 |
+
mpath = Path(f"runs/{run_name}/trajectories/step_{global_step}/metrics.json")
|
| 722 |
+
if mpath.exists():
|
| 723 |
+
with mpath.open("r") as mf:
|
| 724 |
+
metrics = json.load(mf)
|
| 725 |
+
wandb.log({
|
| 726 |
+
"eval/success_rate": metrics.get("success_rate"),
|
| 727 |
+
"eval/avg_return": metrics.get("avg_return"),
|
| 728 |
+
"eval/std_return": metrics.get("std_return"),
|
| 729 |
+
"eval/episodes": metrics.get("episodes"),
|
| 730 |
+
}, step=global_step)
|
| 731 |
+
except Exception:
|
| 732 |
+
pass
|
| 733 |
+
print(f"Collected {args.eval_episodes} eval trajectories at step {global_step}")
|
| 734 |
+
except Exception as e:
|
| 735 |
+
print(f"Warning: eval trajectory collection failed at step {global_step}: {e}")
|
| 736 |
+
|
| 737 |
+
env.close()
|
cleanrl/cleanrl/scout_ppo/ppo_frozenlake_nochangeenv.py
ADDED
|
@@ -0,0 +1,494 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO with small MLP for RAGEN FrozenLake using the existing env (no env edits)
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from pathlib import Path
|
| 7 |
+
from typing import Tuple, Dict, Any
|
| 8 |
+
import json
|
| 9 |
+
|
| 10 |
+
import gymnasium as gym
|
| 11 |
+
import numpy as np
|
| 12 |
+
import torch
|
| 13 |
+
import torch.nn as nn
|
| 14 |
+
import torch.optim as optim
|
| 15 |
+
import tyro
|
| 16 |
+
from torch.distributions.categorical import Categorical
|
| 17 |
+
|
| 18 |
+
import sys
|
| 19 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 20 |
+
|
| 21 |
+
from ragen.env.frozen_lake.env import FrozenLakeEnv
|
| 22 |
+
from ragen.env.frozen_lake.config import FrozenLakeEnvConfig
|
| 23 |
+
|
| 24 |
+
# python /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_frozenlake_nochangeenv.py --total-timesteps 2000000 --num-envs 8 --num-steps 128 --grid-size 4 --is-slippery --track
|
| 25 |
+
class FrozenLakeWrapper(gym.Env):
|
| 26 |
+
"""
|
| 27 |
+
Adapter to use ragen FrozenLakeEnv with Gymnasium vector API.
|
| 28 |
+
- Converts text observation to one-hot grid vector (6 tokens per cell).
|
| 29 |
+
- Maps agent actions [0..3] to env actions [1..4].
|
| 30 |
+
- Exposes proper observation_space and action_space.
|
| 31 |
+
"""
|
| 32 |
+
metadata = {"render_modes": ["rgb_array", "human", "ansi"]}
|
| 33 |
+
|
| 34 |
+
def __init__(self, env: FrozenLakeEnv):
|
| 35 |
+
super().__init__()
|
| 36 |
+
self._env = env
|
| 37 |
+
self._size = int(self._env.nrow) # square grid
|
| 38 |
+
self._tokens = ['P', '_', 'O', 'G', 'X', '√']
|
| 39 |
+
self._token_to_idx = {t: i for i, t in enumerate(self._tokens)}
|
| 40 |
+
self.observation_space = gym.spaces.Box(low=0.0, high=1.0, shape=(self._size * self._size * len(self._tokens),), dtype=np.float32)
|
| 41 |
+
self.action_space = gym.spaces.Discrete(4)
|
| 42 |
+
|
| 43 |
+
def _encode_obs(self, text_obs: str) -> np.ndarray:
|
| 44 |
+
# text_obs is multi-line grid with tokens above
|
| 45 |
+
rows = text_obs.split('\n')
|
| 46 |
+
# handle any accidental extra whitespace
|
| 47 |
+
rows = [list(r) for r in rows if len(r) > 0]
|
| 48 |
+
h = len(rows)
|
| 49 |
+
w = len(rows[0]) if h > 0 else self._size
|
| 50 |
+
grid = np.zeros((h, w, len(self._tokens)), dtype=np.float32)
|
| 51 |
+
for i in range(h):
|
| 52 |
+
for j in range(w):
|
| 53 |
+
ch = rows[i][j]
|
| 54 |
+
idx = self._token_to_idx.get(ch, 0)
|
| 55 |
+
grid[i, j, idx] = 1.0
|
| 56 |
+
return grid.reshape(-1)
|
| 57 |
+
|
| 58 |
+
def reset(self, *, seed: int | None = None, options: Dict[str, Any] | None = None):
|
| 59 |
+
text_obs = self._env.reset(seed=seed)
|
| 60 |
+
obs = self._encode_obs(text_obs)
|
| 61 |
+
return obs, {}
|
| 62 |
+
|
| 63 |
+
def step(self, action: int):
|
| 64 |
+
# map 0..3 -> 1..4 for the underlying env
|
| 65 |
+
mapped = int(action) + 1
|
| 66 |
+
text_obs, reward, done, info = self._env.step(mapped)
|
| 67 |
+
obs = self._encode_obs(text_obs)
|
| 68 |
+
terminated = bool(done)
|
| 69 |
+
truncated = False
|
| 70 |
+
# propagate success if present
|
| 71 |
+
return obs, float(reward), terminated, truncated, info or {}
|
| 72 |
+
|
| 73 |
+
def render(self):
|
| 74 |
+
return self._env.render()
|
| 75 |
+
|
| 76 |
+
def close(self):
|
| 77 |
+
self._env.close()
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
@dataclass
|
| 81 |
+
class Args:
|
| 82 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 83 |
+
seed: int = 1
|
| 84 |
+
torch_deterministic: bool = True
|
| 85 |
+
cuda: bool = True
|
| 86 |
+
track: bool = True
|
| 87 |
+
wandb_project_name: str = "cleanRL"
|
| 88 |
+
wandb_entity: str | None = None
|
| 89 |
+
capture_video: bool = False
|
| 90 |
+
|
| 91 |
+
# Algorithm
|
| 92 |
+
env_id: str = "FrozenLake"
|
| 93 |
+
total_timesteps: int = 200_000
|
| 94 |
+
learning_rate: float = 2.5e-4
|
| 95 |
+
num_envs: int = 8
|
| 96 |
+
num_steps: int = 128
|
| 97 |
+
anneal_lr: bool = True
|
| 98 |
+
gamma: float = 0.99
|
| 99 |
+
gae_lambda: float = 0.95
|
| 100 |
+
num_minibatches: int = 4
|
| 101 |
+
update_epochs: int = 4
|
| 102 |
+
norm_adv: bool = True
|
| 103 |
+
clip_coef: float = 0.2
|
| 104 |
+
clip_vloss: bool = True
|
| 105 |
+
ent_coef: float = 0.01
|
| 106 |
+
vf_coef: float = 0.5
|
| 107 |
+
max_grad_norm: float = 0.5
|
| 108 |
+
target_kl: float | None = None
|
| 109 |
+
|
| 110 |
+
# FrozenLake specific
|
| 111 |
+
grid_size: int = 4
|
| 112 |
+
is_slippery: bool = True
|
| 113 |
+
|
| 114 |
+
# runtime filled
|
| 115 |
+
batch_size: int = 0
|
| 116 |
+
minibatch_size: int = 0
|
| 117 |
+
num_iterations: int = 0
|
| 118 |
+
# eval config to mirror reference script
|
| 119 |
+
eval_splits: int = 2
|
| 120 |
+
eval_episodes: int = 4
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def make_env(idx, run_name, seed, grid_size, is_slippery, capture_video=False):
|
| 124 |
+
def thunk():
|
| 125 |
+
config = FrozenLakeEnvConfig(size=grid_size, p=0.9, success_rate = 0.8, is_slippery=is_slippery, map_seed=seed + idx, render_mode='text')
|
| 126 |
+
# import pdb;pdb.set_trace()
|
| 127 |
+
env = FrozenLakeEnv(config)
|
| 128 |
+
env = FrozenLakeWrapper(env)
|
| 129 |
+
max_steps = int(grid_size * grid_size * 4)
|
| 130 |
+
env = gym.wrappers.TimeLimit(env, max_episode_steps=max_steps)
|
| 131 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 132 |
+
if capture_video and idx == 0:
|
| 133 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 134 |
+
return env
|
| 135 |
+
return thunk
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 139 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 140 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 141 |
+
return layer
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
class Agent(nn.Module):
|
| 145 |
+
def __init__(self, envs):
|
| 146 |
+
super().__init__()
|
| 147 |
+
obs_shape = int(np.array(envs.single_observation_space.shape).prod())
|
| 148 |
+
hidden = 64
|
| 149 |
+
self.critic = nn.Sequential(
|
| 150 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 151 |
+
nn.Tanh(),
|
| 152 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 153 |
+
nn.Tanh(),
|
| 154 |
+
layer_init(nn.Linear(hidden, 1), std=1.0),
|
| 155 |
+
)
|
| 156 |
+
self.actor = nn.Sequential(
|
| 157 |
+
layer_init(nn.Linear(obs_shape, hidden)),
|
| 158 |
+
nn.Tanh(),
|
| 159 |
+
layer_init(nn.Linear(hidden, hidden)),
|
| 160 |
+
nn.Tanh(),
|
| 161 |
+
layer_init(nn.Linear(hidden, envs.single_action_space.n), std=0.01),
|
| 162 |
+
)
|
| 163 |
+
|
| 164 |
+
def get_value(self, x):
|
| 165 |
+
return self.critic(x)
|
| 166 |
+
|
| 167 |
+
def get_action_and_value(self, x, action=None):
|
| 168 |
+
logits = self.actor(x)
|
| 169 |
+
probs = Categorical(logits=logits)
|
| 170 |
+
if action is None:
|
| 171 |
+
action = probs.sample()
|
| 172 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
args = tyro.cli(Args)
|
| 177 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 178 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 179 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 180 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 181 |
+
|
| 182 |
+
if args.track:
|
| 183 |
+
import wandb
|
| 184 |
+
wandb.init(
|
| 185 |
+
project=args.wandb_project_name,
|
| 186 |
+
entity=args.wandb_entity,
|
| 187 |
+
config=vars(args),
|
| 188 |
+
name=run_name,
|
| 189 |
+
monitor_gym=True,
|
| 190 |
+
save_code=True,
|
| 191 |
+
)
|
| 192 |
+
try:
|
| 193 |
+
wandb.define_metric("global_step")
|
| 194 |
+
for prefix in ["train/*", "rollout/*", "eval/*", "losses/*", "charts/*", "perf/*"]:
|
| 195 |
+
wandb.define_metric(prefix, step_metric="global_step")
|
| 196 |
+
except Exception:
|
| 197 |
+
pass
|
| 198 |
+
|
| 199 |
+
# seeding
|
| 200 |
+
random.seed(args.seed)
|
| 201 |
+
np.random.seed(args.seed)
|
| 202 |
+
torch.manual_seed(args.seed)
|
| 203 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 204 |
+
|
| 205 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 206 |
+
|
| 207 |
+
# envs
|
| 208 |
+
envs = gym.vector.SyncVectorEnv([
|
| 209 |
+
make_env(i, run_name, args.seed, args.grid_size, args.is_slippery, args.capture_video)
|
| 210 |
+
for i in range(args.num_envs)
|
| 211 |
+
])
|
| 212 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete)
|
| 213 |
+
|
| 214 |
+
agent = Agent(envs).to(device)
|
| 215 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 216 |
+
|
| 217 |
+
# storage
|
| 218 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 219 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 220 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 221 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 222 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 223 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 224 |
+
|
| 225 |
+
# start
|
| 226 |
+
global_step = 0
|
| 227 |
+
start_time = time.time()
|
| 228 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 229 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 230 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 231 |
+
|
| 232 |
+
episode_returns = []
|
| 233 |
+
episode_steps = []
|
| 234 |
+
episode_successes = []
|
| 235 |
+
|
| 236 |
+
# Eval helper identical to reference
|
| 237 |
+
def collect_eval_trajectories(agent_model, make_env_fn, n_episodes, step_tag):
|
| 238 |
+
out_dir = Path(f"runs/{run_name}/trajectories/step_{step_tag}")
|
| 239 |
+
out_dir.mkdir(parents=True, exist_ok=True)
|
| 240 |
+
out_path = out_dir / "trajectories.jsonl"
|
| 241 |
+
env = make_env_fn()
|
| 242 |
+
collected = 0
|
| 243 |
+
summary_returns = []
|
| 244 |
+
summary_success = []
|
| 245 |
+
with out_path.open("w") as f:
|
| 246 |
+
while collected < n_episodes:
|
| 247 |
+
state, _ = env.reset(seed=args.seed + 100000 + collected)
|
| 248 |
+
traj_states = [state.tolist()]
|
| 249 |
+
traj_actions = []
|
| 250 |
+
traj_rewards = []
|
| 251 |
+
traj_dones = []
|
| 252 |
+
traj_success = []
|
| 253 |
+
done = False
|
| 254 |
+
step_count = 0
|
| 255 |
+
max_eval_steps = getattr(env, '_max_episode_steps', None) or int(args.grid_size * args.grid_size * 4)
|
| 256 |
+
while not done:
|
| 257 |
+
with torch.no_grad():
|
| 258 |
+
logits = agent_model.actor(torch.tensor(state, dtype=torch.float32, device=device).unsqueeze(0))
|
| 259 |
+
action = int(torch.argmax(logits, dim=1).item())
|
| 260 |
+
next_state, reward, terminated, truncated, info = env.step(action)
|
| 261 |
+
traj_actions.append(int(action))
|
| 262 |
+
traj_rewards.append(float(reward))
|
| 263 |
+
step_count += 1
|
| 264 |
+
d = bool(terminated) or bool(truncated) or (step_count >= max_eval_steps)
|
| 265 |
+
traj_dones.append(d)
|
| 266 |
+
traj_success.append(bool(info.get('success', False)))
|
| 267 |
+
state = next_state
|
| 268 |
+
traj_states.append(state.tolist())
|
| 269 |
+
done = d
|
| 270 |
+
ep_ret = float(sum(traj_rewards))
|
| 271 |
+
ep_succ = bool(any(traj_success))
|
| 272 |
+
record = {
|
| 273 |
+
"states": traj_states,
|
| 274 |
+
"actions": traj_actions,
|
| 275 |
+
"rewards": traj_rewards,
|
| 276 |
+
"dones": traj_dones,
|
| 277 |
+
"success": traj_success,
|
| 278 |
+
"episode_return": ep_ret,
|
| 279 |
+
"episode_success": ep_succ,
|
| 280 |
+
}
|
| 281 |
+
f.write(json.dumps(record) + "\n")
|
| 282 |
+
collected += 1
|
| 283 |
+
summary_returns.append(ep_ret)
|
| 284 |
+
summary_success.append(1.0 if ep_succ else 0.0)
|
| 285 |
+
env.close()
|
| 286 |
+
try:
|
| 287 |
+
metrics = {
|
| 288 |
+
"global_step": int(step_tag),
|
| 289 |
+
"episodes": int(n_episodes),
|
| 290 |
+
"success_rate": float(np.mean(summary_success)) if len(summary_success) else 0.0,
|
| 291 |
+
"avg_return": float(np.mean(summary_returns)) if len(summary_returns) else 0.0,
|
| 292 |
+
"std_return": float(np.std(summary_returns)) if len(summary_returns) else 0.0,
|
| 293 |
+
}
|
| 294 |
+
with (out_dir / "metrics.json").open("w") as mf:
|
| 295 |
+
json.dump(metrics, mf)
|
| 296 |
+
except Exception as e:
|
| 297 |
+
print(f"Warning: failed to write eval metrics: {e}")
|
| 298 |
+
|
| 299 |
+
eval_every_iters = max(1, args.num_iterations // args.eval_splits)
|
| 300 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 301 |
+
# Anneal LR
|
| 302 |
+
if args.anneal_lr:
|
| 303 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 304 |
+
lrnow = frac * args.learning_rate
|
| 305 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 306 |
+
|
| 307 |
+
for step in range(0, args.num_steps):
|
| 308 |
+
global_step += args.num_envs
|
| 309 |
+
obs[step] = next_obs
|
| 310 |
+
dones[step] = next_done
|
| 311 |
+
|
| 312 |
+
with torch.no_grad():
|
| 313 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 314 |
+
values[step] = value.flatten()
|
| 315 |
+
actions[step] = action
|
| 316 |
+
logprobs[step] = logprob
|
| 317 |
+
|
| 318 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 319 |
+
next_done = np.logical_or(terminations, truncations)
|
| 320 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 321 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 322 |
+
# Episode stats logging as in reference
|
| 323 |
+
try:
|
| 324 |
+
mask = None
|
| 325 |
+
if isinstance(infos, dict):
|
| 326 |
+
if "_episode" in infos:
|
| 327 |
+
mask = np.asarray(infos["_episode"]).astype(bool)
|
| 328 |
+
elif "episode" in infos and isinstance(infos["episode"], dict) and "_l" in infos["episode"]:
|
| 329 |
+
mask = np.asarray(infos["episode"]["_l"]).astype(bool)
|
| 330 |
+
if mask is not None and np.any(mask):
|
| 331 |
+
r_arr = np.asarray(infos.get("episode", {}).get("r", np.zeros_like(mask, dtype=float)))
|
| 332 |
+
l_arr = np.asarray(infos.get("episode", {}).get("l", np.zeros_like(mask, dtype=int)))
|
| 333 |
+
succ_arr = np.asarray(infos.get("success", np.zeros_like(mask, dtype=bool))).astype(float)
|
| 334 |
+
for i in np.where(mask)[0]:
|
| 335 |
+
ep_r = float(r_arr[i])
|
| 336 |
+
ep_l = int(l_arr[i])
|
| 337 |
+
ep_succ = float(succ_arr[i])
|
| 338 |
+
episode_returns.append(ep_r)
|
| 339 |
+
episode_steps.append(global_step)
|
| 340 |
+
episode_successes.append(ep_succ)
|
| 341 |
+
if args.track:
|
| 342 |
+
try:
|
| 343 |
+
import wandb
|
| 344 |
+
log_dict = {
|
| 345 |
+
"global_step": int(global_step),
|
| 346 |
+
"rollout/ep_rew_mean": float(np.mean(r_arr[mask])) if np.any(mask) else None,
|
| 347 |
+
"rollout/ep_len_mean": float(np.mean(l_arr[mask])) if np.any(mask) else None,
|
| 348 |
+
"rollout/success_rate": float(np.mean(succ_arr[mask])) if np.any(mask) else None,
|
| 349 |
+
}
|
| 350 |
+
if np.any(mask):
|
| 351 |
+
last_idx = np.where(mask)[0][-1]
|
| 352 |
+
log_dict.update({
|
| 353 |
+
"train/episodic_return": float(r_arr[last_idx]),
|
| 354 |
+
"train/episodic_length": int(l_arr[last_idx]),
|
| 355 |
+
"train/success": float(succ_arr[last_idx]),
|
| 356 |
+
"train/success_rate_100": float(np.mean(episode_successes[-100:])) if len(episode_successes) >= 100 else None,
|
| 357 |
+
})
|
| 358 |
+
wandb.log(log_dict, step=global_step)
|
| 359 |
+
except Exception:
|
| 360 |
+
pass
|
| 361 |
+
except Exception:
|
| 362 |
+
pass
|
| 363 |
+
|
| 364 |
+
# GAE
|
| 365 |
+
with torch.no_grad():
|
| 366 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 367 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 368 |
+
lastgaelam = 0
|
| 369 |
+
for t in reversed(range(args.num_steps)):
|
| 370 |
+
if t == args.num_steps - 1:
|
| 371 |
+
nextnonterminal = 1.0 - next_done
|
| 372 |
+
nextvalues = next_value
|
| 373 |
+
else:
|
| 374 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 375 |
+
nextvalues = values[t + 1]
|
| 376 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 377 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 378 |
+
returns = advantages + values
|
| 379 |
+
|
| 380 |
+
# flatten batch
|
| 381 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 382 |
+
b_logprobs = logprobs.reshape(-1)
|
| 383 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 384 |
+
b_advantages = advantages.reshape(-1)
|
| 385 |
+
b_returns = returns.reshape(-1)
|
| 386 |
+
b_values = values.reshape(-1)
|
| 387 |
+
|
| 388 |
+
# update
|
| 389 |
+
b_inds = np.arange(args.batch_size)
|
| 390 |
+
clipfracs = []
|
| 391 |
+
for epoch in range(args.update_epochs):
|
| 392 |
+
np.random.shuffle(b_inds)
|
| 393 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 394 |
+
end = start + args.minibatch_size
|
| 395 |
+
mb_inds = b_inds[start:end]
|
| 396 |
+
|
| 397 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 398 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 399 |
+
ratio = logratio.exp()
|
| 400 |
+
|
| 401 |
+
with torch.no_grad():
|
| 402 |
+
old_approx_kl = (-logratio).mean()
|
| 403 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 404 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 405 |
+
|
| 406 |
+
mb_advantages = b_advantages[mb_inds]
|
| 407 |
+
if args.norm_adv:
|
| 408 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 409 |
+
|
| 410 |
+
pg_loss1 = -mb_advantages * ratio
|
| 411 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 412 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 413 |
+
|
| 414 |
+
newvalue = newvalue.view(-1)
|
| 415 |
+
if args.clip_vloss:
|
| 416 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 417 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 418 |
+
newvalue - b_values[mb_inds], -args.clip_coef, args.clip_coef,
|
| 419 |
+
)
|
| 420 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 421 |
+
v_loss = 0.5 * torch.max(v_loss_unclipped, v_loss_clipped).mean()
|
| 422 |
+
else:
|
| 423 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 424 |
+
|
| 425 |
+
entropy_loss = entropy.mean()
|
| 426 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 427 |
+
|
| 428 |
+
optimizer.zero_grad()
|
| 429 |
+
loss.backward()
|
| 430 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 431 |
+
optimizer.step()
|
| 432 |
+
|
| 433 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 434 |
+
break
|
| 435 |
+
|
| 436 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 437 |
+
var_y = np.var(y_true)
|
| 438 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 439 |
+
|
| 440 |
+
sps = int(global_step / (time.time() - start_time))
|
| 441 |
+
progress = 100 * iteration / args.num_iterations
|
| 442 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 443 |
+
f"SPS: {sps:5d} | "
|
| 444 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 445 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 446 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 447 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 448 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 449 |
+
if args.track:
|
| 450 |
+
try:
|
| 451 |
+
import wandb
|
| 452 |
+
wandb.log({
|
| 453 |
+
"global_step": int(global_step),
|
| 454 |
+
"train/value_loss": float(v_loss.item()),
|
| 455 |
+
"train/policy_loss": float(pg_loss.item()),
|
| 456 |
+
"train/entropy": float(entropy_loss.item()),
|
| 457 |
+
"train/old_approx_kl": float(old_approx_kl.item()),
|
| 458 |
+
"train/approx_kl": float(approx_kl.item()),
|
| 459 |
+
"train/clipfrac": float(np.mean(clipfracs)),
|
| 460 |
+
"losses/explained_variance": float(explained_var),
|
| 461 |
+
"charts/avg_reward": float(rewards.mean().item()),
|
| 462 |
+
"charts/avg_value": float(values.mean().item()),
|
| 463 |
+
"perf/SPS": int(sps),
|
| 464 |
+
"train/learning_rate": float(optimizer.param_groups[0]["lr"]),
|
| 465 |
+
}, step=global_step)
|
| 466 |
+
except Exception:
|
| 467 |
+
pass
|
| 468 |
+
|
| 469 |
+
# periodic evaluation collection
|
| 470 |
+
if iteration==1 or iteration % eval_every_iters == 0:
|
| 471 |
+
try:
|
| 472 |
+
eval_thunk = make_env(0, run_name, args.seed + 9999, args.grid_size, args.is_slippery, False)
|
| 473 |
+
collect_eval_trajectories(agent, eval_thunk, n_episodes=args.eval_episodes, step_tag=global_step)
|
| 474 |
+
if args.track:
|
| 475 |
+
try:
|
| 476 |
+
import json as _json
|
| 477 |
+
from pathlib import Path as _Path
|
| 478 |
+
mpath = _Path(f"runs/{run_name}/trajectories/step_{global_step}/metrics.json")
|
| 479 |
+
if mpath.exists():
|
| 480 |
+
with mpath.open("r") as mf:
|
| 481 |
+
metrics = _json.load(mf)
|
| 482 |
+
wandb.log({
|
| 483 |
+
"eval/success_rate": metrics.get("success_rate"),
|
| 484 |
+
"eval/avg_return": metrics.get("avg_return"),
|
| 485 |
+
"eval/std_return": metrics.get("std_return"),
|
| 486 |
+
"eval/episodes": metrics.get("episodes"),
|
| 487 |
+
}, step=global_step)
|
| 488 |
+
except Exception:
|
| 489 |
+
pass
|
| 490 |
+
print(f"Collected {args.eval_episodes} eval trajectories at global_step {global_step}")
|
| 491 |
+
except Exception as e:
|
| 492 |
+
print(f"Warning: eval trajectory collection failed at step {global_step}: {e}")
|
| 493 |
+
|
| 494 |
+
envs.close()
|
cleanrl/cleanrl/wandb/run-20251107_100619-gm3bobw8/logs/debug-internal.log
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"time":"2025-11-07T10:06:19.994658211+08:00","level":"INFO","msg":"stream: starting","core version":"0.22.3"}
|
| 2 |
+
{"time":"2025-11-07T10:06:20.365926969+08:00","level":"INFO","msg":"stream: created new stream","id":"gm3bobw8"}
|
| 3 |
+
{"time":"2025-11-07T10:06:20.366125989+08:00","level":"INFO","msg":"handler: started","stream_id":"gm3bobw8"}
|
| 4 |
+
{"time":"2025-11-07T10:06:20.369029103+08:00","level":"INFO","msg":"stream: started","id":"gm3bobw8"}
|
| 5 |
+
{"time":"2025-11-07T10:06:20.36904409+08:00","level":"INFO","msg":"writer: started","stream_id":"gm3bobw8"}
|
| 6 |
+
{"time":"2025-11-07T10:06:20.36904757+08:00","level":"INFO","msg":"sender: started","stream_id":"gm3bobw8"}
|
| 7 |
+
{"time":"2025-11-07T10:06:20.813587305+08:00","level":"ERROR","msg":"git repo not found","error":"repository does not exist"}
|
| 8 |
+
{"time":"2025-11-07T10:06:30.950807532+08:00","level":"WARN","msg":"tensorboard: no root directory","error":"timed out after 10s"}
|
| 9 |
+
{"time":"2025-11-07T10:06:30.951607455+08:00","level":"INFO","msg":"tensorboard: tracking new log directory","rootDir":{},"logDir":"LocalOrCloudPath(LocalPath=\"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Bandit__ppo_bandit__1__1762481172\")","namespace":""}
|
| 10 |
+
{"time":"2025-11-07T10:06:30.95391652+08:00","level":"INFO","msg":"tensorboard: saving file","fileLocation":"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Bandit__ppo_bandit__1__1762481172/events.out.tfevents.1762481180.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.131343.0","runPath":"runs/Bandit__ppo_bandit__1__1762481172/events.out.tfevents.1762481180.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.131343.0"}
|
| 11 |
+
{"time":"2025-11-07T10:06:30.957133707+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":71}
|
| 12 |
+
{"time":"2025-11-07T10:06:30.961555078+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":472}
|
| 13 |
+
{"time":"2025-11-07T10:06:35.966080652+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":596}
|
| 14 |
+
{"time":"2025-11-07T10:06:36.315508554+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 15 |
+
{"time":"2025-11-07T10:06:40.972626238+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":964}
|
| 16 |
+
{"time":"2025-11-07T10:06:40.972681395+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 17 |
+
{"time":"2025-11-07T10:06:40.973207934+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":996}
|
| 18 |
+
{"time":"2025-11-07T10:06:40.975801472+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":246}
|
| 19 |
+
{"time":"2025-11-07T10:06:50.990421903+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1662}
|
| 20 |
+
{"time":"2025-11-07T10:06:51.298917777+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":279}
|
| 21 |
+
{"time":"2025-11-07T10:06:55.996470006+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1991}
|
| 22 |
+
{"time":"2025-11-07T10:06:55.996583551+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 23 |
+
{"time":"2025-11-07T10:06:55.997028739+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2023}
|
| 24 |
+
{"time":"2025-11-07T10:06:55.999621336+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":246}
|
| 25 |
+
{"time":"2025-11-07T10:06:59.151408238+08:00","level":"INFO","msg":"stream: closing","id":"gm3bobw8"}
|
| 26 |
+
{"time":"2025-11-07T10:06:59.154021485+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2314}
|
| 27 |
+
{"time":"2025-11-07T10:06:59.156923599+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":201}
|
| 28 |
+
{"time":"2025-11-07T10:07:00.878858934+08:00","level":"INFO","msg":"fileTransfer: Close: file transfer manager closed"}
|
| 29 |
+
{"time":"2025-11-07T10:07:01.313956448+08:00","level":"INFO","msg":"handler: closed","stream_id":"gm3bobw8"}
|
| 30 |
+
{"time":"2025-11-07T10:07:01.315667095+08:00","level":"INFO","msg":"sender: closed","stream_id":"gm3bobw8"}
|
| 31 |
+
{"time":"2025-11-07T10:07:01.31578248+08:00","level":"INFO","msg":"stream: closed","id":"gm3bobw8"}
|
cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/code/cleanrl/ppo_bandit.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO implementation for RAGEN Bandit environment
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
|
| 7 |
+
import gymnasium as gym
|
| 8 |
+
import numpy as np
|
| 9 |
+
import torch
|
| 10 |
+
import torch.nn as nn
|
| 11 |
+
import torch.optim as optim
|
| 12 |
+
import tyro
|
| 13 |
+
from torch.distributions.categorical import Categorical
|
| 14 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 15 |
+
|
| 16 |
+
import sys
|
| 17 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 18 |
+
|
| 19 |
+
from ragen.env.bandit.env import BanditEnv
|
| 20 |
+
from ragen.env.bandit.config import BanditEnvConfig
|
| 21 |
+
from ragen_wrappers import BanditWrapper
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@dataclass
|
| 25 |
+
class Args:
|
| 26 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 27 |
+
"""the name of this experiment"""
|
| 28 |
+
seed: int = 1
|
| 29 |
+
"""seed of the experiment"""
|
| 30 |
+
torch_deterministic: bool = True
|
| 31 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 32 |
+
cuda: bool = True
|
| 33 |
+
"""if toggled, cuda will be enabled by default"""
|
| 34 |
+
track: bool = True
|
| 35 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 36 |
+
wandb_project_name: str = "cleanRL"
|
| 37 |
+
"""the wandb's project name"""
|
| 38 |
+
wandb_entity: str = None
|
| 39 |
+
"""the entity (team) of wandb's project"""
|
| 40 |
+
capture_video: bool = False
|
| 41 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 42 |
+
|
| 43 |
+
# Algorithm specific arguments
|
| 44 |
+
env_id: str = "Bandit"
|
| 45 |
+
"""the id of the environment"""
|
| 46 |
+
total_timesteps: int = 10000000
|
| 47 |
+
"""total timesteps of the experiments"""
|
| 48 |
+
learning_rate: float = 2.5e-4
|
| 49 |
+
"""the learning rate of the optimizer"""
|
| 50 |
+
num_envs: int = 32
|
| 51 |
+
"""the number of parallel game environments"""
|
| 52 |
+
num_steps: int = 512
|
| 53 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 54 |
+
anneal_lr: bool = True
|
| 55 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 56 |
+
gamma: float = 0.99
|
| 57 |
+
"""the discount factor gamma"""
|
| 58 |
+
gae_lambda: float = 0.95
|
| 59 |
+
"""the lambda for the general advantage estimation"""
|
| 60 |
+
num_minibatches: int = 4
|
| 61 |
+
"""the number of mini-batches"""
|
| 62 |
+
update_epochs: int = 4
|
| 63 |
+
"""the K epochs to update the policy"""
|
| 64 |
+
norm_adv: bool = True
|
| 65 |
+
"""Toggles advantages normalization"""
|
| 66 |
+
clip_coef: float = 0.2
|
| 67 |
+
"""the surrogate clipping coefficient"""
|
| 68 |
+
clip_vloss: bool = True
|
| 69 |
+
"""Toggles whether or not to use a clipped loss for the value function, as per the paper."""
|
| 70 |
+
ent_coef: float = 0.01
|
| 71 |
+
"""coefficient of the entropy"""
|
| 72 |
+
vf_coef: float = 0.5
|
| 73 |
+
"""coefficient of the value function"""
|
| 74 |
+
max_grad_norm: float = 0.5
|
| 75 |
+
"""the maximum norm for the gradient clipping"""
|
| 76 |
+
target_kl: float = None
|
| 77 |
+
"""the target KL divergence threshold"""
|
| 78 |
+
|
| 79 |
+
# to be filled in runtime
|
| 80 |
+
batch_size: int = 0
|
| 81 |
+
"""the batch size (computed in runtime)"""
|
| 82 |
+
minibatch_size: int = 0
|
| 83 |
+
"""the mini-batch size (computed in runtime)"""
|
| 84 |
+
num_iterations: int = 0
|
| 85 |
+
"""the number of iterations (computed in runtime)"""
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def make_env(env_id, idx, capture_video, run_name, seed):
|
| 89 |
+
def thunk():
|
| 90 |
+
config = BanditEnvConfig()
|
| 91 |
+
env = BanditEnv(config)
|
| 92 |
+
env = BanditWrapper(env)
|
| 93 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 94 |
+
if capture_video and idx == 0:
|
| 95 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 96 |
+
return env
|
| 97 |
+
return thunk
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 101 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 102 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 103 |
+
return layer
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class Agent(nn.Module):
|
| 107 |
+
def __init__(self, envs):
|
| 108 |
+
super().__init__()
|
| 109 |
+
obs_shape = np.array(envs.single_observation_space.shape).prod()
|
| 110 |
+
self.critic = nn.Sequential(
|
| 111 |
+
layer_init(nn.Linear(obs_shape, 64)),
|
| 112 |
+
nn.Tanh(),
|
| 113 |
+
layer_init(nn.Linear(64, 64)),
|
| 114 |
+
nn.Tanh(),
|
| 115 |
+
layer_init(nn.Linear(64, 1), std=1.0),
|
| 116 |
+
)
|
| 117 |
+
self.actor = nn.Sequential(
|
| 118 |
+
layer_init(nn.Linear(obs_shape, 64)),
|
| 119 |
+
nn.Tanh(),
|
| 120 |
+
layer_init(nn.Linear(64, 64)),
|
| 121 |
+
nn.Tanh(),
|
| 122 |
+
layer_init(nn.Linear(64, envs.single_action_space.n), std=0.01),
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
def get_value(self, x):
|
| 126 |
+
return self.critic(x)
|
| 127 |
+
|
| 128 |
+
def get_action_and_value(self, x, action=None):
|
| 129 |
+
logits = self.actor(x)
|
| 130 |
+
probs = Categorical(logits=logits)
|
| 131 |
+
if action is None:
|
| 132 |
+
action = probs.sample()
|
| 133 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
if __name__ == "__main__":
|
| 137 |
+
args = tyro.cli(Args)
|
| 138 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 139 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 140 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 141 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 142 |
+
if args.track:
|
| 143 |
+
import wandb
|
| 144 |
+
|
| 145 |
+
wandb.init(
|
| 146 |
+
project=args.wandb_project_name,
|
| 147 |
+
entity=args.wandb_entity,
|
| 148 |
+
sync_tensorboard=True,
|
| 149 |
+
config=vars(args),
|
| 150 |
+
name=run_name,
|
| 151 |
+
monitor_gym=True,
|
| 152 |
+
save_code=True,
|
| 153 |
+
)
|
| 154 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 155 |
+
writer.add_text(
|
| 156 |
+
"hyperparameters",
|
| 157 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
# TRY NOT TO MODIFY: seeding
|
| 161 |
+
random.seed(args.seed)
|
| 162 |
+
np.random.seed(args.seed)
|
| 163 |
+
torch.manual_seed(args.seed)
|
| 164 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 165 |
+
|
| 166 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 167 |
+
|
| 168 |
+
# env setup
|
| 169 |
+
envs = gym.vector.SyncVectorEnv(
|
| 170 |
+
[make_env(args.env_id, i, args.capture_video, run_name, args.seed + i) for i in range(args.num_envs)],
|
| 171 |
+
)
|
| 172 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 173 |
+
|
| 174 |
+
agent = Agent(envs).to(device)
|
| 175 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 176 |
+
|
| 177 |
+
# ALGO Logic: Storage setup
|
| 178 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 179 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 180 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 181 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 182 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 183 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 184 |
+
|
| 185 |
+
# TRY NOT TO MODIFY: start the game
|
| 186 |
+
global_step = 0
|
| 187 |
+
start_time = time.time()
|
| 188 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 189 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 190 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 191 |
+
|
| 192 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 193 |
+
# Annealing the rate if instructed to do so.
|
| 194 |
+
if args.anneal_lr:
|
| 195 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 196 |
+
lrnow = frac * args.learning_rate
|
| 197 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 198 |
+
|
| 199 |
+
for step in range(0, args.num_steps):
|
| 200 |
+
global_step += args.num_envs
|
| 201 |
+
obs[step] = next_obs
|
| 202 |
+
dones[step] = next_done
|
| 203 |
+
|
| 204 |
+
# ALGO LOGIC: action logic
|
| 205 |
+
with torch.no_grad():
|
| 206 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 207 |
+
values[step] = value.flatten()
|
| 208 |
+
actions[step] = action
|
| 209 |
+
logprobs[step] = logprob
|
| 210 |
+
|
| 211 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 212 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 213 |
+
next_done = np.logical_or(terminations, truncations)
|
| 214 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 215 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 216 |
+
|
| 217 |
+
if "final_info" in infos:
|
| 218 |
+
for info in infos["final_info"]:
|
| 219 |
+
if info and "episode" in info:
|
| 220 |
+
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
|
| 221 |
+
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
|
| 222 |
+
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
|
| 223 |
+
|
| 224 |
+
# bootstrap value if not done
|
| 225 |
+
with torch.no_grad():
|
| 226 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 227 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 228 |
+
lastgaelam = 0
|
| 229 |
+
for t in reversed(range(args.num_steps)):
|
| 230 |
+
if t == args.num_steps - 1:
|
| 231 |
+
nextnonterminal = 1.0 - next_done
|
| 232 |
+
nextvalues = next_value
|
| 233 |
+
else:
|
| 234 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 235 |
+
nextvalues = values[t + 1]
|
| 236 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 237 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 238 |
+
returns = advantages + values
|
| 239 |
+
|
| 240 |
+
# flatten the batch
|
| 241 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 242 |
+
b_logprobs = logprobs.reshape(-1)
|
| 243 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 244 |
+
b_advantages = advantages.reshape(-1)
|
| 245 |
+
b_returns = returns.reshape(-1)
|
| 246 |
+
b_values = values.reshape(-1)
|
| 247 |
+
|
| 248 |
+
# Optimizing the policy and value network
|
| 249 |
+
b_inds = np.arange(args.batch_size)
|
| 250 |
+
clipfracs = []
|
| 251 |
+
for epoch in range(args.update_epochs):
|
| 252 |
+
np.random.shuffle(b_inds)
|
| 253 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 254 |
+
end = start + args.minibatch_size
|
| 255 |
+
mb_inds = b_inds[start:end]
|
| 256 |
+
|
| 257 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 258 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 259 |
+
ratio = logratio.exp()
|
| 260 |
+
|
| 261 |
+
with torch.no_grad():
|
| 262 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 263 |
+
old_approx_kl = (-logratio).mean()
|
| 264 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 265 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 266 |
+
|
| 267 |
+
mb_advantages = b_advantages[mb_inds]
|
| 268 |
+
if args.norm_adv:
|
| 269 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 270 |
+
|
| 271 |
+
# Policy loss
|
| 272 |
+
pg_loss1 = -mb_advantages * ratio
|
| 273 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 274 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 275 |
+
|
| 276 |
+
# Value loss
|
| 277 |
+
newvalue = newvalue.view(-1)
|
| 278 |
+
if args.clip_vloss:
|
| 279 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 280 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 281 |
+
newvalue - b_values[mb_inds],
|
| 282 |
+
-args.clip_coef,
|
| 283 |
+
args.clip_coef,
|
| 284 |
+
)
|
| 285 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 286 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 287 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 288 |
+
else:
|
| 289 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 290 |
+
|
| 291 |
+
entropy_loss = entropy.mean()
|
| 292 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 293 |
+
|
| 294 |
+
optimizer.zero_grad()
|
| 295 |
+
loss.backward()
|
| 296 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 297 |
+
optimizer.step()
|
| 298 |
+
|
| 299 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 300 |
+
break
|
| 301 |
+
|
| 302 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 303 |
+
var_y = np.var(y_true)
|
| 304 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 305 |
+
|
| 306 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 307 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 308 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 309 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 310 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 311 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 312 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 313 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 314 |
+
writer.add_scalar("losses/explained_variance", explained_var, global_step)
|
| 315 |
+
|
| 316 |
+
# Additional useful metrics
|
| 317 |
+
writer.add_scalar("charts/avg_reward", rewards.mean().item(), global_step)
|
| 318 |
+
writer.add_scalar("charts/avg_value", values.mean().item(), global_step)
|
| 319 |
+
writer.add_scalar("charts/max_reward", rewards.max().item(), global_step)
|
| 320 |
+
writer.add_scalar("charts/min_reward", rewards.min().item(), global_step)
|
| 321 |
+
|
| 322 |
+
# Console output with key metrics
|
| 323 |
+
sps = int(global_step / (time.time() - start_time))
|
| 324 |
+
progress = 100 * iteration / args.num_iterations
|
| 325 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 326 |
+
f"SPS: {sps:5d} | "
|
| 327 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 328 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 329 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 330 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 331 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 332 |
+
writer.add_scalar("charts/SPS", sps, global_step)
|
| 333 |
+
|
| 334 |
+
envs.close()
|
| 335 |
+
writer.close()
|
cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/config.yaml
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
_wandb:
|
| 2 |
+
value:
|
| 3 |
+
cli_version: 0.22.3
|
| 4 |
+
code_path: code/cleanrl/ppo_bandit.py
|
| 5 |
+
e:
|
| 6 |
+
afa72m1ss75e8tywa8la2dtqpijhj6o8:
|
| 7 |
+
args:
|
| 8 |
+
- --track
|
| 9 |
+
- --wandb-project-name
|
| 10 |
+
- ragen-bandit
|
| 11 |
+
codePath: cleanrl/ppo_bandit.py
|
| 12 |
+
codePathLocal: ppo_bandit.py
|
| 13 |
+
cpu_count: 64
|
| 14 |
+
cpu_count_logical: 128
|
| 15 |
+
cudaVersion: "12.4"
|
| 16 |
+
disk:
|
| 17 |
+
/:
|
| 18 |
+
total: "5153960755200"
|
| 19 |
+
used: "30509883392"
|
| 20 |
+
email: haoyu-wa22@mails.tsinghua.edu.cn
|
| 21 |
+
executable: /root/local/miniconda3/envs/ragen/bin/python
|
| 22 |
+
git:
|
| 23 |
+
commit: 004f8a086a892a2a180f4dd332b90d83a968aa7a
|
| 24 |
+
remote: https://github.com/vwxyzjn/cleanrl.git
|
| 25 |
+
gpu: NVIDIA H100 80GB HBM3
|
| 26 |
+
gpu_count: 8
|
| 27 |
+
gpu_nvidia:
|
| 28 |
+
- architecture: Hopper
|
| 29 |
+
cudaCores: 16896
|
| 30 |
+
memoryTotal: "85520809984"
|
| 31 |
+
name: NVIDIA H100 80GB HBM3
|
| 32 |
+
uuid: GPU-35e2d43d-4067-82ce-90d4-def9e389bf28
|
| 33 |
+
- architecture: Hopper
|
| 34 |
+
cudaCores: 16896
|
| 35 |
+
memoryTotal: "85520809984"
|
| 36 |
+
name: NVIDIA H100 80GB HBM3
|
| 37 |
+
uuid: GPU-af4135e3-88f2-e9ac-518d-502c75a85429
|
| 38 |
+
- architecture: Hopper
|
| 39 |
+
cudaCores: 16896
|
| 40 |
+
memoryTotal: "85520809984"
|
| 41 |
+
name: NVIDIA H100 80GB HBM3
|
| 42 |
+
uuid: GPU-d7fdeeba-fe9b-ec03-d9f7-6724fe4266b5
|
| 43 |
+
- architecture: Hopper
|
| 44 |
+
cudaCores: 16896
|
| 45 |
+
memoryTotal: "85520809984"
|
| 46 |
+
name: NVIDIA H100 80GB HBM3
|
| 47 |
+
uuid: GPU-ccc4f668-3882-5a8e-2c07-c5cd08f6f666
|
| 48 |
+
- architecture: Hopper
|
| 49 |
+
cudaCores: 16896
|
| 50 |
+
memoryTotal: "85520809984"
|
| 51 |
+
name: NVIDIA H100 80GB HBM3
|
| 52 |
+
uuid: GPU-7b73c0cf-d3d5-e10c-7176-a43be1e41001
|
| 53 |
+
- architecture: Hopper
|
| 54 |
+
cudaCores: 16896
|
| 55 |
+
memoryTotal: "85520809984"
|
| 56 |
+
name: NVIDIA H100 80GB HBM3
|
| 57 |
+
uuid: GPU-81b58d94-5d1f-8ec2-f9d2-fd56172ed177
|
| 58 |
+
- architecture: Hopper
|
| 59 |
+
cudaCores: 16896
|
| 60 |
+
memoryTotal: "85520809984"
|
| 61 |
+
name: NVIDIA H100 80GB HBM3
|
| 62 |
+
uuid: GPU-03e8bc66-3b44-6794-49fd-5392fbdda6d1
|
| 63 |
+
- architecture: Hopper
|
| 64 |
+
cudaCores: 16896
|
| 65 |
+
memoryTotal: "85520809984"
|
| 66 |
+
name: NVIDIA H100 80GB HBM3
|
| 67 |
+
uuid: GPU-b7cf0ec6-7c29-1179-dceb-09565da51890
|
| 68 |
+
host: pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0
|
| 69 |
+
memory:
|
| 70 |
+
total: "2163642122240"
|
| 71 |
+
os: Linux-5.14.0-284.25.1.el9_2.x86_64-x86_64-with-glibc2.35
|
| 72 |
+
program: /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_bandit.py
|
| 73 |
+
python: CPython 3.12.12
|
| 74 |
+
root: /mnt/general/wanghy/RAGEN/cleanrl/cleanrl
|
| 75 |
+
startedAt: "2025-11-07T02:09:11.693292Z"
|
| 76 |
+
writerId: afa72m1ss75e8tywa8la2dtqpijhj6o8
|
| 77 |
+
m: []
|
| 78 |
+
python_version: 3.12.12
|
| 79 |
+
t:
|
| 80 |
+
"1":
|
| 81 |
+
- 1
|
| 82 |
+
- 49
|
| 83 |
+
- 51
|
| 84 |
+
- 105
|
| 85 |
+
"2":
|
| 86 |
+
- 1
|
| 87 |
+
- 49
|
| 88 |
+
- 51
|
| 89 |
+
- 105
|
| 90 |
+
"3":
|
| 91 |
+
- 13
|
| 92 |
+
- 16
|
| 93 |
+
- 35
|
| 94 |
+
"4": 3.12.12
|
| 95 |
+
"5": 0.22.3
|
| 96 |
+
"12": 0.22.3
|
| 97 |
+
"13": linux-x86_64
|
| 98 |
+
anneal_lr:
|
| 99 |
+
value: true
|
| 100 |
+
batch_size:
|
| 101 |
+
value: 16384
|
| 102 |
+
capture_video:
|
| 103 |
+
value: false
|
| 104 |
+
clip_coef:
|
| 105 |
+
value: 0.2
|
| 106 |
+
clip_vloss:
|
| 107 |
+
value: true
|
| 108 |
+
cuda:
|
| 109 |
+
value: true
|
| 110 |
+
ent_coef:
|
| 111 |
+
value: 0.01
|
| 112 |
+
env_id:
|
| 113 |
+
value: Bandit
|
| 114 |
+
exp_name:
|
| 115 |
+
value: ppo_bandit
|
| 116 |
+
gae_lambda:
|
| 117 |
+
value: 0.95
|
| 118 |
+
gamma:
|
| 119 |
+
value: 0.99
|
| 120 |
+
learning_rate:
|
| 121 |
+
value: 0.00025
|
| 122 |
+
max_grad_norm:
|
| 123 |
+
value: 0.5
|
| 124 |
+
minibatch_size:
|
| 125 |
+
value: 4096
|
| 126 |
+
norm_adv:
|
| 127 |
+
value: true
|
| 128 |
+
num_envs:
|
| 129 |
+
value: 32
|
| 130 |
+
num_iterations:
|
| 131 |
+
value: 610
|
| 132 |
+
num_minibatches:
|
| 133 |
+
value: 4
|
| 134 |
+
num_steps:
|
| 135 |
+
value: 512
|
| 136 |
+
seed:
|
| 137 |
+
value: 1
|
| 138 |
+
target_kl:
|
| 139 |
+
value: null
|
| 140 |
+
torch_deterministic:
|
| 141 |
+
value: true
|
| 142 |
+
total_timesteps:
|
| 143 |
+
value: 10000000
|
| 144 |
+
track:
|
| 145 |
+
value: true
|
| 146 |
+
update_epochs:
|
| 147 |
+
value: 4
|
| 148 |
+
vf_coef:
|
| 149 |
+
value: 0.5
|
| 150 |
+
wandb_entity:
|
| 151 |
+
value: null
|
| 152 |
+
wandb_project_name:
|
| 153 |
+
value: ragen-bandit
|
cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/wandb-metadata.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"os": "Linux-5.14.0-284.25.1.el9_2.x86_64-x86_64-with-glibc2.35",
|
| 3 |
+
"python": "CPython 3.12.12",
|
| 4 |
+
"startedAt": "2025-11-07T02:09:11.693292Z",
|
| 5 |
+
"args": [
|
| 6 |
+
"--track",
|
| 7 |
+
"--wandb-project-name",
|
| 8 |
+
"ragen-bandit"
|
| 9 |
+
],
|
| 10 |
+
"program": "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_bandit.py",
|
| 11 |
+
"codePath": "cleanrl/ppo_bandit.py",
|
| 12 |
+
"codePathLocal": "ppo_bandit.py",
|
| 13 |
+
"git": {
|
| 14 |
+
"remote": "https://github.com/vwxyzjn/cleanrl.git",
|
| 15 |
+
"commit": "004f8a086a892a2a180f4dd332b90d83a968aa7a"
|
| 16 |
+
},
|
| 17 |
+
"email": "haoyu-wa22@mails.tsinghua.edu.cn",
|
| 18 |
+
"root": "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl",
|
| 19 |
+
"host": "pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0",
|
| 20 |
+
"executable": "/root/local/miniconda3/envs/ragen/bin/python",
|
| 21 |
+
"cpu_count": 64,
|
| 22 |
+
"cpu_count_logical": 128,
|
| 23 |
+
"gpu": "NVIDIA H100 80GB HBM3",
|
| 24 |
+
"gpu_count": 8,
|
| 25 |
+
"disk": {
|
| 26 |
+
"/": {
|
| 27 |
+
"total": "5153960755200",
|
| 28 |
+
"used": "30509883392"
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"memory": {
|
| 32 |
+
"total": "2163642122240"
|
| 33 |
+
},
|
| 34 |
+
"gpu_nvidia": [
|
| 35 |
+
{
|
| 36 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 37 |
+
"memoryTotal": "85520809984",
|
| 38 |
+
"cudaCores": 16896,
|
| 39 |
+
"architecture": "Hopper",
|
| 40 |
+
"uuid": "GPU-35e2d43d-4067-82ce-90d4-def9e389bf28"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 44 |
+
"memoryTotal": "85520809984",
|
| 45 |
+
"cudaCores": 16896,
|
| 46 |
+
"architecture": "Hopper",
|
| 47 |
+
"uuid": "GPU-af4135e3-88f2-e9ac-518d-502c75a85429"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 51 |
+
"memoryTotal": "85520809984",
|
| 52 |
+
"cudaCores": 16896,
|
| 53 |
+
"architecture": "Hopper",
|
| 54 |
+
"uuid": "GPU-d7fdeeba-fe9b-ec03-d9f7-6724fe4266b5"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 58 |
+
"memoryTotal": "85520809984",
|
| 59 |
+
"cudaCores": 16896,
|
| 60 |
+
"architecture": "Hopper",
|
| 61 |
+
"uuid": "GPU-ccc4f668-3882-5a8e-2c07-c5cd08f6f666"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 65 |
+
"memoryTotal": "85520809984",
|
| 66 |
+
"cudaCores": 16896,
|
| 67 |
+
"architecture": "Hopper",
|
| 68 |
+
"uuid": "GPU-7b73c0cf-d3d5-e10c-7176-a43be1e41001"
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 72 |
+
"memoryTotal": "85520809984",
|
| 73 |
+
"cudaCores": 16896,
|
| 74 |
+
"architecture": "Hopper",
|
| 75 |
+
"uuid": "GPU-81b58d94-5d1f-8ec2-f9d2-fd56172ed177"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 79 |
+
"memoryTotal": "85520809984",
|
| 80 |
+
"cudaCores": 16896,
|
| 81 |
+
"architecture": "Hopper",
|
| 82 |
+
"uuid": "GPU-03e8bc66-3b44-6794-49fd-5392fbdda6d1"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 86 |
+
"memoryTotal": "85520809984",
|
| 87 |
+
"cudaCores": 16896,
|
| 88 |
+
"architecture": "Hopper",
|
| 89 |
+
"uuid": "GPU-b7cf0ec6-7c29-1179-dceb-09565da51890"
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"cudaVersion": "12.4",
|
| 93 |
+
"writerId": "afa72m1ss75e8tywa8la2dtqpijhj6o8"
|
| 94 |
+
}
|
cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/files/wandb-summary.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"_step":7929,"losses/approx_kl":1.38243195e-08,"losses/policy_loss":1.4365651e-07,"losses/clipfrac":0,"global_step":9994240,"charts/learning_rate":4.0983608e-07,"charts/avg_reward":0.08695068,"charts/max_reward":1,"charts/SPS":27464,"_runtime":365,"losses/entropy":0.6929781,"losses/value_loss":0.043968797,"losses/old_approx_kl":7.185736e-08,"charts/avg_value":0.17424533,"losses/explained_variance":-2.8371811e-05,"charts/min_reward":0,"_timestamp":1.7624817181982253e+09,"_wandb":{"runtime":365}}
|
cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/logs/debug.log
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-11-07 10:09:11,744 INFO MainThread:131665 [wandb_setup.py:_flush():81] Current SDK version is 0.22.3
|
| 2 |
+
2025-11-07 10:09:11,745 INFO MainThread:131665 [wandb_setup.py:_flush():81] Configure stats pid to 131665
|
| 3 |
+
2025-11-07 10:09:11,745 INFO MainThread:131665 [wandb_setup.py:_flush():81] Loading settings from /root/.config/wandb/settings
|
| 4 |
+
2025-11-07 10:09:11,745 INFO MainThread:131665 [wandb_setup.py:_flush():81] Loading settings from /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/settings
|
| 5 |
+
2025-11-07 10:09:11,745 INFO MainThread:131665 [wandb_setup.py:_flush():81] Loading settings from environment variables
|
| 6 |
+
2025-11-07 10:09:11,745 INFO MainThread:131665 [wandb_init.py:setup_run_log_directory():706] Logging user logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/logs/debug.log
|
| 7 |
+
2025-11-07 10:09:11,746 INFO MainThread:131665 [wandb_init.py:setup_run_log_directory():707] Logging internal logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_100911-8xuf7idy/logs/debug-internal.log
|
| 8 |
+
2025-11-07 10:09:11,747 INFO MainThread:131665 [wandb_init.py:init():833] calling init triggers
|
| 9 |
+
2025-11-07 10:09:11,747 INFO MainThread:131665 [wandb_init.py:init():838] wandb.init called with sweep_config: {}
|
| 10 |
+
config: {'exp_name': 'ppo_bandit', 'seed': 1, 'torch_deterministic': True, 'cuda': True, 'track': True, 'wandb_project_name': 'ragen-bandit', 'wandb_entity': None, 'capture_video': False, 'env_id': 'Bandit', 'total_timesteps': 10000000, 'learning_rate': 0.00025, 'num_envs': 32, 'num_steps': 512, 'anneal_lr': True, 'gamma': 0.99, 'gae_lambda': 0.95, 'num_minibatches': 4, 'update_epochs': 4, 'norm_adv': True, 'clip_coef': 0.2, 'clip_vloss': True, 'ent_coef': 0.01, 'vf_coef': 0.5, 'max_grad_norm': 0.5, 'target_kl': None, 'batch_size': 16384, 'minibatch_size': 4096, 'num_iterations': 610, '_wandb': {'code_path': 'code/cleanrl/ppo_bandit.py'}}
|
| 11 |
+
2025-11-07 10:09:11,747 INFO MainThread:131665 [wandb_init.py:init():881] starting backend
|
| 12 |
+
2025-11-07 10:09:11,953 INFO MainThread:131665 [wandb_init.py:init():884] sending inform_init request
|
| 13 |
+
2025-11-07 10:09:11,964 INFO MainThread:131665 [wandb_init.py:init():892] backend started and connected
|
| 14 |
+
2025-11-07 10:09:11,966 INFO MainThread:131665 [wandb_init.py:init():962] updated telemetry
|
| 15 |
+
2025-11-07 10:09:12,000 INFO MainThread:131665 [wandb_init.py:init():986] communicating run to backend with 90.0 second timeout
|
| 16 |
+
2025-11-07 10:09:12,663 INFO MainThread:131665 [wandb_init.py:init():1033] starting run threads in backend
|
| 17 |
+
2025-11-07 10:09:12,806 INFO MainThread:131665 [wandb_run.py:_console_start():2506] atexit reg
|
| 18 |
+
2025-11-07 10:09:12,806 INFO MainThread:131665 [wandb_run.py:_redirect():2354] redirect: wrap_raw
|
| 19 |
+
2025-11-07 10:09:12,807 INFO MainThread:131665 [wandb_run.py:_redirect():2423] Wrapping output streams.
|
| 20 |
+
2025-11-07 10:09:12,807 INFO MainThread:131665 [wandb_run.py:_redirect():2446] Redirects installed.
|
| 21 |
+
2025-11-07 10:09:12,809 INFO MainThread:131665 [wandb_init.py:init():1073] run started, returning control to user process
|
| 22 |
+
2025-11-07 10:09:12,809 INFO MainThread:131665 [wandb_run.py:_tensorboard_callback():1598] tensorboard callback: runs/Bandit__ppo_bandit__1__1762481344, True
|
| 23 |
+
2025-11-07 10:15:18,220 INFO wandb-AsyncioManager-main:131665 [service_client.py:_forward_responses():80] Reached EOF.
|
| 24 |
+
2025-11-07 10:15:18,220 INFO wandb-AsyncioManager-main:131665 [mailbox.py:close():137] Closing mailbox, abandoning 1 handles.
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/code/cleanrl/ppo_bandit.py
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# PPO implementation for RAGEN Bandit environment
|
| 2 |
+
import os
|
| 3 |
+
import random
|
| 4 |
+
import time
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
|
| 7 |
+
import gymnasium as gym
|
| 8 |
+
import numpy as np
|
| 9 |
+
import torch
|
| 10 |
+
import torch.nn as nn
|
| 11 |
+
import torch.optim as optim
|
| 12 |
+
import tyro
|
| 13 |
+
from torch.distributions.categorical import Categorical
|
| 14 |
+
from torch.utils.tensorboard import SummaryWriter
|
| 15 |
+
|
| 16 |
+
import sys
|
| 17 |
+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../../'))
|
| 18 |
+
|
| 19 |
+
from ragen.env.bandit.env import BanditEnv
|
| 20 |
+
from ragen.env.bandit.config import BanditEnvConfig
|
| 21 |
+
from ragen_wrappers import BanditWrapper
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@dataclass
|
| 25 |
+
class Args:
|
| 26 |
+
exp_name: str = os.path.basename(__file__)[: -len(".py")]
|
| 27 |
+
"""the name of this experiment"""
|
| 28 |
+
seed: int = 1
|
| 29 |
+
"""seed of the experiment"""
|
| 30 |
+
torch_deterministic: bool = True
|
| 31 |
+
"""if toggled, `torch.backends.cudnn.deterministic=False`"""
|
| 32 |
+
cuda: bool = True
|
| 33 |
+
"""if toggled, cuda will be enabled by default"""
|
| 34 |
+
track: bool = True
|
| 35 |
+
"""if toggled, this experiment will be tracked with Weights and Biases"""
|
| 36 |
+
wandb_project_name: str = "cleanRL"
|
| 37 |
+
"""the wandb's project name"""
|
| 38 |
+
wandb_entity: str = None
|
| 39 |
+
"""the entity (team) of wandb's project"""
|
| 40 |
+
capture_video: bool = False
|
| 41 |
+
"""whether to capture videos of the agent performances (check out `videos` folder)"""
|
| 42 |
+
|
| 43 |
+
# Algorithm specific arguments
|
| 44 |
+
env_id: str = "Bandit"
|
| 45 |
+
"""the id of the environment"""
|
| 46 |
+
total_timesteps: int = 10000000
|
| 47 |
+
"""total timesteps of the experiments"""
|
| 48 |
+
learning_rate: float = 2.5e-4
|
| 49 |
+
"""the learning rate of the optimizer"""
|
| 50 |
+
num_envs: int = 32
|
| 51 |
+
"""the number of parallel game environments"""
|
| 52 |
+
num_steps: int = 512
|
| 53 |
+
"""the number of steps to run in each environment per policy rollout"""
|
| 54 |
+
anneal_lr: bool = True
|
| 55 |
+
"""Toggle learning rate annealing for policy and value networks"""
|
| 56 |
+
gamma: float = 0.99
|
| 57 |
+
"""the discount factor gamma"""
|
| 58 |
+
gae_lambda: float = 0.95
|
| 59 |
+
"""the lambda for the general advantage estimation"""
|
| 60 |
+
num_minibatches: int = 4
|
| 61 |
+
"""the number of mini-batches"""
|
| 62 |
+
update_epochs: int = 4
|
| 63 |
+
"""the K epochs to update the policy"""
|
| 64 |
+
norm_adv: bool = True
|
| 65 |
+
"""Toggles advantages normalization"""
|
| 66 |
+
clip_coef: float = 0.2
|
| 67 |
+
"""the surrogate clipping coefficient"""
|
| 68 |
+
clip_vloss: bool = True
|
| 69 |
+
"""Toggles whether or not to use a clipped loss for the value function, as per the paper."""
|
| 70 |
+
ent_coef: float = 0.01
|
| 71 |
+
"""coefficient of the entropy"""
|
| 72 |
+
vf_coef: float = 0.5
|
| 73 |
+
"""coefficient of the value function"""
|
| 74 |
+
max_grad_norm: float = 0.5
|
| 75 |
+
"""the maximum norm for the gradient clipping"""
|
| 76 |
+
target_kl: float = None
|
| 77 |
+
"""the target KL divergence threshold"""
|
| 78 |
+
|
| 79 |
+
# to be filled in runtime
|
| 80 |
+
batch_size: int = 0
|
| 81 |
+
"""the batch size (computed in runtime)"""
|
| 82 |
+
minibatch_size: int = 0
|
| 83 |
+
"""the mini-batch size (computed in runtime)"""
|
| 84 |
+
num_iterations: int = 0
|
| 85 |
+
"""the number of iterations (computed in runtime)"""
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
def make_env(env_id, idx, capture_video, run_name, seed):
|
| 89 |
+
def thunk():
|
| 90 |
+
config = BanditEnvConfig()
|
| 91 |
+
env = BanditEnv(config)
|
| 92 |
+
env = BanditWrapper(env)
|
| 93 |
+
env = gym.wrappers.RecordEpisodeStatistics(env)
|
| 94 |
+
if capture_video and idx == 0:
|
| 95 |
+
env = gym.wrappers.RecordVideo(env, f"videos/{run_name}")
|
| 96 |
+
return env
|
| 97 |
+
return thunk
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def layer_init(layer, std=np.sqrt(2), bias_const=0.0):
|
| 101 |
+
torch.nn.init.orthogonal_(layer.weight, std)
|
| 102 |
+
torch.nn.init.constant_(layer.bias, bias_const)
|
| 103 |
+
return layer
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
class Agent(nn.Module):
|
| 107 |
+
def __init__(self, envs):
|
| 108 |
+
super().__init__()
|
| 109 |
+
obs_shape = np.array(envs.single_observation_space.shape).prod()
|
| 110 |
+
self.critic = nn.Sequential(
|
| 111 |
+
layer_init(nn.Linear(obs_shape, 64)),
|
| 112 |
+
nn.Tanh(),
|
| 113 |
+
layer_init(nn.Linear(64, 64)),
|
| 114 |
+
nn.Tanh(),
|
| 115 |
+
layer_init(nn.Linear(64, 1), std=1.0),
|
| 116 |
+
)
|
| 117 |
+
self.actor = nn.Sequential(
|
| 118 |
+
layer_init(nn.Linear(obs_shape, 64)),
|
| 119 |
+
nn.Tanh(),
|
| 120 |
+
layer_init(nn.Linear(64, 64)),
|
| 121 |
+
nn.Tanh(),
|
| 122 |
+
layer_init(nn.Linear(64, envs.single_action_space.n), std=0.01),
|
| 123 |
+
)
|
| 124 |
+
|
| 125 |
+
def get_value(self, x):
|
| 126 |
+
return self.critic(x)
|
| 127 |
+
|
| 128 |
+
def get_action_and_value(self, x, action=None):
|
| 129 |
+
logits = self.actor(x)
|
| 130 |
+
probs = Categorical(logits=logits)
|
| 131 |
+
if action is None:
|
| 132 |
+
action = probs.sample()
|
| 133 |
+
return action, probs.log_prob(action), probs.entropy(), self.critic(x)
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
if __name__ == "__main__":
|
| 137 |
+
args = tyro.cli(Args)
|
| 138 |
+
args.batch_size = int(args.num_envs * args.num_steps)
|
| 139 |
+
args.minibatch_size = int(args.batch_size // args.num_minibatches)
|
| 140 |
+
args.num_iterations = args.total_timesteps // args.batch_size
|
| 141 |
+
run_name = f"{args.env_id}__{args.exp_name}__{args.seed}__{int(time.time())}"
|
| 142 |
+
if args.track:
|
| 143 |
+
import wandb
|
| 144 |
+
|
| 145 |
+
wandb.init(
|
| 146 |
+
project=args.wandb_project_name,
|
| 147 |
+
entity=args.wandb_entity,
|
| 148 |
+
sync_tensorboard=True,
|
| 149 |
+
config=vars(args),
|
| 150 |
+
name=run_name,
|
| 151 |
+
monitor_gym=True,
|
| 152 |
+
save_code=True,
|
| 153 |
+
)
|
| 154 |
+
writer = SummaryWriter(f"runs/{run_name}")
|
| 155 |
+
writer.add_text(
|
| 156 |
+
"hyperparameters",
|
| 157 |
+
"|param|value|\n|-|-|\n%s" % ("\n".join([f"|{key}|{value}|" for key, value in vars(args).items()])),
|
| 158 |
+
)
|
| 159 |
+
|
| 160 |
+
# TRY NOT TO MODIFY: seeding
|
| 161 |
+
random.seed(args.seed)
|
| 162 |
+
np.random.seed(args.seed)
|
| 163 |
+
torch.manual_seed(args.seed)
|
| 164 |
+
torch.backends.cudnn.deterministic = args.torch_deterministic
|
| 165 |
+
|
| 166 |
+
device = torch.device("cuda" if torch.cuda.is_available() and args.cuda else "cpu")
|
| 167 |
+
|
| 168 |
+
# env setup
|
| 169 |
+
envs = gym.vector.SyncVectorEnv(
|
| 170 |
+
[make_env(args.env_id, i, args.capture_video, run_name, args.seed + i) for i in range(args.num_envs)],
|
| 171 |
+
)
|
| 172 |
+
assert isinstance(envs.single_action_space, gym.spaces.Discrete), "only discrete action space is supported"
|
| 173 |
+
|
| 174 |
+
agent = Agent(envs).to(device)
|
| 175 |
+
optimizer = optim.Adam(agent.parameters(), lr=args.learning_rate, eps=1e-5)
|
| 176 |
+
|
| 177 |
+
# ALGO Logic: Storage setup
|
| 178 |
+
obs = torch.zeros((args.num_steps, args.num_envs) + envs.single_observation_space.shape).to(device)
|
| 179 |
+
actions = torch.zeros((args.num_steps, args.num_envs) + envs.single_action_space.shape).to(device)
|
| 180 |
+
logprobs = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 181 |
+
rewards = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 182 |
+
dones = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 183 |
+
values = torch.zeros((args.num_steps, args.num_envs)).to(device)
|
| 184 |
+
|
| 185 |
+
# TRY NOT TO MODIFY: start the game
|
| 186 |
+
global_step = 0
|
| 187 |
+
start_time = time.time()
|
| 188 |
+
next_obs, _ = envs.reset(seed=args.seed)
|
| 189 |
+
next_obs = torch.Tensor(next_obs).to(device)
|
| 190 |
+
next_done = torch.zeros(args.num_envs).to(device)
|
| 191 |
+
|
| 192 |
+
for iteration in range(1, args.num_iterations + 1):
|
| 193 |
+
# Annealing the rate if instructed to do so.
|
| 194 |
+
if args.anneal_lr:
|
| 195 |
+
frac = 1.0 - (iteration - 1.0) / args.num_iterations
|
| 196 |
+
lrnow = frac * args.learning_rate
|
| 197 |
+
optimizer.param_groups[0]["lr"] = lrnow
|
| 198 |
+
|
| 199 |
+
for step in range(0, args.num_steps):
|
| 200 |
+
global_step += args.num_envs
|
| 201 |
+
obs[step] = next_obs
|
| 202 |
+
dones[step] = next_done
|
| 203 |
+
|
| 204 |
+
# ALGO LOGIC: action logic
|
| 205 |
+
with torch.no_grad():
|
| 206 |
+
action, logprob, _, value = agent.get_action_and_value(next_obs)
|
| 207 |
+
values[step] = value.flatten()
|
| 208 |
+
actions[step] = action
|
| 209 |
+
logprobs[step] = logprob
|
| 210 |
+
|
| 211 |
+
# TRY NOT TO MODIFY: execute the game and log data.
|
| 212 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 213 |
+
next_done = np.logical_or(terminations, truncations)
|
| 214 |
+
rewards[step] = torch.tensor(reward).to(device).view(-1)
|
| 215 |
+
next_obs, next_done = torch.Tensor(next_obs).to(device), torch.Tensor(next_done).to(device)
|
| 216 |
+
|
| 217 |
+
if "final_info" in infos:
|
| 218 |
+
for info in infos["final_info"]:
|
| 219 |
+
if info and "episode" in info:
|
| 220 |
+
print(f"global_step={global_step}, episodic_return={info['episode']['r']}")
|
| 221 |
+
writer.add_scalar("charts/episodic_return", info["episode"]["r"], global_step)
|
| 222 |
+
writer.add_scalar("charts/episodic_length", info["episode"]["l"], global_step)
|
| 223 |
+
|
| 224 |
+
# bootstrap value if not done
|
| 225 |
+
with torch.no_grad():
|
| 226 |
+
next_value = agent.get_value(next_obs).reshape(1, -1)
|
| 227 |
+
advantages = torch.zeros_like(rewards).to(device)
|
| 228 |
+
lastgaelam = 0
|
| 229 |
+
for t in reversed(range(args.num_steps)):
|
| 230 |
+
if t == args.num_steps - 1:
|
| 231 |
+
nextnonterminal = 1.0 - next_done
|
| 232 |
+
nextvalues = next_value
|
| 233 |
+
else:
|
| 234 |
+
nextnonterminal = 1.0 - dones[t + 1]
|
| 235 |
+
nextvalues = values[t + 1]
|
| 236 |
+
delta = rewards[t] + args.gamma * nextvalues * nextnonterminal - values[t]
|
| 237 |
+
advantages[t] = lastgaelam = delta + args.gamma * args.gae_lambda * nextnonterminal * lastgaelam
|
| 238 |
+
returns = advantages + values
|
| 239 |
+
|
| 240 |
+
# flatten the batch
|
| 241 |
+
b_obs = obs.reshape((-1,) + envs.single_observation_space.shape)
|
| 242 |
+
b_logprobs = logprobs.reshape(-1)
|
| 243 |
+
b_actions = actions.reshape((-1,) + envs.single_action_space.shape)
|
| 244 |
+
b_advantages = advantages.reshape(-1)
|
| 245 |
+
b_returns = returns.reshape(-1)
|
| 246 |
+
b_values = values.reshape(-1)
|
| 247 |
+
|
| 248 |
+
# Optimizing the policy and value network
|
| 249 |
+
b_inds = np.arange(args.batch_size)
|
| 250 |
+
clipfracs = []
|
| 251 |
+
for epoch in range(args.update_epochs):
|
| 252 |
+
np.random.shuffle(b_inds)
|
| 253 |
+
for start in range(0, args.batch_size, args.minibatch_size):
|
| 254 |
+
end = start + args.minibatch_size
|
| 255 |
+
mb_inds = b_inds[start:end]
|
| 256 |
+
|
| 257 |
+
_, newlogprob, entropy, newvalue = agent.get_action_and_value(b_obs[mb_inds], b_actions.long()[mb_inds])
|
| 258 |
+
logratio = newlogprob - b_logprobs[mb_inds]
|
| 259 |
+
ratio = logratio.exp()
|
| 260 |
+
|
| 261 |
+
with torch.no_grad():
|
| 262 |
+
# calculate approx_kl http://joschu.net/blog/kl-approx.html
|
| 263 |
+
old_approx_kl = (-logratio).mean()
|
| 264 |
+
approx_kl = ((ratio - 1) - logratio).mean()
|
| 265 |
+
clipfracs += [((ratio - 1.0).abs() > args.clip_coef).float().mean().item()]
|
| 266 |
+
|
| 267 |
+
mb_advantages = b_advantages[mb_inds]
|
| 268 |
+
if args.norm_adv:
|
| 269 |
+
mb_advantages = (mb_advantages - mb_advantages.mean()) / (mb_advantages.std() + 1e-8)
|
| 270 |
+
|
| 271 |
+
# Policy loss
|
| 272 |
+
pg_loss1 = -mb_advantages * ratio
|
| 273 |
+
pg_loss2 = -mb_advantages * torch.clamp(ratio, 1 - args.clip_coef, 1 + args.clip_coef)
|
| 274 |
+
pg_loss = torch.max(pg_loss1, pg_loss2).mean()
|
| 275 |
+
|
| 276 |
+
# Value loss
|
| 277 |
+
newvalue = newvalue.view(-1)
|
| 278 |
+
if args.clip_vloss:
|
| 279 |
+
v_loss_unclipped = (newvalue - b_returns[mb_inds]) ** 2
|
| 280 |
+
v_clipped = b_values[mb_inds] + torch.clamp(
|
| 281 |
+
newvalue - b_values[mb_inds],
|
| 282 |
+
-args.clip_coef,
|
| 283 |
+
args.clip_coef,
|
| 284 |
+
)
|
| 285 |
+
v_loss_clipped = (v_clipped - b_returns[mb_inds]) ** 2
|
| 286 |
+
v_loss_max = torch.max(v_loss_unclipped, v_loss_clipped)
|
| 287 |
+
v_loss = 0.5 * v_loss_max.mean()
|
| 288 |
+
else:
|
| 289 |
+
v_loss = 0.5 * ((newvalue - b_returns[mb_inds]) ** 2).mean()
|
| 290 |
+
|
| 291 |
+
entropy_loss = entropy.mean()
|
| 292 |
+
loss = pg_loss - args.ent_coef * entropy_loss + v_loss * args.vf_coef
|
| 293 |
+
|
| 294 |
+
optimizer.zero_grad()
|
| 295 |
+
loss.backward()
|
| 296 |
+
nn.utils.clip_grad_norm_(agent.parameters(), args.max_grad_norm)
|
| 297 |
+
optimizer.step()
|
| 298 |
+
|
| 299 |
+
if args.target_kl is not None and approx_kl > args.target_kl:
|
| 300 |
+
break
|
| 301 |
+
|
| 302 |
+
y_pred, y_true = b_values.cpu().numpy(), b_returns.cpu().numpy()
|
| 303 |
+
var_y = np.var(y_true)
|
| 304 |
+
explained_var = np.nan if var_y == 0 else 1 - np.var(y_true - y_pred) / var_y
|
| 305 |
+
|
| 306 |
+
# TRY NOT TO MODIFY: record rewards for plotting purposes
|
| 307 |
+
writer.add_scalar("charts/learning_rate", optimizer.param_groups[0]["lr"], global_step)
|
| 308 |
+
writer.add_scalar("losses/value_loss", v_loss.item(), global_step)
|
| 309 |
+
writer.add_scalar("losses/policy_loss", pg_loss.item(), global_step)
|
| 310 |
+
writer.add_scalar("losses/entropy", entropy_loss.item(), global_step)
|
| 311 |
+
writer.add_scalar("losses/old_approx_kl", old_approx_kl.item(), global_step)
|
| 312 |
+
writer.add_scalar("losses/approx_kl", approx_kl.item(), global_step)
|
| 313 |
+
writer.add_scalar("losses/clipfrac", np.mean(clipfracs), global_step)
|
| 314 |
+
writer.add_scalar("losses/explained_variance", explained_var, global_step)
|
| 315 |
+
|
| 316 |
+
# Additional useful metrics
|
| 317 |
+
writer.add_scalar("charts/avg_reward", rewards.mean().item(), global_step)
|
| 318 |
+
writer.add_scalar("charts/avg_value", values.mean().item(), global_step)
|
| 319 |
+
writer.add_scalar("charts/max_reward", rewards.max().item(), global_step)
|
| 320 |
+
writer.add_scalar("charts/min_reward", rewards.min().item(), global_step)
|
| 321 |
+
|
| 322 |
+
# Console output with key metrics
|
| 323 |
+
sps = int(global_step / (time.time() - start_time))
|
| 324 |
+
progress = 100 * iteration / args.num_iterations
|
| 325 |
+
print(f"[{progress:5.1f}%] Iter {iteration:4d}/{args.num_iterations} | "
|
| 326 |
+
f"SPS: {sps:5d} | "
|
| 327 |
+
f"Reward: {rewards.mean().item():6.3f} | "
|
| 328 |
+
f"Value: {values.mean().item():6.3f} | "
|
| 329 |
+
f"VLoss: {v_loss.item():.4f} | "
|
| 330 |
+
f"PLoss: {pg_loss.item():.4f} | "
|
| 331 |
+
f"Ent: {entropy_loss.item():.4f}")
|
| 332 |
+
writer.add_scalar("charts/SPS", sps, global_step)
|
| 333 |
+
|
| 334 |
+
envs.close()
|
| 335 |
+
writer.close()
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/output.log
ADDED
|
@@ -0,0 +1,610 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ 0.2%] Iter 1/610 | SPS: 17989 | Reward: 0.087 | Value: -0.004 | VLoss: 0.0479 | PLoss: -0.0007 | Ent: 0.6929
|
| 2 |
+
[ 0.3%] Iter 2/610 | SPS: 22081 | Reward: 0.084 | Value: 0.127 | VLoss: 0.0450 | PLoss: 0.0001 | Ent: 0.6925
|
| 3 |
+
[ 0.5%] Iter 3/610 | SPS: 23843 | Reward: 0.087 | Value: 0.138 | VLoss: 0.0471 | PLoss: -0.0001 | Ent: 0.6924
|
| 4 |
+
[ 0.7%] Iter 4/610 | SPS: 24871 | Reward: 0.088 | Value: 0.149 | VLoss: 0.0454 | PLoss: -0.0002 | Ent: 0.6919
|
| 5 |
+
[ 0.8%] Iter 5/610 | SPS: 25514 | Reward: 0.088 | Value: 0.167 | VLoss: 0.0455 | PLoss: -0.0000 | Ent: 0.6916
|
| 6 |
+
[ 1.0%] Iter 6/610 | SPS: 25956 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0475 | PLoss: -0.0001 | Ent: 0.6915
|
| 7 |
+
[ 1.1%] Iter 7/610 | SPS: 26293 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0482 | PLoss: -0.0002 | Ent: 0.6912
|
| 8 |
+
[ 1.3%] Iter 8/610 | SPS: 26556 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0472 | PLoss: -0.0001 | Ent: 0.6913
|
| 9 |
+
[ 1.5%] Iter 9/610 | SPS: 26765 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0476 | PLoss: 0.0001 | Ent: 0.6912
|
| 10 |
+
[ 1.6%] Iter 10/610 | SPS: 26925 | Reward: 0.084 | Value: 0.177 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6911
|
| 11 |
+
[ 1.8%] Iter 11/610 | SPS: 27059 | Reward: 0.091 | Value: 0.166 | VLoss: 0.0489 | PLoss: 0.0000 | Ent: 0.6908
|
| 12 |
+
[ 2.0%] Iter 12/610 | SPS: 27177 | Reward: 0.086 | Value: 0.183 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6910
|
| 13 |
+
[ 2.1%] Iter 13/610 | SPS: 27282 | Reward: 0.084 | Value: 0.169 | VLoss: 0.0464 | PLoss: -0.0002 | Ent: 0.6913
|
| 14 |
+
[ 2.3%] Iter 14/610 | SPS: 27352 | Reward: 0.086 | Value: 0.169 | VLoss: 0.0449 | PLoss: -0.0000 | Ent: 0.6918
|
| 15 |
+
[ 2.5%] Iter 15/610 | SPS: 27379 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6923
|
| 16 |
+
[ 2.6%] Iter 16/610 | SPS: 27451 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0493 | PLoss: -0.0001 | Ent: 0.6926
|
| 17 |
+
[ 2.8%] Iter 17/610 | SPS: 27516 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6929
|
| 18 |
+
[ 3.0%] Iter 18/610 | SPS: 27566 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0460 | PLoss: -0.0001 | Ent: 0.6930
|
| 19 |
+
[ 3.1%] Iter 19/610 | SPS: 27600 | Reward: 0.090 | Value: 0.169 | VLoss: 0.0492 | PLoss: -0.0001 | Ent: 0.6931
|
| 20 |
+
[ 3.3%] Iter 20/610 | SPS: 27645 | Reward: 0.088 | Value: 0.180 | VLoss: 0.0461 | PLoss: -0.0002 | Ent: 0.6930
|
| 21 |
+
[ 3.4%] Iter 21/610 | SPS: 27677 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0461 | PLoss: 0.0001 | Ent: 0.6927
|
| 22 |
+
[ 3.6%] Iter 22/610 | SPS: 27715 | Reward: 0.092 | Value: 0.171 | VLoss: 0.0507 | PLoss: -0.0000 | Ent: 0.6926
|
| 23 |
+
[ 3.8%] Iter 23/610 | SPS: 27750 | Reward: 0.083 | Value: 0.184 | VLoss: 0.0424 | PLoss: -0.0001 | Ent: 0.6927
|
| 24 |
+
[ 3.9%] Iter 24/610 | SPS: 27776 | Reward: 0.084 | Value: 0.165 | VLoss: 0.0449 | PLoss: -0.0000 | Ent: 0.6926
|
| 25 |
+
[ 4.1%] Iter 25/610 | SPS: 27777 | Reward: 0.086 | Value: 0.167 | VLoss: 0.0449 | PLoss: -0.0001 | Ent: 0.6926
|
| 26 |
+
[ 4.3%] Iter 26/610 | SPS: 27803 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0460 | PLoss: 0.0001 | Ent: 0.6927
|
| 27 |
+
[ 4.4%] Iter 27/610 | SPS: 27826 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0478 | PLoss: -0.0001 | Ent: 0.6928
|
| 28 |
+
[ 4.6%] Iter 28/610 | SPS: 27848 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0484 | PLoss: -0.0000 | Ent: 0.6929
|
| 29 |
+
[ 4.8%] Iter 29/610 | SPS: 27869 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0449 | PLoss: -0.0001 | Ent: 0.6927
|
| 30 |
+
[ 4.9%] Iter 30/610 | SPS: 27890 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0483 | PLoss: 0.0001 | Ent: 0.6925
|
| 31 |
+
[ 5.1%] Iter 31/610 | SPS: 27887 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6927
|
| 32 |
+
[ 5.2%] Iter 32/610 | SPS: 27879 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0491 | PLoss: -0.0000 | Ent: 0.6927
|
| 33 |
+
[ 5.4%] Iter 33/610 | SPS: 27880 | Reward: 0.085 | Value: 0.175 | VLoss: 0.0437 | PLoss: -0.0001 | Ent: 0.6925
|
| 34 |
+
[ 5.6%] Iter 34/610 | SPS: 27888 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0451 | PLoss: -0.0002 | Ent: 0.6924
|
| 35 |
+
[ 5.7%] Iter 35/610 | SPS: 27892 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0476 | PLoss: -0.0000 | Ent: 0.6923
|
| 36 |
+
[ 5.9%] Iter 36/610 | SPS: 27898 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0450 | PLoss: -0.0001 | Ent: 0.6922
|
| 37 |
+
[ 6.1%] Iter 37/610 | SPS: 27879 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0455 | PLoss: -0.0000 | Ent: 0.6920
|
| 38 |
+
[ 6.2%] Iter 38/610 | SPS: 27886 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0474 | PLoss: -0.0004 | Ent: 0.6915
|
| 39 |
+
[ 6.4%] Iter 39/610 | SPS: 27891 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0485 | PLoss: 0.0002 | Ent: 0.6904
|
| 40 |
+
[ 6.6%] Iter 40/610 | SPS: 27898 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0454 | PLoss: -0.0000 | Ent: 0.6907
|
| 41 |
+
[ 6.7%] Iter 41/610 | SPS: 27905 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0475 | PLoss: 0.0001 | Ent: 0.6916
|
| 42 |
+
[ 6.9%] Iter 42/610 | SPS: 27907 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0462 | PLoss: 0.0000 | Ent: 0.6917
|
| 43 |
+
[ 7.0%] Iter 43/610 | SPS: 27908 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0475 | PLoss: -0.0003 | Ent: 0.6912
|
| 44 |
+
[ 7.2%] Iter 44/610 | SPS: 27910 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0477 | PLoss: -0.0001 | Ent: 0.6913
|
| 45 |
+
[ 7.4%] Iter 45/610 | SPS: 27911 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0458 | PLoss: -0.0005 | Ent: 0.6919
|
| 46 |
+
[ 7.5%] Iter 46/610 | SPS: 27914 | Reward: 0.089 | Value: 0.171 | VLoss: 0.0482 | PLoss: -0.0001 | Ent: 0.6922
|
| 47 |
+
[ 7.7%] Iter 47/610 | SPS: 27920 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0452 | PLoss: -0.0002 | Ent: 0.6924
|
| 48 |
+
[ 7.9%] Iter 48/610 | SPS: 27921 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0478 | PLoss: -0.0001 | Ent: 0.6927
|
| 49 |
+
[ 8.0%] Iter 49/610 | SPS: 27910 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0465 | PLoss: 0.0000 | Ent: 0.6929
|
| 50 |
+
[ 8.2%] Iter 50/610 | SPS: 27906 | Reward: 0.084 | Value: 0.174 | VLoss: 0.0429 | PLoss: 0.0000 | Ent: 0.6930
|
| 51 |
+
[ 8.4%] Iter 51/610 | SPS: 27910 | Reward: 0.086 | Value: 0.167 | VLoss: 0.0459 | PLoss: 0.0002 | Ent: 0.6930
|
| 52 |
+
[ 8.5%] Iter 52/610 | SPS: 27913 | Reward: 0.090 | Value: 0.170 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6930
|
| 53 |
+
[ 8.7%] Iter 53/610 | SPS: 27915 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0489 | PLoss: -0.0002 | Ent: 0.6929
|
| 54 |
+
[ 8.9%] Iter 54/610 | SPS: 27918 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0484 | PLoss: -0.0003 | Ent: 0.6930
|
| 55 |
+
[ 9.0%] Iter 55/610 | SPS: 27922 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0465 | PLoss: -0.0001 | Ent: 0.6931
|
| 56 |
+
[ 9.2%] Iter 56/610 | SPS: 27925 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0461 | PLoss: -0.0002 | Ent: 0.6931
|
| 57 |
+
[ 9.3%] Iter 57/610 | SPS: 27921 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0458 | PLoss: 0.0001 | Ent: 0.6930
|
| 58 |
+
[ 9.5%] Iter 58/610 | SPS: 27923 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0459 | PLoss: -0.0002 | Ent: 0.6928
|
| 59 |
+
[ 9.7%] Iter 59/610 | SPS: 27926 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0457 | PLoss: -0.0000 | Ent: 0.6926
|
| 60 |
+
[ 9.8%] Iter 60/610 | SPS: 27924 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0491 | PLoss: -0.0000 | Ent: 0.6925
|
| 61 |
+
[ 10.0%] Iter 61/610 | SPS: 27919 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0483 | PLoss: -0.0001 | Ent: 0.6922
|
| 62 |
+
[ 10.2%] Iter 62/610 | SPS: 27923 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0457 | PLoss: -0.0000 | Ent: 0.6921
|
| 63 |
+
[ 10.3%] Iter 63/610 | SPS: 27925 | Reward: 0.085 | Value: 0.174 | VLoss: 0.0458 | PLoss: -0.0003 | Ent: 0.6920
|
| 64 |
+
[ 10.5%] Iter 64/610 | SPS: 27928 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0469 | PLoss: -0.0002 | Ent: 0.6916
|
| 65 |
+
[ 10.7%] Iter 65/610 | SPS: 27930 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0001 | Ent: 0.6915
|
| 66 |
+
[ 10.8%] Iter 66/610 | SPS: 27894 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0459 | PLoss: -0.0001 | Ent: 0.6917
|
| 67 |
+
[ 11.0%] Iter 67/610 | SPS: 27895 | Reward: 0.082 | Value: 0.175 | VLoss: 0.0431 | PLoss: -0.0001 | Ent: 0.6917
|
| 68 |
+
[ 11.1%] Iter 68/610 | SPS: 27896 | Reward: 0.088 | Value: 0.165 | VLoss: 0.0473 | PLoss: -0.0001 | Ent: 0.6914
|
| 69 |
+
[ 11.3%] Iter 69/610 | SPS: 27900 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0456 | PLoss: -0.0001 | Ent: 0.6909
|
| 70 |
+
[ 11.5%] Iter 70/610 | SPS: 27902 | Reward: 0.084 | Value: 0.177 | VLoss: 0.0460 | PLoss: -0.0001 | Ent: 0.6904
|
| 71 |
+
[ 11.6%] Iter 71/610 | SPS: 27904 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0477 | PLoss: -0.0000 | Ent: 0.6908
|
| 72 |
+
[ 11.8%] Iter 72/610 | SPS: 27908 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0454 | PLoss: 0.0002 | Ent: 0.6917
|
| 73 |
+
[ 12.0%] Iter 73/610 | SPS: 27910 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0447 | PLoss: -0.0003 | Ent: 0.6919
|
| 74 |
+
[ 12.1%] Iter 74/610 | SPS: 27913 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6923
|
| 75 |
+
[ 12.3%] Iter 75/610 | SPS: 27915 | Reward: 0.085 | Value: 0.170 | VLoss: 0.0476 | PLoss: -0.0002 | Ent: 0.6924
|
| 76 |
+
[ 12.5%] Iter 76/610 | SPS: 27917 | Reward: 0.089 | Value: 0.169 | VLoss: 0.0460 | PLoss: -0.0001 | Ent: 0.6926
|
| 77 |
+
[ 12.6%] Iter 77/610 | SPS: 27919 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0482 | PLoss: 0.0001 | Ent: 0.6926
|
| 78 |
+
[ 12.8%] Iter 78/610 | SPS: 27923 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0474 | PLoss: 0.0000 | Ent: 0.6927
|
| 79 |
+
[ 13.0%] Iter 79/610 | SPS: 27924 | Reward: 0.092 | Value: 0.177 | VLoss: 0.0491 | PLoss: 0.0002 | Ent: 0.6926
|
| 80 |
+
[ 13.1%] Iter 80/610 | SPS: 27925 | Reward: 0.086 | Value: 0.183 | VLoss: 0.0475 | PLoss: -0.0002 | Ent: 0.6925
|
| 81 |
+
[ 13.3%] Iter 81/610 | SPS: 27926 | Reward: 0.090 | Value: 0.174 | VLoss: 0.0475 | PLoss: 0.0000 | Ent: 0.6925
|
| 82 |
+
[ 13.4%] Iter 82/610 | SPS: 27925 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0474 | PLoss: 0.0000 | Ent: 0.6924
|
| 83 |
+
[ 13.6%] Iter 83/610 | SPS: 27918 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0462 | PLoss: -0.0001 | Ent: 0.6921
|
| 84 |
+
[ 13.8%] Iter 84/610 | SPS: 27916 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0428 | PLoss: -0.0000 | Ent: 0.6922
|
| 85 |
+
[ 13.9%] Iter 85/610 | SPS: 27918 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0462 | PLoss: -0.0001 | Ent: 0.6924
|
| 86 |
+
[ 14.1%] Iter 86/610 | SPS: 27920 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6925
|
| 87 |
+
[ 14.3%] Iter 87/610 | SPS: 27920 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0445 | PLoss: 0.0000 | Ent: 0.6926
|
| 88 |
+
[ 14.4%] Iter 88/610 | SPS: 27921 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0472 | PLoss: -0.0000 | Ent: 0.6925
|
| 89 |
+
[ 14.6%] Iter 89/610 | SPS: 27922 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0447 | PLoss: 0.0001 | Ent: 0.6922
|
| 90 |
+
[ 14.8%] Iter 90/610 | SPS: 27925 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0431 | PLoss: -0.0001 | Ent: 0.6920
|
| 91 |
+
[ 14.9%] Iter 91/610 | SPS: 27926 | Reward: 0.091 | Value: 0.175 | VLoss: 0.0493 | PLoss: -0.0001 | Ent: 0.6923
|
| 92 |
+
[ 15.1%] Iter 92/610 | SPS: 27926 | Reward: 0.084 | Value: 0.181 | VLoss: 0.0465 | PLoss: 0.0000 | Ent: 0.6925
|
| 93 |
+
[ 15.2%] Iter 93/610 | SPS: 27928 | Reward: 0.083 | Value: 0.170 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6926
|
| 94 |
+
[ 15.4%] Iter 94/610 | SPS: 27930 | Reward: 0.088 | Value: 0.162 | VLoss: 0.0452 | PLoss: -0.0001 | Ent: 0.6924
|
| 95 |
+
[ 15.6%] Iter 95/610 | SPS: 27932 | Reward: 0.090 | Value: 0.172 | VLoss: 0.0499 | PLoss: -0.0000 | Ent: 0.6924
|
| 96 |
+
[ 15.7%] Iter 96/610 | SPS: 27935 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0469 | PLoss: 0.0000 | Ent: 0.6927
|
| 97 |
+
[ 15.9%] Iter 97/610 | SPS: 27939 | Reward: 0.090 | Value: 0.177 | VLoss: 0.0497 | PLoss: 0.0000 | Ent: 0.6928
|
| 98 |
+
[ 16.1%] Iter 98/610 | SPS: 27941 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0481 | PLoss: -0.0001 | Ent: 0.6929
|
| 99 |
+
[ 16.2%] Iter 99/610 | SPS: 27941 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0490 | PLoss: -0.0001 | Ent: 0.6929
|
| 100 |
+
[ 16.4%] Iter 100/610 | SPS: 27937 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0495 | PLoss: -0.0000 | Ent: 0.6929
|
| 101 |
+
[ 16.6%] Iter 101/610 | SPS: 27937 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0438 | PLoss: -0.0002 | Ent: 0.6930
|
| 102 |
+
[ 16.7%] Iter 102/610 | SPS: 27939 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0001 | Ent: 0.6930
|
| 103 |
+
[ 16.9%] Iter 103/610 | SPS: 27942 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0466 | PLoss: 0.0001 | Ent: 0.6929
|
| 104 |
+
[ 17.0%] Iter 104/610 | SPS: 27942 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0436 | PLoss: -0.0001 | Ent: 0.6929
|
| 105 |
+
[ 17.2%] Iter 105/610 | SPS: 27945 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6929
|
| 106 |
+
[ 17.4%] Iter 106/610 | SPS: 27947 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6929
|
| 107 |
+
[ 17.5%] Iter 107/610 | SPS: 27950 | Reward: 0.091 | Value: 0.172 | VLoss: 0.0497 | PLoss: -0.0003 | Ent: 0.6928
|
| 108 |
+
[ 17.7%] Iter 108/610 | SPS: 27953 | Reward: 0.088 | Value: 0.179 | VLoss: 0.0460 | PLoss: -0.0004 | Ent: 0.6924
|
| 109 |
+
[ 17.9%] Iter 109/610 | SPS: 27955 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0451 | PLoss: -0.0000 | Ent: 0.6921
|
| 110 |
+
[ 18.0%] Iter 110/610 | SPS: 27958 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0485 | PLoss: -0.0000 | Ent: 0.6918
|
| 111 |
+
[ 18.2%] Iter 111/610 | SPS: 27963 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0484 | PLoss: -0.0002 | Ent: 0.6911
|
| 112 |
+
[ 18.4%] Iter 112/610 | SPS: 27969 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6905
|
| 113 |
+
[ 18.5%] Iter 113/610 | SPS: 27975 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6902
|
| 114 |
+
[ 18.7%] Iter 114/610 | SPS: 27981 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0471 | PLoss: -0.0000 | Ent: 0.6909
|
| 115 |
+
[ 18.9%] Iter 115/610 | SPS: 27987 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6920
|
| 116 |
+
[ 19.0%] Iter 116/610 | SPS: 27992 | Reward: 0.085 | Value: 0.171 | VLoss: 0.0455 | PLoss: 0.0001 | Ent: 0.6922
|
| 117 |
+
[ 19.2%] Iter 117/610 | SPS: 27994 | Reward: 0.085 | Value: 0.168 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6923
|
| 118 |
+
[ 19.3%] Iter 118/610 | SPS: 27993 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0482 | PLoss: 0.0000 | Ent: 0.6924
|
| 119 |
+
[ 19.5%] Iter 119/610 | SPS: 27999 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0497 | PLoss: -0.0001 | Ent: 0.6922
|
| 120 |
+
[ 19.7%] Iter 120/610 | SPS: 28005 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0454 | PLoss: 0.0000 | Ent: 0.6921
|
| 121 |
+
[ 19.8%] Iter 121/610 | SPS: 28011 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0494 | PLoss: -0.0000 | Ent: 0.6921
|
| 122 |
+
[ 20.0%] Iter 122/610 | SPS: 28017 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6920
|
| 123 |
+
[ 20.2%] Iter 123/610 | SPS: 28022 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0440 | PLoss: -0.0001 | Ent: 0.6920
|
| 124 |
+
[ 20.3%] Iter 124/610 | SPS: 28027 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0488 | PLoss: -0.0000 | Ent: 0.6921
|
| 125 |
+
[ 20.5%] Iter 125/610 | SPS: 28033 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0475 | PLoss: -0.0001 | Ent: 0.6923
|
| 126 |
+
[ 20.7%] Iter 126/610 | SPS: 28037 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0464 | PLoss: -0.0002 | Ent: 0.6926
|
| 127 |
+
[ 20.8%] Iter 127/610 | SPS: 28040 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0489 | PLoss: 0.0000 | Ent: 0.6925
|
| 128 |
+
[ 21.0%] Iter 128/610 | SPS: 28045 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0466 | PLoss: 0.0001 | Ent: 0.6923
|
| 129 |
+
[ 21.1%] Iter 129/610 | SPS: 28050 | Reward: 0.085 | Value: 0.172 | VLoss: 0.0467 | PLoss: -0.0001 | Ent: 0.6923
|
| 130 |
+
[ 21.3%] Iter 130/610 | SPS: 28054 | Reward: 0.084 | Value: 0.170 | VLoss: 0.0436 | PLoss: -0.0001 | Ent: 0.6920
|
| 131 |
+
[ 21.5%] Iter 131/610 | SPS: 28058 | Reward: 0.088 | Value: 0.166 | VLoss: 0.0476 | PLoss: -0.0001 | Ent: 0.6921
|
| 132 |
+
[ 21.6%] Iter 132/610 | SPS: 28063 | Reward: 0.091 | Value: 0.172 | VLoss: 0.0480 | PLoss: -0.0002 | Ent: 0.6924
|
| 133 |
+
[ 21.8%] Iter 133/610 | SPS: 28067 | Reward: 0.087 | Value: 0.180 | VLoss: 0.0454 | PLoss: 0.0000 | Ent: 0.6924
|
| 134 |
+
[ 22.0%] Iter 134/610 | SPS: 28071 | Reward: 0.090 | Value: 0.175 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6923
|
| 135 |
+
[ 22.1%] Iter 135/610 | SPS: 28064 | Reward: 0.085 | Value: 0.179 | VLoss: 0.0457 | PLoss: -0.0001 | Ent: 0.6920
|
| 136 |
+
[ 22.3%] Iter 136/610 | SPS: 28063 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0473 | PLoss: -0.0001 | Ent: 0.6916
|
| 137 |
+
[ 22.5%] Iter 137/610 | SPS: 28063 | Reward: 0.086 | Value: 0.168 | VLoss: 0.0473 | PLoss: 0.0000 | Ent: 0.6916
|
| 138 |
+
[ 22.6%] Iter 138/610 | SPS: 28062 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0465 | PLoss: 0.0001 | Ent: 0.6918
|
| 139 |
+
[ 22.8%] Iter 139/610 | SPS: 28062 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0444 | PLoss: -0.0001 | Ent: 0.6917
|
| 140 |
+
[ 23.0%] Iter 140/610 | SPS: 28063 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0464 | PLoss: -0.0001 | Ent: 0.6916
|
| 141 |
+
[ 23.1%] Iter 141/610 | SPS: 28064 | Reward: 0.089 | Value: 0.171 | VLoss: 0.0479 | PLoss: -0.0000 | Ent: 0.6914
|
| 142 |
+
[ 23.3%] Iter 142/610 | SPS: 28065 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0478 | PLoss: -0.0001 | Ent: 0.6915
|
| 143 |
+
[ 23.4%] Iter 143/610 | SPS: 28066 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0490 | PLoss: -0.0000 | Ent: 0.6909
|
| 144 |
+
[ 23.6%] Iter 144/610 | SPS: 28066 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0472 | PLoss: 0.0000 | Ent: 0.6908
|
| 145 |
+
[ 23.8%] Iter 145/610 | SPS: 28067 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6909
|
| 146 |
+
[ 23.9%] Iter 146/610 | SPS: 28066 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0506 | PLoss: -0.0001 | Ent: 0.6911
|
| 147 |
+
[ 24.1%] Iter 147/610 | SPS: 28067 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0479 | PLoss: -0.0001 | Ent: 0.6915
|
| 148 |
+
[ 24.3%] Iter 148/610 | SPS: 28067 | Reward: 0.084 | Value: 0.173 | VLoss: 0.0424 | PLoss: -0.0000 | Ent: 0.6916
|
| 149 |
+
[ 24.4%] Iter 149/610 | SPS: 28068 | Reward: 0.086 | Value: 0.168 | VLoss: 0.0473 | PLoss: -0.0000 | Ent: 0.6914
|
| 150 |
+
[ 24.6%] Iter 150/610 | SPS: 28068 | Reward: 0.087 | Value: 0.168 | VLoss: 0.0483 | PLoss: -0.0004 | Ent: 0.6914
|
| 151 |
+
[ 24.8%] Iter 151/610 | SPS: 28069 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0455 | PLoss: -0.0000 | Ent: 0.6916
|
| 152 |
+
[ 24.9%] Iter 152/610 | SPS: 28066 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0492 | PLoss: -0.0002 | Ent: 0.6917
|
| 153 |
+
[ 25.1%] Iter 153/610 | SPS: 28063 | Reward: 0.092 | Value: 0.176 | VLoss: 0.0498 | PLoss: -0.0000 | Ent: 0.6918
|
| 154 |
+
[ 25.2%] Iter 154/610 | SPS: 28066 | Reward: 0.089 | Value: 0.181 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6919
|
| 155 |
+
[ 25.4%] Iter 155/610 | SPS: 28069 | Reward: 0.085 | Value: 0.179 | VLoss: 0.0435 | PLoss: -0.0000 | Ent: 0.6919
|
| 156 |
+
[ 25.6%] Iter 156/610 | SPS: 28071 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0453 | PLoss: 0.0001 | Ent: 0.6920
|
| 157 |
+
[ 25.7%] Iter 157/610 | SPS: 28074 | Reward: 0.090 | Value: 0.172 | VLoss: 0.0492 | PLoss: -0.0001 | Ent: 0.6921
|
| 158 |
+
[ 25.9%] Iter 158/610 | SPS: 28076 | Reward: 0.088 | Value: 0.179 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6921
|
| 159 |
+
[ 26.1%] Iter 159/610 | SPS: 28080 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0472 | PLoss: -0.0000 | Ent: 0.6921
|
| 160 |
+
[ 26.2%] Iter 160/610 | SPS: 28082 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6920
|
| 161 |
+
[ 26.4%] Iter 161/610 | SPS: 28085 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0478 | PLoss: 0.0000 | Ent: 0.6915
|
| 162 |
+
[ 26.6%] Iter 162/610 | SPS: 28088 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0476 | PLoss: 0.0000 | Ent: 0.6912
|
| 163 |
+
[ 26.7%] Iter 163/610 | SPS: 28090 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0467 | PLoss: 0.0000 | Ent: 0.6909
|
| 164 |
+
[ 26.9%] Iter 164/610 | SPS: 28093 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0466 | PLoss: -0.0001 | Ent: 0.6905
|
| 165 |
+
[ 27.0%] Iter 165/610 | SPS: 28093 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0486 | PLoss: -0.0002 | Ent: 0.6908
|
| 166 |
+
[ 27.2%] Iter 166/610 | SPS: 28093 | Reward: 0.089 | Value: 0.171 | VLoss: 0.0492 | PLoss: 0.0000 | Ent: 0.6914
|
| 167 |
+
[ 27.4%] Iter 167/610 | SPS: 28093 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6918
|
| 168 |
+
[ 27.5%] Iter 168/610 | SPS: 28093 | Reward: 0.086 | Value: 0.178 | VLoss: 0.0448 | PLoss: -0.0001 | Ent: 0.6921
|
| 169 |
+
[ 27.7%] Iter 169/610 | SPS: 28091 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0472 | PLoss: -0.0003 | Ent: 0.6923
|
| 170 |
+
[ 27.9%] Iter 170/610 | SPS: 28089 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0475 | PLoss: -0.0001 | Ent: 0.6925
|
| 171 |
+
[ 28.0%] Iter 171/610 | SPS: 28089 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0457 | PLoss: 0.0001 | Ent: 0.6927
|
| 172 |
+
[ 28.2%] Iter 172/610 | SPS: 28090 | Reward: 0.085 | Value: 0.172 | VLoss: 0.0464 | PLoss: 0.0001 | Ent: 0.6926
|
| 173 |
+
[ 28.4%] Iter 173/610 | SPS: 28091 | Reward: 0.088 | Value: 0.169 | VLoss: 0.0453 | PLoss: -0.0001 | Ent: 0.6924
|
| 174 |
+
[ 28.5%] Iter 174/610 | SPS: 28094 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0461 | PLoss: -0.0001 | Ent: 0.6923
|
| 175 |
+
[ 28.7%] Iter 175/610 | SPS: 28097 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0456 | PLoss: -0.0000 | Ent: 0.6924
|
| 176 |
+
[ 28.9%] Iter 176/610 | SPS: 28101 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0468 | PLoss: -0.0002 | Ent: 0.6925
|
| 177 |
+
[ 29.0%] Iter 177/610 | SPS: 28103 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0457 | PLoss: 0.0000 | Ent: 0.6926
|
| 178 |
+
[ 29.2%] Iter 178/610 | SPS: 28106 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0452 | PLoss: 0.0000 | Ent: 0.6927
|
| 179 |
+
[ 29.3%] Iter 179/610 | SPS: 28109 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0500 | PLoss: -0.0001 | Ent: 0.6928
|
| 180 |
+
[ 29.5%] Iter 180/610 | SPS: 28111 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0439 | PLoss: -0.0001 | Ent: 0.6927
|
| 181 |
+
[ 29.7%] Iter 181/610 | SPS: 28114 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0456 | PLoss: 0.0001 | Ent: 0.6928
|
| 182 |
+
[ 29.8%] Iter 182/610 | SPS: 28117 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0459 | PLoss: 0.0001 | Ent: 0.6928
|
| 183 |
+
[ 30.0%] Iter 183/610 | SPS: 28120 | Reward: 0.091 | Value: 0.172 | VLoss: 0.0504 | PLoss: -0.0001 | Ent: 0.6930
|
| 184 |
+
[ 30.2%] Iter 184/610 | SPS: 28122 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0493 | PLoss: -0.0002 | Ent: 0.6930
|
| 185 |
+
[ 30.3%] Iter 185/610 | SPS: 28125 | Reward: 0.084 | Value: 0.174 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6930
|
| 186 |
+
[ 30.5%] Iter 186/610 | SPS: 28128 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0476 | PLoss: 0.0000 | Ent: 0.6930
|
| 187 |
+
[ 30.7%] Iter 187/610 | SPS: 28113 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0455 | PLoss: -0.0000 | Ent: 0.6930
|
| 188 |
+
[ 30.8%] Iter 188/610 | SPS: 28117 | Reward: 0.085 | Value: 0.175 | VLoss: 0.0447 | PLoss: -0.0000 | Ent: 0.6930
|
| 189 |
+
[ 31.0%] Iter 189/610 | SPS: 28121 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0474 | PLoss: 0.0000 | Ent: 0.6931
|
| 190 |
+
[ 31.1%] Iter 190/610 | SPS: 28125 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0484 | PLoss: -0.0001 | Ent: 0.6931
|
| 191 |
+
[ 31.3%] Iter 191/610 | SPS: 28129 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0461 | PLoss: -0.0001 | Ent: 0.6930
|
| 192 |
+
[ 31.5%] Iter 192/610 | SPS: 28132 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0451 | PLoss: -0.0000 | Ent: 0.6930
|
| 193 |
+
[ 31.6%] Iter 193/610 | SPS: 28135 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6930
|
| 194 |
+
[ 31.8%] Iter 194/610 | SPS: 28139 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0471 | PLoss: 0.0000 | Ent: 0.6929
|
| 195 |
+
[ 32.0%] Iter 195/610 | SPS: 28142 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0445 | PLoss: -0.0002 | Ent: 0.6929
|
| 196 |
+
[ 32.1%] Iter 196/610 | SPS: 28145 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0479 | PLoss: -0.0000 | Ent: 0.6930
|
| 197 |
+
[ 32.3%] Iter 197/610 | SPS: 28149 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0481 | PLoss: -0.0000 | Ent: 0.6930
|
| 198 |
+
[ 32.5%] Iter 198/610 | SPS: 28152 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0488 | PLoss: -0.0004 | Ent: 0.6930
|
| 199 |
+
[ 32.6%] Iter 199/610 | SPS: 28155 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0006 | Ent: 0.6928
|
| 200 |
+
[ 32.8%] Iter 200/610 | SPS: 28159 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0476 | PLoss: 0.0000 | Ent: 0.6927
|
| 201 |
+
[ 33.0%] Iter 201/610 | SPS: 28162 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0483 | PLoss: -0.0001 | Ent: 0.6927
|
| 202 |
+
[ 33.1%] Iter 202/610 | SPS: 28165 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0487 | PLoss: -0.0001 | Ent: 0.6927
|
| 203 |
+
[ 33.3%] Iter 203/610 | SPS: 28169 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0475 | PLoss: 0.0000 | Ent: 0.6926
|
| 204 |
+
[ 33.4%] Iter 204/610 | SPS: 28169 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0458 | PLoss: 0.0000 | Ent: 0.6928
|
| 205 |
+
[ 33.6%] Iter 205/610 | SPS: 28166 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6926
|
| 206 |
+
[ 33.8%] Iter 206/610 | SPS: 28166 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0433 | PLoss: -0.0001 | Ent: 0.6925
|
| 207 |
+
[ 33.9%] Iter 207/610 | SPS: 28166 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0462 | PLoss: -0.0001 | Ent: 0.6926
|
| 208 |
+
[ 34.1%] Iter 208/610 | SPS: 28167 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6925
|
| 209 |
+
[ 34.3%] Iter 209/610 | SPS: 28167 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0517 | PLoss: 0.0001 | Ent: 0.6924
|
| 210 |
+
[ 34.4%] Iter 210/610 | SPS: 28168 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0413 | PLoss: -0.0000 | Ent: 0.6925
|
| 211 |
+
[ 34.6%] Iter 211/610 | SPS: 28169 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0480 | PLoss: -0.0002 | Ent: 0.6924
|
| 212 |
+
[ 34.8%] Iter 212/610 | SPS: 28169 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0463 | PLoss: -0.0001 | Ent: 0.6921
|
| 213 |
+
[ 34.9%] Iter 213/610 | SPS: 28169 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0481 | PLoss: -0.0000 | Ent: 0.6920
|
| 214 |
+
[ 35.1%] Iter 214/610 | SPS: 28169 | Reward: 0.085 | Value: 0.175 | VLoss: 0.0455 | PLoss: -0.0003 | Ent: 0.6924
|
| 215 |
+
[ 35.2%] Iter 215/610 | SPS: 28168 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0445 | PLoss: 0.0000 | Ent: 0.6925
|
| 216 |
+
[ 35.4%] Iter 216/610 | SPS: 28167 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0457 | PLoss: -0.0001 | Ent: 0.6924
|
| 217 |
+
[ 35.6%] Iter 217/610 | SPS: 28166 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0473 | PLoss: -0.0001 | Ent: 0.6921
|
| 218 |
+
[ 35.7%] Iter 218/610 | SPS: 28166 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0491 | PLoss: 0.0000 | Ent: 0.6920
|
| 219 |
+
[ 35.9%] Iter 219/610 | SPS: 28166 | Reward: 0.085 | Value: 0.175 | VLoss: 0.0456 | PLoss: -0.0002 | Ent: 0.6919
|
| 220 |
+
[ 36.1%] Iter 220/610 | SPS: 28167 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0464 | PLoss: 0.0000 | Ent: 0.6915
|
| 221 |
+
[ 36.2%] Iter 221/610 | SPS: 28167 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0448 | PLoss: -0.0004 | Ent: 0.6906
|
| 222 |
+
[ 36.4%] Iter 222/610 | SPS: 28164 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0482 | PLoss: -0.0001 | Ent: 0.6901
|
| 223 |
+
[ 36.6%] Iter 223/610 | SPS: 28164 | Reward: 0.090 | Value: 0.175 | VLoss: 0.0478 | PLoss: 0.0001 | Ent: 0.6906
|
| 224 |
+
[ 36.7%] Iter 224/610 | SPS: 28164 | Reward: 0.091 | Value: 0.178 | VLoss: 0.0479 | PLoss: -0.0002 | Ent: 0.6915
|
| 225 |
+
[ 36.9%] Iter 225/610 | SPS: 28164 | Reward: 0.090 | Value: 0.183 | VLoss: 0.0489 | PLoss: 0.0000 | Ent: 0.6918
|
| 226 |
+
[ 37.0%] Iter 226/610 | SPS: 28164 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0468 | PLoss: -0.0002 | Ent: 0.6920
|
| 227 |
+
[ 37.2%] Iter 227/610 | SPS: 28164 | Reward: 0.084 | Value: 0.175 | VLoss: 0.0471 | PLoss: -0.0001 | Ent: 0.6918
|
| 228 |
+
[ 37.4%] Iter 228/610 | SPS: 28164 | Reward: 0.089 | Value: 0.167 | VLoss: 0.0493 | PLoss: -0.0000 | Ent: 0.6918
|
| 229 |
+
[ 37.5%] Iter 229/610 | SPS: 28163 | Reward: 0.084 | Value: 0.173 | VLoss: 0.0466 | PLoss: 0.0000 | Ent: 0.6918
|
| 230 |
+
[ 37.7%] Iter 230/610 | SPS: 28163 | Reward: 0.087 | Value: 0.168 | VLoss: 0.0471 | PLoss: -0.0001 | Ent: 0.6922
|
| 231 |
+
[ 37.9%] Iter 231/610 | SPS: 28162 | Reward: 0.083 | Value: 0.169 | VLoss: 0.0432 | PLoss: -0.0002 | Ent: 0.6924
|
| 232 |
+
[ 38.0%] Iter 232/610 | SPS: 28162 | Reward: 0.087 | Value: 0.167 | VLoss: 0.0477 | PLoss: -0.0002 | Ent: 0.6922
|
| 233 |
+
[ 38.2%] Iter 233/610 | SPS: 28161 | Reward: 0.090 | Value: 0.170 | VLoss: 0.0493 | PLoss: -0.0001 | Ent: 0.6921
|
| 234 |
+
[ 38.4%] Iter 234/610 | SPS: 28161 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6919
|
| 235 |
+
[ 38.5%] Iter 235/610 | SPS: 28161 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0482 | PLoss: -0.0000 | Ent: 0.6920
|
| 236 |
+
[ 38.7%] Iter 236/610 | SPS: 28161 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0495 | PLoss: -0.0000 | Ent: 0.6922
|
| 237 |
+
[ 38.9%] Iter 237/610 | SPS: 28160 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0487 | PLoss: 0.0000 | Ent: 0.6923
|
| 238 |
+
[ 39.0%] Iter 238/610 | SPS: 28158 | Reward: 0.085 | Value: 0.175 | VLoss: 0.0449 | PLoss: -0.0001 | Ent: 0.6922
|
| 239 |
+
[ 39.2%] Iter 239/610 | SPS: 28154 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0461 | PLoss: 0.0000 | Ent: 0.6922
|
| 240 |
+
[ 39.3%] Iter 240/610 | SPS: 28153 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0478 | PLoss: -0.0001 | Ent: 0.6922
|
| 241 |
+
[ 39.5%] Iter 241/610 | SPS: 28152 | Reward: 0.085 | Value: 0.176 | VLoss: 0.0444 | PLoss: -0.0001 | Ent: 0.6922
|
| 242 |
+
[ 39.7%] Iter 242/610 | SPS: 28152 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6924
|
| 243 |
+
[ 39.8%] Iter 243/610 | SPS: 28152 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0461 | PLoss: 0.0000 | Ent: 0.6925
|
| 244 |
+
[ 40.0%] Iter 244/610 | SPS: 28151 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0465 | PLoss: -0.0001 | Ent: 0.6925
|
| 245 |
+
[ 40.2%] Iter 245/610 | SPS: 28151 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0487 | PLoss: 0.0000 | Ent: 0.6925
|
| 246 |
+
[ 40.3%] Iter 246/610 | SPS: 28151 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0466 | PLoss: -0.0002 | Ent: 0.6926
|
| 247 |
+
[ 40.5%] Iter 247/610 | SPS: 28150 | Reward: 0.091 | Value: 0.174 | VLoss: 0.0485 | PLoss: 0.0000 | Ent: 0.6926
|
| 248 |
+
[ 40.7%] Iter 248/610 | SPS: 28150 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0463 | PLoss: -0.0001 | Ent: 0.6925
|
| 249 |
+
[ 40.8%] Iter 249/610 | SPS: 28148 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0462 | PLoss: 0.0000 | Ent: 0.6924
|
| 250 |
+
[ 41.0%] Iter 250/610 | SPS: 28148 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0449 | PLoss: -0.0001 | Ent: 0.6923
|
| 251 |
+
[ 41.1%] Iter 251/610 | SPS: 28146 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6921
|
| 252 |
+
[ 41.3%] Iter 252/610 | SPS: 28146 | Reward: 0.091 | Value: 0.174 | VLoss: 0.0484 | PLoss: -0.0000 | Ent: 0.6919
|
| 253 |
+
[ 41.5%] Iter 253/610 | SPS: 28145 | Reward: 0.088 | Value: 0.182 | VLoss: 0.0487 | PLoss: -0.0001 | Ent: 0.6919
|
| 254 |
+
[ 41.6%] Iter 254/610 | SPS: 28145 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6919
|
| 255 |
+
[ 41.8%] Iter 255/610 | SPS: 28143 | Reward: 0.090 | Value: 0.169 | VLoss: 0.0436 | PLoss: -0.0000 | Ent: 0.6919
|
| 256 |
+
[ 42.0%] Iter 256/610 | SPS: 28142 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0454 | PLoss: -0.0001 | Ent: 0.6919
|
| 257 |
+
[ 42.1%] Iter 257/610 | SPS: 28144 | Reward: 0.086 | Value: 0.178 | VLoss: 0.0454 | PLoss: -0.0001 | Ent: 0.6918
|
| 258 |
+
[ 42.3%] Iter 258/610 | SPS: 28145 | Reward: 0.085 | Value: 0.171 | VLoss: 0.0428 | PLoss: -0.0001 | Ent: 0.6918
|
| 259 |
+
[ 42.5%] Iter 259/610 | SPS: 28147 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0457 | PLoss: -0.0001 | Ent: 0.6917
|
| 260 |
+
[ 42.6%] Iter 260/610 | SPS: 28148 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6919
|
| 261 |
+
[ 42.8%] Iter 261/610 | SPS: 28149 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0468 | PLoss: 0.0000 | Ent: 0.6919
|
| 262 |
+
[ 43.0%] Iter 262/610 | SPS: 28150 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6919
|
| 263 |
+
[ 43.1%] Iter 263/610 | SPS: 28152 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0465 | PLoss: -0.0001 | Ent: 0.6918
|
| 264 |
+
[ 43.3%] Iter 264/610 | SPS: 28153 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0498 | PLoss: -0.0000 | Ent: 0.6917
|
| 265 |
+
[ 43.4%] Iter 265/610 | SPS: 28155 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6917
|
| 266 |
+
[ 43.6%] Iter 266/610 | SPS: 28157 | Reward: 0.085 | Value: 0.174 | VLoss: 0.0461 | PLoss: -0.0002 | Ent: 0.6920
|
| 267 |
+
[ 43.8%] Iter 267/610 | SPS: 28159 | Reward: 0.089 | Value: 0.167 | VLoss: 0.0503 | PLoss: 0.0000 | Ent: 0.6921
|
| 268 |
+
[ 43.9%] Iter 268/610 | SPS: 28160 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0484 | PLoss: -0.0002 | Ent: 0.6924
|
| 269 |
+
[ 44.1%] Iter 269/610 | SPS: 28162 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0457 | PLoss: 0.0000 | Ent: 0.6926
|
| 270 |
+
[ 44.3%] Iter 270/610 | SPS: 28163 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0446 | PLoss: -0.0000 | Ent: 0.6926
|
| 271 |
+
[ 44.4%] Iter 271/610 | SPS: 28165 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0441 | PLoss: -0.0001 | Ent: 0.6927
|
| 272 |
+
[ 44.6%] Iter 272/610 | SPS: 28167 | Reward: 0.084 | Value: 0.170 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6923
|
| 273 |
+
[ 44.8%] Iter 273/610 | SPS: 28167 | Reward: 0.086 | Value: 0.168 | VLoss: 0.0458 | PLoss: 0.0001 | Ent: 0.6918
|
| 274 |
+
[ 44.9%] Iter 274/610 | SPS: 28168 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0478 | PLoss: 0.0000 | Ent: 0.6913
|
| 275 |
+
[ 45.1%] Iter 275/610 | SPS: 28170 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0463 | PLoss: -0.0001 | Ent: 0.6905
|
| 276 |
+
[ 45.2%] Iter 276/610 | SPS: 28171 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0477 | PLoss: 0.0000 | Ent: 0.6905
|
| 277 |
+
[ 45.4%] Iter 277/610 | SPS: 28172 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0462 | PLoss: -0.0001 | Ent: 0.6908
|
| 278 |
+
[ 45.6%] Iter 278/610 | SPS: 28173 | Reward: 0.087 | Value: 0.171 | VLoss: 0.0470 | PLoss: 0.0001 | Ent: 0.6910
|
| 279 |
+
[ 45.7%] Iter 279/610 | SPS: 28175 | Reward: 0.090 | Value: 0.170 | VLoss: 0.0495 | PLoss: -0.0001 | Ent: 0.6911
|
| 280 |
+
[ 45.9%] Iter 280/610 | SPS: 28177 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0437 | PLoss: -0.0002 | Ent: 0.6910
|
| 281 |
+
[ 46.1%] Iter 281/610 | SPS: 28178 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6905
|
| 282 |
+
[ 46.2%] Iter 282/610 | SPS: 28180 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0440 | PLoss: -0.0001 | Ent: 0.6901
|
| 283 |
+
[ 46.4%] Iter 283/610 | SPS: 28182 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0468 | PLoss: -0.0001 | Ent: 0.6897
|
| 284 |
+
[ 46.6%] Iter 284/610 | SPS: 28183 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0443 | PLoss: -0.0000 | Ent: 0.6901
|
| 285 |
+
[ 46.7%] Iter 285/610 | SPS: 28185 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0459 | PLoss: -0.0002 | Ent: 0.6908
|
| 286 |
+
[ 46.9%] Iter 286/610 | SPS: 28187 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0443 | PLoss: 0.0000 | Ent: 0.6913
|
| 287 |
+
[ 47.0%] Iter 287/610 | SPS: 28189 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6914
|
| 288 |
+
[ 47.2%] Iter 288/610 | SPS: 28190 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0465 | PLoss: -0.0000 | Ent: 0.6916
|
| 289 |
+
[ 47.4%] Iter 289/610 | SPS: 28192 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0468 | PLoss: -0.0001 | Ent: 0.6919
|
| 290 |
+
[ 47.5%] Iter 290/610 | SPS: 28193 | Reward: 0.085 | Value: 0.171 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6918
|
| 291 |
+
[ 47.7%] Iter 291/610 | SPS: 28193 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6916
|
| 292 |
+
[ 47.9%] Iter 292/610 | SPS: 28180 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6918
|
| 293 |
+
[ 48.0%] Iter 293/610 | SPS: 28182 | Reward: 0.092 | Value: 0.178 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6918
|
| 294 |
+
[ 48.2%] Iter 294/610 | SPS: 28185 | Reward: 0.088 | Value: 0.185 | VLoss: 0.0492 | PLoss: -0.0001 | Ent: 0.6920
|
| 295 |
+
[ 48.4%] Iter 295/610 | SPS: 28187 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0474 | PLoss: -0.0003 | Ent: 0.6923
|
| 296 |
+
[ 48.5%] Iter 296/610 | SPS: 28190 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6925
|
| 297 |
+
[ 48.7%] Iter 297/610 | SPS: 28192 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0485 | PLoss: -0.0000 | Ent: 0.6926
|
| 298 |
+
[ 48.9%] Iter 298/610 | SPS: 28194 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6927
|
| 299 |
+
[ 49.0%] Iter 299/610 | SPS: 28197 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6927
|
| 300 |
+
[ 49.2%] Iter 300/610 | SPS: 28198 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0443 | PLoss: -0.0000 | Ent: 0.6928
|
| 301 |
+
[ 49.3%] Iter 301/610 | SPS: 28199 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0447 | PLoss: -0.0001 | Ent: 0.6928
|
| 302 |
+
[ 49.5%] Iter 302/610 | SPS: 28200 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0460 | PLoss: -0.0003 | Ent: 0.6929
|
| 303 |
+
[ 49.7%] Iter 303/610 | SPS: 28202 | Reward: 0.084 | Value: 0.177 | VLoss: 0.0429 | PLoss: 0.0000 | Ent: 0.6929
|
| 304 |
+
[ 49.8%] Iter 304/610 | SPS: 28203 | Reward: 0.088 | Value: 0.169 | VLoss: 0.0466 | PLoss: -0.0001 | Ent: 0.6929
|
| 305 |
+
[ 50.0%] Iter 305/610 | SPS: 28205 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6929
|
| 306 |
+
[ 50.2%] Iter 306/610 | SPS: 28207 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6929
|
| 307 |
+
[ 50.3%] Iter 307/610 | SPS: 28208 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0450 | PLoss: -0.0001 | Ent: 0.6929
|
| 308 |
+
[ 50.5%] Iter 308/610 | SPS: 28206 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6928
|
| 309 |
+
[ 50.7%] Iter 309/610 | SPS: 28207 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0456 | PLoss: -0.0000 | Ent: 0.6929
|
| 310 |
+
[ 50.8%] Iter 310/610 | SPS: 28209 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0482 | PLoss: -0.0001 | Ent: 0.6928
|
| 311 |
+
[ 51.0%] Iter 311/610 | SPS: 28210 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6928
|
| 312 |
+
[ 51.1%] Iter 312/610 | SPS: 28209 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6928
|
| 313 |
+
[ 51.3%] Iter 313/610 | SPS: 28210 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0466 | PLoss: 0.0000 | Ent: 0.6928
|
| 314 |
+
[ 51.5%] Iter 314/610 | SPS: 28211 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0458 | PLoss: 0.0000 | Ent: 0.6927
|
| 315 |
+
[ 51.6%] Iter 315/610 | SPS: 28213 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0469 | PLoss: 0.0000 | Ent: 0.6927
|
| 316 |
+
[ 51.8%] Iter 316/610 | SPS: 28214 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0451 | PLoss: 0.0000 | Ent: 0.6926
|
| 317 |
+
[ 52.0%] Iter 317/610 | SPS: 28215 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0447 | PLoss: -0.0001 | Ent: 0.6926
|
| 318 |
+
[ 52.1%] Iter 318/610 | SPS: 28216 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0450 | PLoss: 0.0000 | Ent: 0.6923
|
| 319 |
+
[ 52.3%] Iter 319/610 | SPS: 28213 | Reward: 0.085 | Value: 0.171 | VLoss: 0.0425 | PLoss: 0.0000 | Ent: 0.6921
|
| 320 |
+
[ 52.5%] Iter 320/610 | SPS: 28214 | Reward: 0.088 | Value: 0.169 | VLoss: 0.0475 | PLoss: -0.0000 | Ent: 0.6921
|
| 321 |
+
[ 52.6%] Iter 321/610 | SPS: 28215 | Reward: 0.092 | Value: 0.176 | VLoss: 0.0518 | PLoss: 0.0001 | Ent: 0.6922
|
| 322 |
+
[ 52.8%] Iter 322/610 | SPS: 28216 | Reward: 0.087 | Value: 0.182 | VLoss: 0.0458 | PLoss: -0.0001 | Ent: 0.6923
|
| 323 |
+
[ 53.0%] Iter 323/610 | SPS: 28217 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0480 | PLoss: -0.0000 | Ent: 0.6924
|
| 324 |
+
[ 53.1%] Iter 324/610 | SPS: 28218 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0480 | PLoss: 0.0000 | Ent: 0.6924
|
| 325 |
+
[ 53.3%] Iter 325/610 | SPS: 28217 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0468 | PLoss: -0.0001 | Ent: 0.6924
|
| 326 |
+
[ 53.4%] Iter 326/610 | SPS: 28217 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0480 | PLoss: -0.0000 | Ent: 0.6924
|
| 327 |
+
[ 53.6%] Iter 327/610 | SPS: 28218 | Reward: 0.090 | Value: 0.170 | VLoss: 0.0500 | PLoss: -0.0000 | Ent: 0.6924
|
| 328 |
+
[ 53.8%] Iter 328/610 | SPS: 28218 | Reward: 0.088 | Value: 0.179 | VLoss: 0.0457 | PLoss: -0.0000 | Ent: 0.6926
|
| 329 |
+
[ 53.9%] Iter 329/610 | SPS: 28219 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0451 | PLoss: -0.0001 | Ent: 0.6927
|
| 330 |
+
[ 54.1%] Iter 330/610 | SPS: 28220 | Reward: 0.088 | Value: 0.169 | VLoss: 0.0465 | PLoss: -0.0000 | Ent: 0.6927
|
| 331 |
+
[ 54.3%] Iter 331/610 | SPS: 28221 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0439 | PLoss: -0.0001 | Ent: 0.6927
|
| 332 |
+
[ 54.4%] Iter 332/610 | SPS: 28223 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0465 | PLoss: -0.0000 | Ent: 0.6927
|
| 333 |
+
[ 54.6%] Iter 333/610 | SPS: 28224 | Reward: 0.085 | Value: 0.169 | VLoss: 0.0498 | PLoss: -0.0000 | Ent: 0.6928
|
| 334 |
+
[ 54.8%] Iter 334/610 | SPS: 28225 | Reward: 0.089 | Value: 0.168 | VLoss: 0.0473 | PLoss: -0.0001 | Ent: 0.6927
|
| 335 |
+
[ 54.9%] Iter 335/610 | SPS: 28226 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0477 | PLoss: -0.0000 | Ent: 0.6927
|
| 336 |
+
[ 55.1%] Iter 336/610 | SPS: 28227 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0475 | PLoss: -0.0001 | Ent: 0.6928
|
| 337 |
+
[ 55.2%] Iter 337/610 | SPS: 28228 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6929
|
| 338 |
+
[ 55.4%] Iter 338/610 | SPS: 28229 | Reward: 0.085 | Value: 0.174 | VLoss: 0.0435 | PLoss: -0.0001 | Ent: 0.6928
|
| 339 |
+
[ 55.6%] Iter 339/610 | SPS: 28229 | Reward: 0.087 | Value: 0.169 | VLoss: 0.0453 | PLoss: 0.0000 | Ent: 0.6927
|
| 340 |
+
[ 55.7%] Iter 340/610 | SPS: 28231 | Reward: 0.083 | Value: 0.173 | VLoss: 0.0439 | PLoss: -0.0000 | Ent: 0.6927
|
| 341 |
+
[ 55.9%] Iter 341/610 | SPS: 28231 | Reward: 0.089 | Value: 0.165 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6928
|
| 342 |
+
[ 56.1%] Iter 342/610 | SPS: 28231 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0490 | PLoss: -0.0001 | Ent: 0.6929
|
| 343 |
+
[ 56.2%] Iter 343/610 | SPS: 28221 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6929
|
| 344 |
+
[ 56.4%] Iter 344/610 | SPS: 28220 | Reward: 0.091 | Value: 0.172 | VLoss: 0.0501 | PLoss: 0.0000 | Ent: 0.6929
|
| 345 |
+
[ 56.6%] Iter 345/610 | SPS: 28218 | Reward: 0.086 | Value: 0.181 | VLoss: 0.0462 | PLoss: -0.0001 | Ent: 0.6928
|
| 346 |
+
[ 56.7%] Iter 346/610 | SPS: 28216 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0470 | PLoss: 0.0000 | Ent: 0.6929
|
| 347 |
+
[ 56.9%] Iter 347/610 | SPS: 28214 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0462 | PLoss: 0.0001 | Ent: 0.6929
|
| 348 |
+
[ 57.0%] Iter 348/610 | SPS: 28212 | Reward: 0.089 | Value: 0.180 | VLoss: 0.0465 | PLoss: 0.0000 | Ent: 0.6930
|
| 349 |
+
[ 57.2%] Iter 349/610 | SPS: 28211 | Reward: 0.085 | Value: 0.177 | VLoss: 0.0461 | PLoss: 0.0001 | Ent: 0.6930
|
| 350 |
+
[ 57.4%] Iter 350/610 | SPS: 28210 | Reward: 0.086 | Value: 0.167 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6930
|
| 351 |
+
[ 57.5%] Iter 351/610 | SPS: 28208 | Reward: 0.089 | Value: 0.171 | VLoss: 0.0512 | PLoss: 0.0000 | Ent: 0.6930
|
| 352 |
+
[ 57.7%] Iter 352/610 | SPS: 28205 | Reward: 0.085 | Value: 0.179 | VLoss: 0.0463 | PLoss: -0.0002 | Ent: 0.6930
|
| 353 |
+
[ 57.9%] Iter 353/610 | SPS: 28203 | Reward: 0.088 | Value: 0.167 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6930
|
| 354 |
+
[ 58.0%] Iter 354/610 | SPS: 28201 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0448 | PLoss: 0.0000 | Ent: 0.6930
|
| 355 |
+
[ 58.2%] Iter 355/610 | SPS: 28199 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6930
|
| 356 |
+
[ 58.4%] Iter 356/610 | SPS: 28198 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0474 | PLoss: 0.0000 | Ent: 0.6930
|
| 357 |
+
[ 58.5%] Iter 357/610 | SPS: 28196 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0457 | PLoss: -0.0001 | Ent: 0.6930
|
| 358 |
+
[ 58.7%] Iter 358/610 | SPS: 28195 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0457 | PLoss: -0.0001 | Ent: 0.6929
|
| 359 |
+
[ 58.9%] Iter 359/610 | SPS: 28192 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6929
|
| 360 |
+
[ 59.0%] Iter 360/610 | SPS: 28188 | Reward: 0.088 | Value: 0.179 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6930
|
| 361 |
+
[ 59.2%] Iter 361/610 | SPS: 28187 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0485 | PLoss: -0.0000 | Ent: 0.6929
|
| 362 |
+
[ 59.3%] Iter 362/610 | SPS: 28186 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0480 | PLoss: -0.0000 | Ent: 0.6930
|
| 363 |
+
[ 59.5%] Iter 363/610 | SPS: 28184 | Reward: 0.089 | Value: 0.172 | VLoss: 0.0475 | PLoss: -0.0000 | Ent: 0.6930
|
| 364 |
+
[ 59.7%] Iter 364/610 | SPS: 28183 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6930
|
| 365 |
+
[ 59.8%] Iter 365/610 | SPS: 28181 | Reward: 0.090 | Value: 0.177 | VLoss: 0.0490 | PLoss: -0.0000 | Ent: 0.6930
|
| 366 |
+
[ 60.0%] Iter 366/610 | SPS: 28180 | Reward: 0.086 | Value: 0.178 | VLoss: 0.0432 | PLoss: -0.0001 | Ent: 0.6930
|
| 367 |
+
[ 60.2%] Iter 367/610 | SPS: 28179 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0482 | PLoss: -0.0000 | Ent: 0.6930
|
| 368 |
+
[ 60.3%] Iter 368/610 | SPS: 28177 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0462 | PLoss: -0.0000 | Ent: 0.6930
|
| 369 |
+
[ 60.5%] Iter 369/610 | SPS: 28175 | Reward: 0.090 | Value: 0.175 | VLoss: 0.0477 | PLoss: -0.0001 | Ent: 0.6930
|
| 370 |
+
[ 60.7%] Iter 370/610 | SPS: 28176 | Reward: 0.085 | Value: 0.182 | VLoss: 0.0464 | PLoss: -0.0001 | Ent: 0.6931
|
| 371 |
+
[ 60.8%] Iter 371/610 | SPS: 28178 | Reward: 0.089 | Value: 0.167 | VLoss: 0.0493 | PLoss: -0.0000 | Ent: 0.6930
|
| 372 |
+
[ 61.0%] Iter 372/610 | SPS: 28180 | Reward: 0.090 | Value: 0.176 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6930
|
| 373 |
+
[ 61.1%] Iter 373/610 | SPS: 28182 | Reward: 0.088 | Value: 0.180 | VLoss: 0.0472 | PLoss: -0.0000 | Ent: 0.6931
|
| 374 |
+
[ 61.3%] Iter 374/610 | SPS: 28183 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0490 | PLoss: 0.0000 | Ent: 0.6931
|
| 375 |
+
[ 61.5%] Iter 375/610 | SPS: 28185 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0454 | PLoss: -0.0000 | Ent: 0.6931
|
| 376 |
+
[ 61.6%] Iter 376/610 | SPS: 28186 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6931
|
| 377 |
+
[ 61.8%] Iter 377/610 | SPS: 28187 | Reward: 0.083 | Value: 0.170 | VLoss: 0.0431 | PLoss: 0.0000 | Ent: 0.6931
|
| 378 |
+
[ 62.0%] Iter 378/610 | SPS: 28187 | Reward: 0.087 | Value: 0.163 | VLoss: 0.0481 | PLoss: 0.0000 | Ent: 0.6931
|
| 379 |
+
[ 62.1%] Iter 379/610 | SPS: 28190 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0452 | PLoss: 0.0000 | Ent: 0.6931
|
| 380 |
+
[ 62.3%] Iter 380/610 | SPS: 28191 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0473 | PLoss: -0.0000 | Ent: 0.6931
|
| 381 |
+
[ 62.5%] Iter 381/610 | SPS: 28193 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0477 | PLoss: -0.0001 | Ent: 0.6931
|
| 382 |
+
[ 62.6%] Iter 382/610 | SPS: 28195 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6931
|
| 383 |
+
[ 62.8%] Iter 383/610 | SPS: 28197 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0450 | PLoss: -0.0000 | Ent: 0.6931
|
| 384 |
+
[ 63.0%] Iter 384/610 | SPS: 28199 | Reward: 0.092 | Value: 0.170 | VLoss: 0.0489 | PLoss: -0.0000 | Ent: 0.6931
|
| 385 |
+
[ 63.1%] Iter 385/610 | SPS: 28201 | Reward: 0.083 | Value: 0.184 | VLoss: 0.0446 | PLoss: -0.0001 | Ent: 0.6931
|
| 386 |
+
[ 63.3%] Iter 386/610 | SPS: 28202 | Reward: 0.084 | Value: 0.163 | VLoss: 0.0448 | PLoss: 0.0000 | Ent: 0.6931
|
| 387 |
+
[ 63.4%] Iter 387/610 | SPS: 28204 | Reward: 0.085 | Value: 0.167 | VLoss: 0.0437 | PLoss: -0.0000 | Ent: 0.6931
|
| 388 |
+
[ 63.6%] Iter 388/610 | SPS: 28205 | Reward: 0.090 | Value: 0.171 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6931
|
| 389 |
+
[ 63.8%] Iter 389/610 | SPS: 28206 | Reward: 0.087 | Value: 0.182 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6931
|
| 390 |
+
[ 63.9%] Iter 390/610 | SPS: 28207 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6931
|
| 391 |
+
[ 64.1%] Iter 391/610 | SPS: 28207 | Reward: 0.090 | Value: 0.175 | VLoss: 0.0501 | PLoss: -0.0001 | Ent: 0.6931
|
| 392 |
+
[ 64.3%] Iter 392/610 | SPS: 28208 | Reward: 0.087 | Value: 0.181 | VLoss: 0.0488 | PLoss: 0.0000 | Ent: 0.6931
|
| 393 |
+
[ 64.4%] Iter 393/610 | SPS: 28206 | Reward: 0.085 | Value: 0.172 | VLoss: 0.0459 | PLoss: -0.0001 | Ent: 0.6931
|
| 394 |
+
[ 64.6%] Iter 394/610 | SPS: 28205 | Reward: 0.088 | Value: 0.168 | VLoss: 0.0487 | PLoss: 0.0000 | Ent: 0.6931
|
| 395 |
+
[ 64.8%] Iter 395/610 | SPS: 28202 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0494 | PLoss: -0.0000 | Ent: 0.6931
|
| 396 |
+
[ 64.9%] Iter 396/610 | SPS: 28202 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6931
|
| 397 |
+
[ 65.1%] Iter 397/610 | SPS: 28204 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0461 | PLoss: -0.0000 | Ent: 0.6931
|
| 398 |
+
[ 65.2%] Iter 398/610 | SPS: 28206 | Reward: 0.085 | Value: 0.178 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6931
|
| 399 |
+
[ 65.4%] Iter 399/610 | SPS: 28208 | Reward: 0.087 | Value: 0.168 | VLoss: 0.0431 | PLoss: 0.0000 | Ent: 0.6931
|
| 400 |
+
[ 65.6%] Iter 400/610 | SPS: 28210 | Reward: 0.083 | Value: 0.173 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6931
|
| 401 |
+
[ 65.7%] Iter 401/610 | SPS: 28211 | Reward: 0.088 | Value: 0.165 | VLoss: 0.0480 | PLoss: -0.0000 | Ent: 0.6931
|
| 402 |
+
[ 65.9%] Iter 402/610 | SPS: 28213 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0486 | PLoss: 0.0000 | Ent: 0.6930
|
| 403 |
+
[ 66.1%] Iter 403/610 | SPS: 28214 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0479 | PLoss: 0.0000 | Ent: 0.6930
|
| 404 |
+
[ 66.2%] Iter 404/610 | SPS: 28216 | Reward: 0.091 | Value: 0.173 | VLoss: 0.0505 | PLoss: 0.0000 | Ent: 0.6930
|
| 405 |
+
[ 66.4%] Iter 405/610 | SPS: 28218 | Reward: 0.088 | Value: 0.182 | VLoss: 0.0472 | PLoss: -0.0000 | Ent: 0.6930
|
| 406 |
+
[ 66.6%] Iter 406/610 | SPS: 28219 | Reward: 0.084 | Value: 0.172 | VLoss: 0.0464 | PLoss: -0.0000 | Ent: 0.6930
|
| 407 |
+
[ 66.7%] Iter 407/610 | SPS: 28221 | Reward: 0.089 | Value: 0.167 | VLoss: 0.0490 | PLoss: 0.0000 | Ent: 0.6930
|
| 408 |
+
[ 66.9%] Iter 408/610 | SPS: 28223 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0447 | PLoss: -0.0000 | Ent: 0.6930
|
| 409 |
+
[ 67.0%] Iter 409/610 | SPS: 28224 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0445 | PLoss: -0.0000 | Ent: 0.6930
|
| 410 |
+
[ 67.2%] Iter 410/610 | SPS: 28226 | Reward: 0.089 | Value: 0.169 | VLoss: 0.0480 | PLoss: 0.0000 | Ent: 0.6929
|
| 411 |
+
[ 67.4%] Iter 411/610 | SPS: 28227 | Reward: 0.090 | Value: 0.177 | VLoss: 0.0503 | PLoss: -0.0000 | Ent: 0.6930
|
| 412 |
+
[ 67.5%] Iter 412/610 | SPS: 28227 | Reward: 0.085 | Value: 0.180 | VLoss: 0.0460 | PLoss: 0.0000 | Ent: 0.6930
|
| 413 |
+
[ 67.7%] Iter 413/610 | SPS: 28228 | Reward: 0.089 | Value: 0.167 | VLoss: 0.0469 | PLoss: -0.0001 | Ent: 0.6930
|
| 414 |
+
[ 67.9%] Iter 414/610 | SPS: 28230 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0500 | PLoss: -0.0000 | Ent: 0.6929
|
| 415 |
+
[ 68.0%] Iter 415/610 | SPS: 28231 | Reward: 0.090 | Value: 0.176 | VLoss: 0.0501 | PLoss: 0.0000 | Ent: 0.6929
|
| 416 |
+
[ 68.2%] Iter 416/610 | SPS: 28233 | Reward: 0.085 | Value: 0.181 | VLoss: 0.0439 | PLoss: -0.0000 | Ent: 0.6929
|
| 417 |
+
[ 68.4%] Iter 417/610 | SPS: 28234 | Reward: 0.088 | Value: 0.167 | VLoss: 0.0475 | PLoss: -0.0000 | Ent: 0.6929
|
| 418 |
+
[ 68.5%] Iter 418/610 | SPS: 28236 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6929
|
| 419 |
+
[ 68.7%] Iter 419/610 | SPS: 28238 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0464 | PLoss: -0.0000 | Ent: 0.6929
|
| 420 |
+
[ 68.9%] Iter 420/610 | SPS: 28239 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6928
|
| 421 |
+
[ 69.0%] Iter 421/610 | SPS: 28241 | Reward: 0.090 | Value: 0.176 | VLoss: 0.0475 | PLoss: -0.0000 | Ent: 0.6928
|
| 422 |
+
[ 69.2%] Iter 422/610 | SPS: 28242 | Reward: 0.087 | Value: 0.180 | VLoss: 0.0471 | PLoss: -0.0001 | Ent: 0.6929
|
| 423 |
+
[ 69.3%] Iter 423/610 | SPS: 28244 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0431 | PLoss: -0.0000 | Ent: 0.6928
|
| 424 |
+
[ 69.5%] Iter 424/610 | SPS: 28244 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0436 | PLoss: 0.0000 | Ent: 0.6928
|
| 425 |
+
[ 69.7%] Iter 425/610 | SPS: 28245 | Reward: 0.090 | Value: 0.171 | VLoss: 0.0468 | PLoss: 0.0000 | Ent: 0.6928
|
| 426 |
+
[ 69.8%] Iter 426/610 | SPS: 28246 | Reward: 0.086 | Value: 0.181 | VLoss: 0.0431 | PLoss: -0.0001 | Ent: 0.6928
|
| 427 |
+
[ 70.0%] Iter 427/610 | SPS: 28248 | Reward: 0.088 | Value: 0.168 | VLoss: 0.0479 | PLoss: -0.0000 | Ent: 0.6927
|
| 428 |
+
[ 70.2%] Iter 428/610 | SPS: 28249 | Reward: 0.086 | Value: 0.178 | VLoss: 0.0473 | PLoss: 0.0000 | Ent: 0.6927
|
| 429 |
+
[ 70.3%] Iter 429/610 | SPS: 28249 | Reward: 0.089 | Value: 0.170 | VLoss: 0.0468 | PLoss: -0.0000 | Ent: 0.6927
|
| 430 |
+
[ 70.5%] Iter 430/610 | SPS: 28251 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6927
|
| 431 |
+
[ 70.7%] Iter 431/610 | SPS: 28252 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6927
|
| 432 |
+
[ 70.8%] Iter 432/610 | SPS: 28253 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0481 | PLoss: -0.0001 | Ent: 0.6927
|
| 433 |
+
[ 71.0%] Iter 433/610 | SPS: 28255 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0431 | PLoss: 0.0000 | Ent: 0.6926
|
| 434 |
+
[ 71.1%] Iter 434/610 | SPS: 28256 | Reward: 0.087 | Value: 0.168 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6926
|
| 435 |
+
[ 71.3%] Iter 435/610 | SPS: 28258 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0425 | PLoss: 0.0000 | Ent: 0.6926
|
| 436 |
+
[ 71.5%] Iter 436/610 | SPS: 28259 | Reward: 0.087 | Value: 0.167 | VLoss: 0.0482 | PLoss: -0.0000 | Ent: 0.6927
|
| 437 |
+
[ 71.6%] Iter 437/610 | SPS: 28260 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0478 | PLoss: -0.0001 | Ent: 0.6926
|
| 438 |
+
[ 71.8%] Iter 438/610 | SPS: 28262 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0501 | PLoss: -0.0000 | Ent: 0.6926
|
| 439 |
+
[ 72.0%] Iter 439/610 | SPS: 28263 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6926
|
| 440 |
+
[ 72.1%] Iter 440/610 | SPS: 28265 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0476 | PLoss: -0.0000 | Ent: 0.6927
|
| 441 |
+
[ 72.3%] Iter 441/610 | SPS: 28266 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6927
|
| 442 |
+
[ 72.5%] Iter 442/610 | SPS: 28268 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6926
|
| 443 |
+
[ 72.6%] Iter 443/610 | SPS: 28269 | Reward: 0.084 | Value: 0.177 | VLoss: 0.0440 | PLoss: 0.0000 | Ent: 0.6926
|
| 444 |
+
[ 72.8%] Iter 444/610 | SPS: 28270 | Reward: 0.087 | Value: 0.165 | VLoss: 0.0489 | PLoss: -0.0000 | Ent: 0.6926
|
| 445 |
+
[ 73.0%] Iter 445/610 | SPS: 28272 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0477 | PLoss: -0.0000 | Ent: 0.6926
|
| 446 |
+
[ 73.1%] Iter 446/610 | SPS: 28273 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6926
|
| 447 |
+
[ 73.3%] Iter 447/610 | SPS: 28273 | Reward: 0.089 | Value: 0.176 | VLoss: 0.0491 | PLoss: -0.0000 | Ent: 0.6926
|
| 448 |
+
[ 73.4%] Iter 448/610 | SPS: 28274 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0452 | PLoss: -0.0001 | Ent: 0.6925
|
| 449 |
+
[ 73.6%] Iter 449/610 | SPS: 28275 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0452 | PLoss: 0.0000 | Ent: 0.6924
|
| 450 |
+
[ 73.8%] Iter 450/610 | SPS: 28276 | Reward: 0.089 | Value: 0.179 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6924
|
| 451 |
+
[ 73.9%] Iter 451/610 | SPS: 28277 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0486 | PLoss: -0.0001 | Ent: 0.6925
|
| 452 |
+
[ 74.1%] Iter 452/610 | SPS: 28278 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0461 | PLoss: 0.0000 | Ent: 0.6925
|
| 453 |
+
[ 74.3%] Iter 453/610 | SPS: 28279 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6925
|
| 454 |
+
[ 74.4%] Iter 454/610 | SPS: 28280 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0481 | PLoss: 0.0000 | Ent: 0.6926
|
| 455 |
+
[ 74.6%] Iter 455/610 | SPS: 28281 | Reward: 0.090 | Value: 0.175 | VLoss: 0.0494 | PLoss: -0.0001 | Ent: 0.6927
|
| 456 |
+
[ 74.8%] Iter 456/610 | SPS: 28282 | Reward: 0.089 | Value: 0.181 | VLoss: 0.0455 | PLoss: -0.0000 | Ent: 0.6927
|
| 457 |
+
[ 74.9%] Iter 457/610 | SPS: 28283 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0485 | PLoss: -0.0000 | Ent: 0.6926
|
| 458 |
+
[ 75.1%] Iter 458/610 | SPS: 28284 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6927
|
| 459 |
+
[ 75.2%] Iter 459/610 | SPS: 28285 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0457 | PLoss: -0.0000 | Ent: 0.6927
|
| 460 |
+
[ 75.4%] Iter 460/610 | SPS: 28286 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0461 | PLoss: -0.0000 | Ent: 0.6927
|
| 461 |
+
[ 75.6%] Iter 461/610 | SPS: 28287 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0476 | PLoss: -0.0000 | Ent: 0.6927
|
| 462 |
+
[ 75.7%] Iter 462/610 | SPS: 28288 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0454 | PLoss: 0.0000 | Ent: 0.6927
|
| 463 |
+
[ 75.9%] Iter 463/610 | SPS: 28289 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0472 | PLoss: 0.0000 | Ent: 0.6927
|
| 464 |
+
[ 76.1%] Iter 464/610 | SPS: 28289 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6928
|
| 465 |
+
[ 76.2%] Iter 465/610 | SPS: 28290 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6927
|
| 466 |
+
[ 76.4%] Iter 466/610 | SPS: 28292 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0439 | PLoss: -0.0000 | Ent: 0.6927
|
| 467 |
+
[ 76.6%] Iter 467/610 | SPS: 28293 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0460 | PLoss: -0.0001 | Ent: 0.6925
|
| 468 |
+
[ 76.7%] Iter 468/610 | SPS: 28294 | Reward: 0.085 | Value: 0.174 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6925
|
| 469 |
+
[ 76.9%] Iter 469/610 | SPS: 28295 | Reward: 0.088 | Value: 0.168 | VLoss: 0.0465 | PLoss: -0.0000 | Ent: 0.6925
|
| 470 |
+
[ 77.0%] Iter 470/610 | SPS: 28296 | Reward: 0.093 | Value: 0.176 | VLoss: 0.0517 | PLoss: -0.0000 | Ent: 0.6924
|
| 471 |
+
[ 77.2%] Iter 471/610 | SPS: 28297 | Reward: 0.091 | Value: 0.185 | VLoss: 0.0451 | PLoss: -0.0001 | Ent: 0.6924
|
| 472 |
+
[ 77.4%] Iter 472/610 | SPS: 28298 | Reward: 0.086 | Value: 0.180 | VLoss: 0.0455 | PLoss: -0.0001 | Ent: 0.6923
|
| 473 |
+
[ 77.5%] Iter 473/610 | SPS: 28299 | Reward: 0.085 | Value: 0.170 | VLoss: 0.0462 | PLoss: -0.0000 | Ent: 0.6922
|
| 474 |
+
[ 77.7%] Iter 474/610 | SPS: 28300 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0468 | PLoss: 0.0000 | Ent: 0.6922
|
| 475 |
+
[ 77.9%] Iter 475/610 | SPS: 28301 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6922
|
| 476 |
+
[ 78.0%] Iter 476/610 | SPS: 28302 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0439 | PLoss: -0.0001 | Ent: 0.6922
|
| 477 |
+
[ 78.2%] Iter 477/610 | SPS: 28303 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0442 | PLoss: -0.0000 | Ent: 0.6922
|
| 478 |
+
[ 78.4%] Iter 478/610 | SPS: 28303 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0484 | PLoss: -0.0000 | Ent: 0.6922
|
| 479 |
+
[ 78.5%] Iter 479/610 | SPS: 28304 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0001 | Ent: 0.6922
|
| 480 |
+
[ 78.7%] Iter 480/610 | SPS: 28305 | Reward: 0.087 | Value: 0.178 | VLoss: 0.0449 | PLoss: -0.0000 | Ent: 0.6923
|
| 481 |
+
[ 78.9%] Iter 481/610 | SPS: 28305 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6924
|
| 482 |
+
[ 79.0%] Iter 482/610 | SPS: 28305 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0432 | PLoss: 0.0000 | Ent: 0.6923
|
| 483 |
+
[ 79.2%] Iter 483/610 | SPS: 28305 | Reward: 0.090 | Value: 0.168 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6923
|
| 484 |
+
[ 79.3%] Iter 484/610 | SPS: 28305 | Reward: 0.088 | Value: 0.180 | VLoss: 0.0461 | PLoss: 0.0000 | Ent: 0.6923
|
| 485 |
+
[ 79.5%] Iter 485/610 | SPS: 28306 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0510 | PLoss: -0.0000 | Ent: 0.6922
|
| 486 |
+
[ 79.7%] Iter 486/610 | SPS: 28306 | Reward: 0.089 | Value: 0.180 | VLoss: 0.0449 | PLoss: -0.0001 | Ent: 0.6921
|
| 487 |
+
[ 79.8%] Iter 487/610 | SPS: 28307 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0471 | PLoss: -0.0000 | Ent: 0.6920
|
| 488 |
+
[ 80.0%] Iter 488/610 | SPS: 28308 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0468 | PLoss: -0.0000 | Ent: 0.6920
|
| 489 |
+
[ 80.2%] Iter 489/610 | SPS: 28308 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6921
|
| 490 |
+
[ 80.3%] Iter 490/610 | SPS: 28308 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0484 | PLoss: -0.0000 | Ent: 0.6921
|
| 491 |
+
[ 80.5%] Iter 491/610 | SPS: 28309 | Reward: 0.091 | Value: 0.176 | VLoss: 0.0474 | PLoss: 0.0000 | Ent: 0.6921
|
| 492 |
+
[ 80.7%] Iter 492/610 | SPS: 28309 | Reward: 0.087 | Value: 0.183 | VLoss: 0.0454 | PLoss: -0.0000 | Ent: 0.6921
|
| 493 |
+
[ 80.8%] Iter 493/610 | SPS: 28309 | Reward: 0.086 | Value: 0.172 | VLoss: 0.0440 | PLoss: -0.0000 | Ent: 0.6922
|
| 494 |
+
[ 81.0%] Iter 494/610 | SPS: 28310 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0493 | PLoss: 0.0000 | Ent: 0.6922
|
| 495 |
+
[ 81.1%] Iter 495/610 | SPS: 28310 | Reward: 0.086 | Value: 0.180 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6923
|
| 496 |
+
[ 81.3%] Iter 496/610 | SPS: 28310 | Reward: 0.088 | Value: 0.170 | VLoss: 0.0460 | PLoss: 0.0000 | Ent: 0.6924
|
| 497 |
+
[ 81.5%] Iter 497/610 | SPS: 28311 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0502 | PLoss: -0.0000 | Ent: 0.6924
|
| 498 |
+
[ 81.6%] Iter 498/610 | SPS: 28311 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0448 | PLoss: -0.0000 | Ent: 0.6924
|
| 499 |
+
[ 81.8%] Iter 499/610 | SPS: 28311 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6924
|
| 500 |
+
[ 82.0%] Iter 500/610 | SPS: 28311 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0473 | PLoss: 0.0000 | Ent: 0.6924
|
| 501 |
+
[ 82.1%] Iter 501/610 | SPS: 28311 | Reward: 0.084 | Value: 0.176 | VLoss: 0.0475 | PLoss: -0.0000 | Ent: 0.6924
|
| 502 |
+
[ 82.3%] Iter 502/610 | SPS: 28312 | Reward: 0.091 | Value: 0.166 | VLoss: 0.0502 | PLoss: -0.0000 | Ent: 0.6924
|
| 503 |
+
[ 82.5%] Iter 503/610 | SPS: 28312 | Reward: 0.088 | Value: 0.183 | VLoss: 0.0486 | PLoss: -0.0000 | Ent: 0.6924
|
| 504 |
+
[ 82.6%] Iter 504/610 | SPS: 28313 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0490 | PLoss: 0.0000 | Ent: 0.6924
|
| 505 |
+
[ 82.8%] Iter 505/610 | SPS: 28313 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0495 | PLoss: 0.0000 | Ent: 0.6924
|
| 506 |
+
[ 83.0%] Iter 506/610 | SPS: 28313 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0436 | PLoss: 0.0000 | Ent: 0.6925
|
| 507 |
+
[ 83.1%] Iter 507/610 | SPS: 28314 | Reward: 0.090 | Value: 0.172 | VLoss: 0.0485 | PLoss: 0.0000 | Ent: 0.6924
|
| 508 |
+
[ 83.3%] Iter 508/610 | SPS: 28314 | Reward: 0.089 | Value: 0.181 | VLoss: 0.0468 | PLoss: -0.0000 | Ent: 0.6924
|
| 509 |
+
[ 83.4%] Iter 509/610 | SPS: 28314 | Reward: 0.085 | Value: 0.178 | VLoss: 0.0486 | PLoss: -0.0000 | Ent: 0.6924
|
| 510 |
+
[ 83.6%] Iter 510/610 | SPS: 28314 | Reward: 0.089 | Value: 0.168 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6924
|
| 511 |
+
[ 83.8%] Iter 511/610 | SPS: 28314 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0479 | PLoss: -0.0000 | Ent: 0.6924
|
| 512 |
+
[ 83.9%] Iter 512/610 | SPS: 28314 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0483 | PLoss: 0.0000 | Ent: 0.6924
|
| 513 |
+
[ 84.1%] Iter 513/610 | SPS: 28314 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6923
|
| 514 |
+
[ 84.3%] Iter 514/610 | SPS: 28315 | Reward: 0.090 | Value: 0.173 | VLoss: 0.0479 | PLoss: -0.0000 | Ent: 0.6922
|
| 515 |
+
[ 84.4%] Iter 515/610 | SPS: 28316 | Reward: 0.085 | Value: 0.180 | VLoss: 0.0436 | PLoss: -0.0000 | Ent: 0.6923
|
| 516 |
+
[ 84.6%] Iter 516/610 | SPS: 28317 | Reward: 0.090 | Value: 0.168 | VLoss: 0.0462 | PLoss: 0.0000 | Ent: 0.6924
|
| 517 |
+
[ 84.8%] Iter 517/610 | SPS: 28317 | Reward: 0.085 | Value: 0.178 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6925
|
| 518 |
+
[ 84.9%] Iter 518/610 | SPS: 28317 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6925
|
| 519 |
+
[ 85.1%] Iter 519/610 | SPS: 28319 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0481 | PLoss: -0.0001 | Ent: 0.6926
|
| 520 |
+
[ 85.2%] Iter 520/610 | SPS: 28319 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0450 | PLoss: -0.0000 | Ent: 0.6926
|
| 521 |
+
[ 85.4%] Iter 521/610 | SPS: 28320 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0444 | PLoss: -0.0000 | Ent: 0.6926
|
| 522 |
+
[ 85.6%] Iter 522/610 | SPS: 28321 | Reward: 0.088 | Value: 0.172 | VLoss: 0.0470 | PLoss: -0.0000 | Ent: 0.6926
|
| 523 |
+
[ 85.7%] Iter 523/610 | SPS: 28321 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0469 | PLoss: 0.0000 | Ent: 0.6926
|
| 524 |
+
[ 85.9%] Iter 524/610 | SPS: 28322 | Reward: 0.088 | Value: 0.175 | VLoss: 0.0466 | PLoss: 0.0000 | Ent: 0.6926
|
| 525 |
+
[ 86.1%] Iter 525/610 | SPS: 28323 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0470 | PLoss: 0.0000 | Ent: 0.6926
|
| 526 |
+
[ 86.2%] Iter 526/610 | SPS: 28324 | Reward: 0.086 | Value: 0.171 | VLoss: 0.0452 | PLoss: -0.0000 | Ent: 0.6926
|
| 527 |
+
[ 86.4%] Iter 527/610 | SPS: 28325 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0477 | PLoss: 0.0000 | Ent: 0.6926
|
| 528 |
+
[ 86.6%] Iter 528/610 | SPS: 28326 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0451 | PLoss: -0.0000 | Ent: 0.6927
|
| 529 |
+
[ 86.7%] Iter 529/610 | SPS: 28327 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0455 | PLoss: 0.0000 | Ent: 0.6927
|
| 530 |
+
[ 86.9%] Iter 530/610 | SPS: 28327 | Reward: 0.087 | Value: 0.170 | VLoss: 0.0457 | PLoss: -0.0000 | Ent: 0.6927
|
| 531 |
+
[ 87.0%] Iter 531/610 | SPS: 28328 | Reward: 0.091 | Value: 0.173 | VLoss: 0.0493 | PLoss: -0.0000 | Ent: 0.6927
|
| 532 |
+
[ 87.2%] Iter 532/610 | SPS: 28329 | Reward: 0.089 | Value: 0.181 | VLoss: 0.0453 | PLoss: -0.0000 | Ent: 0.6926
|
| 533 |
+
[ 87.4%] Iter 533/610 | SPS: 28329 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6927
|
| 534 |
+
[ 87.5%] Iter 534/610 | SPS: 28330 | Reward: 0.088 | Value: 0.169 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6927
|
| 535 |
+
[ 87.7%] Iter 535/610 | SPS: 28331 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0494 | PLoss: -0.0000 | Ent: 0.6926
|
| 536 |
+
[ 87.9%] Iter 536/610 | SPS: 28332 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0456 | PLoss: 0.0000 | Ent: 0.6926
|
| 537 |
+
[ 88.0%] Iter 537/610 | SPS: 28333 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6926
|
| 538 |
+
[ 88.2%] Iter 538/610 | SPS: 28334 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0500 | PLoss: -0.0000 | Ent: 0.6926
|
| 539 |
+
[ 88.4%] Iter 539/610 | SPS: 28335 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0462 | PLoss: 0.0000 | Ent: 0.6926
|
| 540 |
+
[ 88.5%] Iter 540/610 | SPS: 28337 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0480 | PLoss: 0.0000 | Ent: 0.6926
|
| 541 |
+
[ 88.7%] Iter 541/610 | SPS: 28338 | Reward: 0.090 | Value: 0.176 | VLoss: 0.0465 | PLoss: -0.0000 | Ent: 0.6926
|
| 542 |
+
[ 88.9%] Iter 542/610 | SPS: 28339 | Reward: 0.090 | Value: 0.179 | VLoss: 0.0485 | PLoss: -0.0000 | Ent: 0.6926
|
| 543 |
+
[ 89.0%] Iter 543/610 | SPS: 28339 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0456 | PLoss: -0.0000 | Ent: 0.6926
|
| 544 |
+
[ 89.2%] Iter 544/610 | SPS: 28340 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6926
|
| 545 |
+
[ 89.3%] Iter 545/610 | SPS: 28341 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0474 | PLoss: -0.0000 | Ent: 0.6925
|
| 546 |
+
[ 89.5%] Iter 546/610 | SPS: 28342 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0457 | PLoss: 0.0000 | Ent: 0.6925
|
| 547 |
+
[ 89.7%] Iter 547/610 | SPS: 28343 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0480 | PLoss: -0.0000 | Ent: 0.6925
|
| 548 |
+
[ 89.8%] Iter 548/610 | SPS: 28344 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0464 | PLoss: -0.0000 | Ent: 0.6924
|
| 549 |
+
[ 90.0%] Iter 549/610 | SPS: 28344 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0456 | PLoss: 0.0000 | Ent: 0.6924
|
| 550 |
+
[ 90.2%] Iter 550/610 | SPS: 28345 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0473 | PLoss: -0.0000 | Ent: 0.6924
|
| 551 |
+
[ 90.3%] Iter 551/610 | SPS: 28346 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0454 | PLoss: -0.0000 | Ent: 0.6925
|
| 552 |
+
[ 90.5%] Iter 552/610 | SPS: 28346 | Reward: 0.085 | Value: 0.171 | VLoss: 0.0424 | PLoss: -0.0000 | Ent: 0.6925
|
| 553 |
+
[ 90.7%] Iter 553/610 | SPS: 28347 | Reward: 0.086 | Value: 0.170 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6925
|
| 554 |
+
[ 90.8%] Iter 554/610 | SPS: 28348 | Reward: 0.088 | Value: 0.171 | VLoss: 0.0440 | PLoss: -0.0000 | Ent: 0.6926
|
| 555 |
+
[ 91.0%] Iter 555/610 | SPS: 28349 | Reward: 0.092 | Value: 0.174 | VLoss: 0.0494 | PLoss: 0.0000 | Ent: 0.6926
|
| 556 |
+
[ 91.1%] Iter 556/610 | SPS: 28350 | Reward: 0.088 | Value: 0.181 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6925
|
| 557 |
+
[ 91.3%] Iter 557/610 | SPS: 28351 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6925
|
| 558 |
+
[ 91.5%] Iter 558/610 | SPS: 28352 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6925
|
| 559 |
+
[ 91.6%] Iter 559/610 | SPS: 28352 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0471 | PLoss: 0.0000 | Ent: 0.6925
|
| 560 |
+
[ 91.8%] Iter 560/610 | SPS: 28353 | Reward: 0.087 | Value: 0.176 | VLoss: 0.0468 | PLoss: -0.0000 | Ent: 0.6925
|
| 561 |
+
[ 92.0%] Iter 561/610 | SPS: 28354 | Reward: 0.090 | Value: 0.174 | VLoss: 0.0484 | PLoss: 0.0000 | Ent: 0.6925
|
| 562 |
+
[ 92.1%] Iter 562/610 | SPS: 28355 | Reward: 0.090 | Value: 0.178 | VLoss: 0.0492 | PLoss: -0.0000 | Ent: 0.6925
|
| 563 |
+
[ 92.3%] Iter 563/610 | SPS: 28356 | Reward: 0.087 | Value: 0.179 | VLoss: 0.0466 | PLoss: 0.0000 | Ent: 0.6925
|
| 564 |
+
[ 92.5%] Iter 564/610 | SPS: 28357 | Reward: 0.089 | Value: 0.175 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6925
|
| 565 |
+
[ 92.6%] Iter 565/610 | SPS: 28358 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6925
|
| 566 |
+
[ 92.8%] Iter 566/610 | SPS: 28358 | Reward: 0.086 | Value: 0.177 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6925
|
| 567 |
+
[ 93.0%] Iter 567/610 | SPS: 28359 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0466 | PLoss: -0.0000 | Ent: 0.6925
|
| 568 |
+
[ 93.1%] Iter 568/610 | SPS: 28360 | Reward: 0.084 | Value: 0.173 | VLoss: 0.0449 | PLoss: 0.0000 | Ent: 0.6925
|
| 569 |
+
[ 93.3%] Iter 569/610 | SPS: 28359 | Reward: 0.091 | Value: 0.170 | VLoss: 0.0456 | PLoss: -0.0000 | Ent: 0.6925
|
| 570 |
+
[ 93.4%] Iter 570/610 | SPS: 28357 | Reward: 0.084 | Value: 0.176 | VLoss: 0.0484 | PLoss: 0.0000 | Ent: 0.6925
|
| 571 |
+
[ 93.6%] Iter 571/610 | SPS: 28357 | Reward: 0.085 | Value: 0.173 | VLoss: 0.0442 | PLoss: -0.0000 | Ent: 0.6925
|
| 572 |
+
[ 93.8%] Iter 572/610 | SPS: 28358 | Reward: 0.092 | Value: 0.169 | VLoss: 0.0506 | PLoss: -0.0000 | Ent: 0.6925
|
| 573 |
+
[ 93.9%] Iter 573/610 | SPS: 28359 | Reward: 0.088 | Value: 0.177 | VLoss: 0.0441 | PLoss: -0.0000 | Ent: 0.6925
|
| 574 |
+
[ 94.1%] Iter 574/610 | SPS: 28360 | Reward: 0.088 | Value: 0.178 | VLoss: 0.0476 | PLoss: 0.0000 | Ent: 0.6925
|
| 575 |
+
[ 94.3%] Iter 575/610 | SPS: 28361 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0467 | PLoss: -0.0000 | Ent: 0.6925
|
| 576 |
+
[ 94.4%] Iter 576/610 | SPS: 28362 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6925
|
| 577 |
+
[ 94.6%] Iter 577/610 | SPS: 28363 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0462 | PLoss: 0.0000 | Ent: 0.6925
|
| 578 |
+
[ 94.8%] Iter 578/610 | SPS: 28364 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0468 | PLoss: -0.0000 | Ent: 0.6924
|
| 579 |
+
[ 94.9%] Iter 579/610 | SPS: 28364 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0469 | PLoss: -0.0000 | Ent: 0.6924
|
| 580 |
+
[ 95.1%] Iter 580/610 | SPS: 28366 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0479 | PLoss: 0.0000 | Ent: 0.6924
|
| 581 |
+
[ 95.2%] Iter 581/610 | SPS: 28367 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0442 | PLoss: -0.0000 | Ent: 0.6924
|
| 582 |
+
[ 95.4%] Iter 582/610 | SPS: 28368 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0457 | PLoss: 0.0000 | Ent: 0.6924
|
| 583 |
+
[ 95.6%] Iter 583/610 | SPS: 28368 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0483 | PLoss: -0.0000 | Ent: 0.6924
|
| 584 |
+
[ 95.7%] Iter 584/610 | SPS: 28369 | Reward: 0.088 | Value: 0.173 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6924
|
| 585 |
+
[ 95.9%] Iter 585/610 | SPS: 28370 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0456 | PLoss: -0.0000 | Ent: 0.6924
|
| 586 |
+
[ 96.1%] Iter 586/610 | SPS: 28370 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0458 | PLoss: -0.0000 | Ent: 0.6924
|
| 587 |
+
[ 96.2%] Iter 587/610 | SPS: 28370 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0476 | PLoss: 0.0000 | Ent: 0.6924
|
| 588 |
+
[ 96.4%] Iter 588/610 | SPS: 28371 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0456 | PLoss: 0.0000 | Ent: 0.6924
|
| 589 |
+
[ 96.6%] Iter 589/610 | SPS: 28372 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0499 | PLoss: 0.0000 | Ent: 0.6923
|
| 590 |
+
[ 96.7%] Iter 590/610 | SPS: 28373 | Reward: 0.090 | Value: 0.174 | VLoss: 0.0490 | PLoss: -0.0000 | Ent: 0.6923
|
| 591 |
+
[ 96.9%] Iter 591/610 | SPS: 28375 | Reward: 0.088 | Value: 0.176 | VLoss: 0.0478 | PLoss: -0.0000 | Ent: 0.6923
|
| 592 |
+
[ 97.0%] Iter 592/610 | SPS: 28376 | Reward: 0.089 | Value: 0.177 | VLoss: 0.0460 | PLoss: -0.0000 | Ent: 0.6923
|
| 593 |
+
[ 97.2%] Iter 593/610 | SPS: 28376 | Reward: 0.087 | Value: 0.177 | VLoss: 0.0471 | PLoss: 0.0000 | Ent: 0.6923
|
| 594 |
+
[ 97.4%] Iter 594/610 | SPS: 28377 | Reward: 0.090 | Value: 0.176 | VLoss: 0.0491 | PLoss: 0.0000 | Ent: 0.6923
|
| 595 |
+
[ 97.5%] Iter 595/610 | SPS: 28378 | Reward: 0.086 | Value: 0.176 | VLoss: 0.0478 | PLoss: 0.0000 | Ent: 0.6923
|
| 596 |
+
[ 97.7%] Iter 596/610 | SPS: 28379 | Reward: 0.087 | Value: 0.175 | VLoss: 0.0450 | PLoss: -0.0000 | Ent: 0.6923
|
| 597 |
+
[ 97.9%] Iter 597/610 | SPS: 28380 | Reward: 0.088 | Value: 0.174 | VLoss: 0.0486 | PLoss: 0.0000 | Ent: 0.6923
|
| 598 |
+
[ 98.0%] Iter 598/610 | SPS: 28381 | Reward: 0.085 | Value: 0.174 | VLoss: 0.0472 | PLoss: -0.0000 | Ent: 0.6924
|
| 599 |
+
[ 98.2%] Iter 599/610 | SPS: 28382 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0450 | PLoss: -0.0000 | Ent: 0.6924
|
| 600 |
+
[ 98.4%] Iter 600/610 | SPS: 28383 | Reward: 0.087 | Value: 0.173 | VLoss: 0.0475 | PLoss: 0.0000 | Ent: 0.6924
|
| 601 |
+
[ 98.5%] Iter 601/610 | SPS: 28384 | Reward: 0.086 | Value: 0.173 | VLoss: 0.0463 | PLoss: 0.0000 | Ent: 0.6923
|
| 602 |
+
[ 98.7%] Iter 602/610 | SPS: 28385 | Reward: 0.087 | Value: 0.172 | VLoss: 0.0463 | PLoss: -0.0000 | Ent: 0.6924
|
| 603 |
+
[ 98.9%] Iter 603/610 | SPS: 28386 | Reward: 0.089 | Value: 0.173 | VLoss: 0.0491 | PLoss: -0.0000 | Ent: 0.6924
|
| 604 |
+
[ 99.0%] Iter 604/610 | SPS: 28386 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6923
|
| 605 |
+
[ 99.2%] Iter 605/610 | SPS: 28386 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0451 | PLoss: 0.0000 | Ent: 0.6924
|
| 606 |
+
[ 99.3%] Iter 606/610 | SPS: 28387 | Reward: 0.086 | Value: 0.175 | VLoss: 0.0464 | PLoss: -0.0000 | Ent: 0.6923
|
| 607 |
+
[ 99.5%] Iter 607/610 | SPS: 28388 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0470 | PLoss: 0.0000 | Ent: 0.6924
|
| 608 |
+
[ 99.7%] Iter 608/610 | SPS: 28389 | Reward: 0.086 | Value: 0.174 | VLoss: 0.0459 | PLoss: -0.0000 | Ent: 0.6923
|
| 609 |
+
[ 99.8%] Iter 609/610 | SPS: 28389 | Reward: 0.087 | Value: 0.174 | VLoss: 0.0487 | PLoss: -0.0000 | Ent: 0.6923
|
| 610 |
+
[100.0%] Iter 610/610 | SPS: 28390 | Reward: 0.089 | Value: 0.174 | VLoss: 0.0446 | PLoss: -0.0000 | Ent: 0.6924
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/requirements.txt
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ragen==0.1
|
| 2 |
+
setuptools==80.9.0
|
| 3 |
+
wheel==0.45.1
|
| 4 |
+
pip==25.2
|
| 5 |
+
zipp==3.23.0
|
| 6 |
+
verl==0.2.0.dev0
|
| 7 |
+
ragen==0.1
|
| 8 |
+
triton==3.2.0
|
| 9 |
+
nvidia-cusparselt-cu12==0.6.2
|
| 10 |
+
mpmath==1.3.0
|
| 11 |
+
typing_extensions==4.15.0
|
| 12 |
+
sympy==1.13.1
|
| 13 |
+
nvidia-nvtx-cu12==12.4.127
|
| 14 |
+
nvidia-nvjitlink-cu12==12.4.127
|
| 15 |
+
nvidia-nccl-cu12==2.21.5
|
| 16 |
+
nvidia-curand-cu12==10.3.5.147
|
| 17 |
+
nvidia-cufft-cu12==11.2.1.3
|
| 18 |
+
nvidia-cuda-runtime-cu12==12.4.127
|
| 19 |
+
nvidia-cuda-nvrtc-cu12==12.4.127
|
| 20 |
+
nvidia-cuda-cupti-cu12==12.4.127
|
| 21 |
+
nvidia-cublas-cu12==12.4.5.8
|
| 22 |
+
networkx==3.5
|
| 23 |
+
MarkupSafe==2.1.5
|
| 24 |
+
fsspec==2025.9.0
|
| 25 |
+
filelock==3.19.1
|
| 26 |
+
nvidia-cusparse-cu12==12.3.1.170
|
| 27 |
+
nvidia-cudnn-cu12==9.1.0.70
|
| 28 |
+
Jinja2==3.1.6
|
| 29 |
+
nvidia-cusolver-cu12==11.6.1.9
|
| 30 |
+
torch==2.6.0+cu124
|
| 31 |
+
einops==0.8.1
|
| 32 |
+
flash_attn==2.7.4.post1
|
| 33 |
+
pytz==2025.2
|
| 34 |
+
pyperclip==1.11.0
|
| 35 |
+
pylatexenc==2.10
|
| 36 |
+
pyjnius==1.7.0
|
| 37 |
+
py-cpuinfo==9.0.0
|
| 38 |
+
pure_eval==0.2.3
|
| 39 |
+
ptyprocess==0.7.0
|
| 40 |
+
gym-notices==0.1.0
|
| 41 |
+
flatbuffers==25.9.23
|
| 42 |
+
fastrlock==0.8.3
|
| 43 |
+
Farama-Notifications==0.0.4
|
| 44 |
+
cymem==2.0.11
|
| 45 |
+
antlr4-python3-runtime==4.9.3
|
| 46 |
+
xxhash==3.6.0
|
| 47 |
+
wrapt==2.0.0
|
| 48 |
+
Werkzeug==3.1.3
|
| 49 |
+
websockets==15.0.1
|
| 50 |
+
wcwidth==0.2.14
|
| 51 |
+
wasabi==1.1.3
|
| 52 |
+
uvloop==0.22.1
|
| 53 |
+
urllib3==2.5.0
|
| 54 |
+
tzdata==2025.2
|
| 55 |
+
typing-inspection==0.4.2
|
| 56 |
+
traitlets==5.14.3
|
| 57 |
+
tqdm==4.67.1
|
| 58 |
+
threadpoolctl==3.6.0
|
| 59 |
+
tabulate==0.9.0
|
| 60 |
+
spacy-loggers==1.0.5
|
| 61 |
+
spacy-legacy==3.0.12
|
| 62 |
+
soupsieve==2.8
|
| 63 |
+
sniffio==1.3.1
|
| 64 |
+
smmap==5.0.2
|
| 65 |
+
six==1.17.0
|
| 66 |
+
shellingham==1.5.4
|
| 67 |
+
sentencepiece==0.2.1
|
| 68 |
+
safetensors==0.6.2
|
| 69 |
+
rpds-py==0.28.0
|
| 70 |
+
rignore==0.7.6
|
| 71 |
+
regex==2025.11.3
|
| 72 |
+
RapidFuzz==3.14.3
|
| 73 |
+
pyzmq==27.1.0
|
| 74 |
+
PyYAML==6.0.3
|
| 75 |
+
pytokens==0.3.0
|
| 76 |
+
python-multipart==0.0.20
|
| 77 |
+
python-json-logger==4.0.0
|
| 78 |
+
python-dotenv==1.2.1
|
| 79 |
+
PySocks==1.7.1
|
| 80 |
+
pyparsing==3.2.5
|
| 81 |
+
PyJWT==2.10.1
|
| 82 |
+
Pygments==2.19.2
|
| 83 |
+
pygame==2.6.1
|
| 84 |
+
pydantic_core==2.41.5
|
| 85 |
+
pycparser==2.23
|
| 86 |
+
pycountry==24.6.1
|
| 87 |
+
pybind11==3.0.1
|
| 88 |
+
pyarrow==22.0.0
|
| 89 |
+
psutil==7.1.3
|
| 90 |
+
protobuf==6.33.0
|
| 91 |
+
propcache==0.4.1
|
| 92 |
+
prometheus_client==0.23.1
|
| 93 |
+
platformdirs==4.5.0
|
| 94 |
+
pillow==11.3.0
|
| 95 |
+
pexpect==4.9.0
|
| 96 |
+
pathvalidate==3.3.1
|
| 97 |
+
pathspec==0.12.1
|
| 98 |
+
pathable==0.4.4
|
| 99 |
+
partial-json-parser==0.2.1.1.post6
|
| 100 |
+
parso==0.8.5
|
| 101 |
+
packaging==25.0
|
| 102 |
+
orjson==3.11.4
|
| 103 |
+
numpy==1.26.4
|
| 104 |
+
ninja==1.13.0
|
| 105 |
+
nest-asyncio==1.6.0
|
| 106 |
+
mypy_extensions==1.1.0
|
| 107 |
+
murmurhash==1.0.13
|
| 108 |
+
multidict==6.7.0
|
| 109 |
+
msgspec==0.19.0
|
| 110 |
+
msgpack==1.1.2
|
| 111 |
+
more-itertools==10.8.0
|
| 112 |
+
mdurl==0.1.2
|
| 113 |
+
marisa-trie==1.3.1
|
| 114 |
+
llvmlite==0.43.0
|
| 115 |
+
llguidance==0.7.30
|
| 116 |
+
lark==1.2.2
|
| 117 |
+
kiwisolver==1.4.9
|
| 118 |
+
joblib==1.5.2
|
| 119 |
+
jiter==0.11.1
|
| 120 |
+
jeepney==0.9.0
|
| 121 |
+
jaraco.context==6.0.1
|
| 122 |
+
itsdangerous==2.2.0
|
| 123 |
+
interegular==0.3.3
|
| 124 |
+
idna==3.11
|
| 125 |
+
humanfriendly==10.0
|
| 126 |
+
httpx-sse==0.4.3
|
| 127 |
+
httptools==0.7.1
|
| 128 |
+
html2text==2025.4.15
|
| 129 |
+
hf-xet==1.2.0
|
| 130 |
+
h11==0.16.0
|
| 131 |
+
frozenlist==1.8.0
|
| 132 |
+
fonttools==4.60.1
|
| 133 |
+
executing==2.2.1
|
| 134 |
+
exceptiongroup==1.3.0
|
| 135 |
+
eval_type_backport==0.2.2
|
| 136 |
+
docutils==0.22.3
|
| 137 |
+
docstring_parser==0.17.0
|
| 138 |
+
dnspython==2.8.0
|
| 139 |
+
distro==1.9.0
|
| 140 |
+
diskcache==5.6.3
|
| 141 |
+
dill==0.4.0
|
| 142 |
+
decorator==5.2.1
|
| 143 |
+
debugpy==1.8.17
|
| 144 |
+
Cython==3.2.0
|
| 145 |
+
cycler==0.12.1
|
| 146 |
+
codetiming==1.4.0
|
| 147 |
+
cloudpickle==3.1.2
|
| 148 |
+
cloudpathlib==0.23.0
|
| 149 |
+
click==8.2.1
|
| 150 |
+
charset-normalizer==3.4.4
|
| 151 |
+
certifi==2025.10.5
|
| 152 |
+
catalogue==2.0.10
|
| 153 |
+
cachetools==6.2.1
|
| 154 |
+
blinker==1.9.0
|
| 155 |
+
blake3==1.0.8
|
| 156 |
+
beartype==0.22.5
|
| 157 |
+
attrs==25.4.0
|
| 158 |
+
asttokens==3.0.0
|
| 159 |
+
astor==0.8.1
|
| 160 |
+
annotated-types==0.7.0
|
| 161 |
+
annotated-doc==0.0.3
|
| 162 |
+
airportsdata==20250909
|
| 163 |
+
aiohappyeyeballs==2.6.1
|
| 164 |
+
yarl==1.22.0
|
| 165 |
+
uvicorn==0.38.0
|
| 166 |
+
typer-slim==0.20.0
|
| 167 |
+
thefuzz==0.22.1
|
| 168 |
+
stack-data==0.6.3
|
| 169 |
+
srsly==2.5.1
|
| 170 |
+
smart_open==7.4.4
|
| 171 |
+
sentry-sdk==2.43.0
|
| 172 |
+
scipy==1.16.3
|
| 173 |
+
requests==2.32.5
|
| 174 |
+
referencing==0.36.2
|
| 175 |
+
rank-bm25==0.2.2
|
| 176 |
+
python-dateutil==2.9.0.post0
|
| 177 |
+
pydantic==2.12.4
|
| 178 |
+
py-key-value-shared==0.2.8
|
| 179 |
+
prompt_toolkit==3.0.52
|
| 180 |
+
preshed==3.0.10
|
| 181 |
+
opencv-python-headless==4.11.0.86
|
| 182 |
+
omegaconf==2.3.0
|
| 183 |
+
numba==0.60.0
|
| 184 |
+
nltk==3.9.2
|
| 185 |
+
multiprocess==0.70.18
|
| 186 |
+
matplotlib-inline==0.2.1
|
| 187 |
+
markdown-it-py==4.0.0
|
| 188 |
+
language_data==1.3.0
|
| 189 |
+
jedi==0.19.2
|
| 190 |
+
jaraco.functools==4.3.0
|
| 191 |
+
jaraco.classes==3.4.0
|
| 192 |
+
ipython_pygments_lexers==1.1.1
|
| 193 |
+
importlib_metadata==8.7.0
|
| 194 |
+
ImageIO==2.37.2
|
| 195 |
+
httpcore==1.0.9
|
| 196 |
+
gymnasium==1.2.2
|
| 197 |
+
gym==0.26.2
|
| 198 |
+
gitdb==4.0.12
|
| 199 |
+
gguf==0.10.0
|
| 200 |
+
Flask==3.1.2
|
| 201 |
+
faiss-cpu==1.12.0
|
| 202 |
+
email-validator==2.3.0
|
| 203 |
+
depyf==0.18.0
|
| 204 |
+
cupy-cuda12x==13.6.0
|
| 205 |
+
contourpy==1.3.3
|
| 206 |
+
coloredlogs==15.0.1
|
| 207 |
+
cffi==2.0.0
|
| 208 |
+
blis==1.3.0
|
| 209 |
+
black==25.9.0
|
| 210 |
+
beautifulsoup4==4.14.2
|
| 211 |
+
anyio==4.11.0
|
| 212 |
+
aiosignal==1.4.0
|
| 213 |
+
watchfiles==1.1.1
|
| 214 |
+
tiktoken==0.12.0
|
| 215 |
+
starlette==0.49.3
|
| 216 |
+
sse-starlette==3.0.3
|
| 217 |
+
scikit-learn==1.7.2
|
| 218 |
+
rich==14.2.0
|
| 219 |
+
pydantic-settings==2.11.0
|
| 220 |
+
pydantic-extra-types==2.10.6
|
| 221 |
+
py-key-value-aio==0.2.8
|
| 222 |
+
pandas==2.3.3
|
| 223 |
+
openapi-pydantic==0.5.1
|
| 224 |
+
onnxruntime==1.23.2
|
| 225 |
+
matplotlib==3.10.7
|
| 226 |
+
lm-format-enforcer==0.10.12
|
| 227 |
+
langcodes==3.5.0
|
| 228 |
+
jsonschema-specifications==2025.9.1
|
| 229 |
+
jsonschema-path==0.3.4
|
| 230 |
+
ipython==9.7.0
|
| 231 |
+
hydra-core==1.3.2
|
| 232 |
+
huggingface-hub==0.36.0
|
| 233 |
+
httpx==0.28.1
|
| 234 |
+
gym-sokoban==0.0.6
|
| 235 |
+
GitPython==3.1.45
|
| 236 |
+
cryptography==46.0.3
|
| 237 |
+
confection==0.1.5
|
| 238 |
+
cleantext==1.1.4
|
| 239 |
+
aiohttp==3.13.2
|
| 240 |
+
xformers==0.0.29.post2
|
| 241 |
+
weasel==0.4.2
|
| 242 |
+
wandb==0.22.3
|
| 243 |
+
typer==0.19.2
|
| 244 |
+
torchvision==0.21.0
|
| 245 |
+
torchdata==0.11.0
|
| 246 |
+
torchaudio==2.6.0
|
| 247 |
+
tokenizers==0.22.1
|
| 248 |
+
thinc==8.3.7
|
| 249 |
+
tensordict==0.8.3
|
| 250 |
+
SecretStorage==3.4.0
|
| 251 |
+
rich-toolkit==0.15.1
|
| 252 |
+
rich-rst==1.3.2
|
| 253 |
+
prometheus-fastapi-instrumentator==7.1.0
|
| 254 |
+
openai==2.7.1
|
| 255 |
+
jsonschema==4.25.1
|
| 256 |
+
gdown==5.2.0
|
| 257 |
+
fastapi==0.121.0
|
| 258 |
+
Authlib==1.6.5
|
| 259 |
+
anthropic==0.72.0
|
| 260 |
+
accelerate==1.11.0
|
| 261 |
+
transformers==4.57.1
|
| 262 |
+
together==1.5.30
|
| 263 |
+
spacy==3.8.7
|
| 264 |
+
ray==2.51.1
|
| 265 |
+
outlines_core==0.1.26
|
| 266 |
+
mistral_common==1.8.5
|
| 267 |
+
mcp==1.20.0
|
| 268 |
+
keyring==25.6.0
|
| 269 |
+
fastapi-cloud-cli==0.3.1
|
| 270 |
+
fastapi-cli==0.0.14
|
| 271 |
+
datasets==4.4.1
|
| 272 |
+
cyclopts==4.2.1
|
| 273 |
+
xgrammar==0.1.16
|
| 274 |
+
peft==0.17.1
|
| 275 |
+
outlines==0.1.11
|
| 276 |
+
compressed-tensors==0.9.2
|
| 277 |
+
fastmcp==2.13.0.2
|
| 278 |
+
vllm==0.8.2
|
| 279 |
+
pyserini==1.3.0
|
| 280 |
+
typeguard==4.4.4
|
| 281 |
+
shtab==1.7.2
|
| 282 |
+
tyro==0.9.35
|
| 283 |
+
tensorboard-data-server==0.7.2
|
| 284 |
+
Markdown==3.10
|
| 285 |
+
grpcio==1.76.0
|
| 286 |
+
absl-py==2.3.1
|
| 287 |
+
tensorboard==2.20.0
|
| 288 |
+
ragen==0.1
|
| 289 |
+
verl==0.2.0.dev0
|
| 290 |
+
autocommand==2.2.2
|
| 291 |
+
backports.tarfile==1.2.0
|
| 292 |
+
importlib_metadata==8.0.0
|
| 293 |
+
inflect==7.3.1
|
| 294 |
+
jaraco.collections==5.1.0
|
| 295 |
+
jaraco.context==5.3.0
|
| 296 |
+
jaraco.functools==4.0.1
|
| 297 |
+
jaraco.text==3.12.1
|
| 298 |
+
more-itertools==10.3.0
|
| 299 |
+
packaging==24.2
|
| 300 |
+
platformdirs==4.2.2
|
| 301 |
+
tomli==2.0.1
|
| 302 |
+
typeguard==4.3.0
|
| 303 |
+
typing_extensions==4.12.2
|
| 304 |
+
wheel==0.45.1
|
| 305 |
+
zipp==3.19.2
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/files/wandb-metadata.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"os": "Linux-5.14.0-284.25.1.el9_2.x86_64-x86_64-with-glibc2.35",
|
| 3 |
+
"python": "CPython 3.12.12",
|
| 4 |
+
"startedAt": "2025-11-07T02:26:33.725426Z",
|
| 5 |
+
"args": [
|
| 6 |
+
"--track",
|
| 7 |
+
"--wandb-project-name",
|
| 8 |
+
"ragen-bandit"
|
| 9 |
+
],
|
| 10 |
+
"program": "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_bandit.py",
|
| 11 |
+
"codePath": "cleanrl/ppo_bandit.py",
|
| 12 |
+
"codePathLocal": "ppo_bandit.py",
|
| 13 |
+
"git": {
|
| 14 |
+
"remote": "https://github.com/vwxyzjn/cleanrl.git",
|
| 15 |
+
"commit": "004f8a086a892a2a180f4dd332b90d83a968aa7a"
|
| 16 |
+
},
|
| 17 |
+
"email": "haoyu-wa22@mails.tsinghua.edu.cn",
|
| 18 |
+
"root": "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl",
|
| 19 |
+
"host": "pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0",
|
| 20 |
+
"executable": "/root/local/miniconda3/envs/ragen/bin/python",
|
| 21 |
+
"cpu_count": 64,
|
| 22 |
+
"cpu_count_logical": 128,
|
| 23 |
+
"gpu": "NVIDIA H100 80GB HBM3",
|
| 24 |
+
"gpu_count": 8,
|
| 25 |
+
"disk": {
|
| 26 |
+
"/": {
|
| 27 |
+
"total": "5153960755200",
|
| 28 |
+
"used": "30509887488"
|
| 29 |
+
}
|
| 30 |
+
},
|
| 31 |
+
"memory": {
|
| 32 |
+
"total": "2163642122240"
|
| 33 |
+
},
|
| 34 |
+
"gpu_nvidia": [
|
| 35 |
+
{
|
| 36 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 37 |
+
"memoryTotal": "85520809984",
|
| 38 |
+
"cudaCores": 16896,
|
| 39 |
+
"architecture": "Hopper",
|
| 40 |
+
"uuid": "GPU-35e2d43d-4067-82ce-90d4-def9e389bf28"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 44 |
+
"memoryTotal": "85520809984",
|
| 45 |
+
"cudaCores": 16896,
|
| 46 |
+
"architecture": "Hopper",
|
| 47 |
+
"uuid": "GPU-af4135e3-88f2-e9ac-518d-502c75a85429"
|
| 48 |
+
},
|
| 49 |
+
{
|
| 50 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 51 |
+
"memoryTotal": "85520809984",
|
| 52 |
+
"cudaCores": 16896,
|
| 53 |
+
"architecture": "Hopper",
|
| 54 |
+
"uuid": "GPU-d7fdeeba-fe9b-ec03-d9f7-6724fe4266b5"
|
| 55 |
+
},
|
| 56 |
+
{
|
| 57 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 58 |
+
"memoryTotal": "85520809984",
|
| 59 |
+
"cudaCores": 16896,
|
| 60 |
+
"architecture": "Hopper",
|
| 61 |
+
"uuid": "GPU-ccc4f668-3882-5a8e-2c07-c5cd08f6f666"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 65 |
+
"memoryTotal": "85520809984",
|
| 66 |
+
"cudaCores": 16896,
|
| 67 |
+
"architecture": "Hopper",
|
| 68 |
+
"uuid": "GPU-7b73c0cf-d3d5-e10c-7176-a43be1e41001"
|
| 69 |
+
},
|
| 70 |
+
{
|
| 71 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 72 |
+
"memoryTotal": "85520809984",
|
| 73 |
+
"cudaCores": 16896,
|
| 74 |
+
"architecture": "Hopper",
|
| 75 |
+
"uuid": "GPU-81b58d94-5d1f-8ec2-f9d2-fd56172ed177"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 79 |
+
"memoryTotal": "85520809984",
|
| 80 |
+
"cudaCores": 16896,
|
| 81 |
+
"architecture": "Hopper",
|
| 82 |
+
"uuid": "GPU-03e8bc66-3b44-6794-49fd-5392fbdda6d1"
|
| 83 |
+
},
|
| 84 |
+
{
|
| 85 |
+
"name": "NVIDIA H100 80GB HBM3",
|
| 86 |
+
"memoryTotal": "85520809984",
|
| 87 |
+
"cudaCores": 16896,
|
| 88 |
+
"architecture": "Hopper",
|
| 89 |
+
"uuid": "GPU-b7cf0ec6-7c29-1179-dceb-09565da51890"
|
| 90 |
+
}
|
| 91 |
+
],
|
| 92 |
+
"cudaVersion": "12.4",
|
| 93 |
+
"writerId": "6ymqnqubvr99vvj2hajaxngee30bwzdk"
|
| 94 |
+
}
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug-internal.log
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"time":"2025-11-07T10:26:33.988521172+08:00","level":"INFO","msg":"stream: starting","core version":"0.22.3"}
|
| 2 |
+
{"time":"2025-11-07T10:26:34.459274234+08:00","level":"INFO","msg":"stream: created new stream","id":"lu2iu68t"}
|
| 3 |
+
{"time":"2025-11-07T10:26:34.459631305+08:00","level":"INFO","msg":"handler: started","stream_id":"lu2iu68t"}
|
| 4 |
+
{"time":"2025-11-07T10:26:34.462877596+08:00","level":"INFO","msg":"stream: started","id":"lu2iu68t"}
|
| 5 |
+
{"time":"2025-11-07T10:26:34.462890194+08:00","level":"INFO","msg":"writer: started","stream_id":"lu2iu68t"}
|
| 6 |
+
{"time":"2025-11-07T10:26:34.462896873+08:00","level":"INFO","msg":"sender: started","stream_id":"lu2iu68t"}
|
| 7 |
+
{"time":"2025-11-07T10:26:34.849513804+08:00","level":"ERROR","msg":"git repo not found","error":"repository does not exist"}
|
| 8 |
+
{"time":"2025-11-07T10:26:44.983958473+08:00","level":"WARN","msg":"tensorboard: no root directory","error":"timed out after 10s"}
|
| 9 |
+
{"time":"2025-11-07T10:26:44.984581369+08:00","level":"INFO","msg":"tensorboard: tracking new log directory","rootDir":{},"logDir":"LocalOrCloudPath(LocalPath=\"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Bandit__ppo_bandit__1__1762482386\")","namespace":""}
|
| 10 |
+
{"time":"2025-11-07T10:26:44.986307004+08:00","level":"INFO","msg":"tensorboard: saving file","fileLocation":"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Bandit__ppo_bandit__1__1762482386/events.out.tfevents.1762482394.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.132004.0","runPath":"runs/Bandit__ppo_bandit__1__1762482386/events.out.tfevents.1762482394.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.132004.0"}
|
| 11 |
+
{"time":"2025-11-07T10:26:44.990870062+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":527}
|
| 12 |
+
{"time":"2025-11-07T10:26:44.990963594+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 13 |
+
{"time":"2025-11-07T10:26:49.995612799+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":595}
|
| 14 |
+
{"time":"2025-11-07T10:26:50.232894155+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":319}
|
| 15 |
+
{"time":"2025-11-07T10:26:55.002055348+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":966}
|
| 16 |
+
{"time":"2025-11-07T10:26:55.002149962+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 17 |
+
{"time":"2025-11-07T10:26:55.002562082+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":998}
|
| 18 |
+
{"time":"2025-11-07T10:26:55.009356397+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":285}
|
| 19 |
+
{"time":"2025-11-07T10:27:05.018193552+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1664}
|
| 20 |
+
{"time":"2025-11-07T10:27:05.331667668+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 21 |
+
{"time":"2025-11-07T10:27:10.031761756+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2307}
|
| 22 |
+
{"time":"2025-11-07T10:27:10.031836934+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 23 |
+
{"time":"2025-11-07T10:27:15.03775749+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2500}
|
| 24 |
+
{"time":"2025-11-07T10:27:15.037865133+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 25 |
+
{"time":"2025-11-07T10:27:15.038270114+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2532}
|
| 26 |
+
{"time":"2025-11-07T10:27:15.039543895+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":147}
|
| 27 |
+
{"time":"2025-11-07T10:27:20.044229233+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2730}
|
| 28 |
+
{"time":"2025-11-07T10:27:20.326495928+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":281}
|
| 29 |
+
{"time":"2025-11-07T10:27:25.050848255+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3097}
|
| 30 |
+
{"time":"2025-11-07T10:27:25.05091684+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 31 |
+
{"time":"2025-11-07T10:27:25.051418353+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3129}
|
| 32 |
+
{"time":"2025-11-07T10:27:25.053863604+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":249}
|
| 33 |
+
{"time":"2025-11-07T10:27:30.057397574+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3429}
|
| 34 |
+
{"time":"2025-11-07T10:27:30.057494707+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 35 |
+
{"time":"2025-11-07T10:27:30.057854865+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3461}
|
| 36 |
+
{"time":"2025-11-07T10:27:30.060495635+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":259}
|
| 37 |
+
{"time":"2025-11-07T10:27:35.07649203+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3797}
|
| 38 |
+
{"time":"2025-11-07T10:27:35.27622333+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":280}
|
| 39 |
+
{"time":"2025-11-07T10:27:40.083967862+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4128}
|
| 40 |
+
{"time":"2025-11-07T10:27:40.084146434+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 41 |
+
{"time":"2025-11-07T10:27:40.084472099+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4160}
|
| 42 |
+
{"time":"2025-11-07T10:27:40.086936595+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 43 |
+
{"time":"2025-11-07T10:27:45.092861781+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4496}
|
| 44 |
+
{"time":"2025-11-07T10:27:45.092928318+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 45 |
+
{"time":"2025-11-07T10:27:45.093417362+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4528}
|
| 46 |
+
{"time":"2025-11-07T10:27:45.09732899+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":246}
|
| 47 |
+
{"time":"2025-11-07T10:27:50.100469955+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4827}
|
| 48 |
+
{"time":"2025-11-07T10:27:50.339439289+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":320}
|
| 49 |
+
{"time":"2025-11-07T10:27:55.107527698+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5203}
|
| 50 |
+
{"time":"2025-11-07T10:27:55.107591925+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 51 |
+
{"time":"2025-11-07T10:27:55.108033547+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5235}
|
| 52 |
+
{"time":"2025-11-07T10:27:55.111821673+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":279}
|
| 53 |
+
{"time":"2025-11-07T10:28:05.122107602+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5895}
|
| 54 |
+
{"time":"2025-11-07T10:28:05.236283223+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 55 |
+
{"time":"2025-11-07T10:28:10.128830958+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6266}
|
| 56 |
+
{"time":"2025-11-07T10:28:10.128925836+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 57 |
+
{"time":"2025-11-07T10:28:10.129460344+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6298}
|
| 58 |
+
{"time":"2025-11-07T10:28:10.13199436+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":284}
|
| 59 |
+
{"time":"2025-11-07T10:28:15.137230668+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6727}
|
| 60 |
+
{"time":"2025-11-07T10:28:15.137336027+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 61 |
+
{"time":"2025-11-07T10:28:15.137720284+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6759}
|
| 62 |
+
{"time":"2025-11-07T10:28:15.138856926+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":151}
|
| 63 |
+
{"time":"2025-11-07T10:28:20.14295049+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6962}
|
| 64 |
+
{"time":"2025-11-07T10:28:20.274436083+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":319}
|
| 65 |
+
{"time":"2025-11-07T10:28:25.152046634+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7626}
|
| 66 |
+
{"time":"2025-11-07T10:28:25.15216733+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 67 |
+
{"time":"2025-11-07T10:28:30.161394355+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7846}
|
| 68 |
+
{"time":"2025-11-07T10:28:30.161474969+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 69 |
+
{"time":"2025-11-07T10:28:30.161877754+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7878}
|
| 70 |
+
{"time":"2025-11-07T10:28:30.163607669+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":100}
|
| 71 |
+
{"time":"2025-11-07T10:28:35.167466563+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8031}
|
| 72 |
+
{"time":"2025-11-07T10:28:35.283489533+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 73 |
+
{"time":"2025-11-07T10:28:40.174265357+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8442}
|
| 74 |
+
{"time":"2025-11-07T10:28:40.174349051+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 75 |
+
{"time":"2025-11-07T10:28:40.174769736+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8474}
|
| 76 |
+
{"time":"2025-11-07T10:28:40.178530405+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":244}
|
| 77 |
+
{"time":"2025-11-07T10:28:45.184290307+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8866}
|
| 78 |
+
{"time":"2025-11-07T10:28:45.18446969+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 79 |
+
{"time":"2025-11-07T10:28:45.184790363+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8898}
|
| 80 |
+
{"time":"2025-11-07T10:28:45.185974572+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":148}
|
| 81 |
+
{"time":"2025-11-07T10:28:50.190177678+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":9099}
|
| 82 |
+
{"time":"2025-11-07T10:28:50.309608655+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 83 |
+
{"time":"2025-11-07T10:29:00.204935353+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":9859}
|
| 84 |
+
{"time":"2025-11-07T10:29:00.205034074+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 85 |
+
{"time":"2025-11-07T10:29:00.205462661+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":9891}
|
| 86 |
+
{"time":"2025-11-07T10:29:00.207011094+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":223}
|
| 87 |
+
{"time":"2025-11-07T10:29:05.21154651+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":10165}
|
| 88 |
+
{"time":"2025-11-07T10:29:05.253318623+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":320}
|
| 89 |
+
{"time":"2025-11-07T10:29:10.219829464+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":10551}
|
| 90 |
+
{"time":"2025-11-07T10:29:10.21991712+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 91 |
+
{"time":"2025-11-07T10:29:10.22034466+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":10583}
|
| 92 |
+
{"time":"2025-11-07T10:29:10.22287408+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":230}
|
| 93 |
+
{"time":"2025-11-07T10:29:15.228375922+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11048}
|
| 94 |
+
{"time":"2025-11-07T10:29:15.228428694+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 95 |
+
{"time":"2025-11-07T10:29:15.228890991+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11080}
|
| 96 |
+
{"time":"2025-11-07T10:29:15.230953936+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":102}
|
| 97 |
+
{"time":"2025-11-07T10:29:20.235020269+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11233}
|
| 98 |
+
{"time":"2025-11-07T10:29:20.314026917+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":320}
|
| 99 |
+
{"time":"2025-11-07T10:29:25.24166487+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11619}
|
| 100 |
+
{"time":"2025-11-07T10:29:25.241780056+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 101 |
+
{"time":"2025-11-07T10:29:25.242814382+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11652}
|
| 102 |
+
{"time":"2025-11-07T10:29:25.246017883+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":270}
|
| 103 |
+
{"time":"2025-11-07T10:29:30.249524383+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12023}
|
| 104 |
+
{"time":"2025-11-07T10:29:30.249602423+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 105 |
+
{"time":"2025-11-07T10:29:30.250043012+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12055}
|
| 106 |
+
{"time":"2025-11-07T10:29:30.252450902+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":195}
|
| 107 |
+
{"time":"2025-11-07T10:29:35.256840642+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12303}
|
| 108 |
+
{"time":"2025-11-07T10:29:35.273715662+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 109 |
+
{"time":"2025-11-07T10:29:40.262878908+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12672}
|
| 110 |
+
{"time":"2025-11-07T10:29:40.263010145+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 111 |
+
{"time":"2025-11-07T10:29:40.264085587+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12705}
|
| 112 |
+
{"time":"2025-11-07T10:29:40.266025691+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":285}
|
| 113 |
+
{"time":"2025-11-07T10:29:45.27048696+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13040}
|
| 114 |
+
{"time":"2025-11-07T10:29:45.270586377+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 115 |
+
{"time":"2025-11-07T10:29:45.270990672+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13072}
|
| 116 |
+
{"time":"2025-11-07T10:29:45.27372833+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":246}
|
| 117 |
+
{"time":"2025-11-07T10:29:50.277657296+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13371}
|
| 118 |
+
{"time":"2025-11-07T10:29:50.323990746+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":318}
|
| 119 |
+
{"time":"2025-11-07T10:30:00.289980525+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":14107}
|
| 120 |
+
{"time":"2025-11-07T10:30:00.290096526+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 121 |
+
{"time":"2025-11-07T10:30:00.290474489+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":14139}
|
| 122 |
+
{"time":"2025-11-07T10:30:00.293801683+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":247}
|
| 123 |
+
{"time":"2025-11-07T10:30:10.50009327+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":14924}
|
| 124 |
+
{"time":"2025-11-07T10:30:10.500155877+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 125 |
+
{"time":"2025-11-07T10:30:10.500665245+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":14956}
|
| 126 |
+
{"time":"2025-11-07T10:30:10.502914625+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":129}
|
| 127 |
+
{"time":"2025-11-07T10:30:15.507664487+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15163}
|
| 128 |
+
{"time":"2025-11-07T10:30:15.50775712+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 129 |
+
{"time":"2025-11-07T10:30:15.508234394+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15195}
|
| 130 |
+
{"time":"2025-11-07T10:30:15.510794899+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":259}
|
| 131 |
+
{"time":"2025-11-07T10:30:20.513938488+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15507}
|
| 132 |
+
{"time":"2025-11-07T10:30:20.514102014+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 133 |
+
{"time":"2025-11-07T10:30:20.514489935+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15539}
|
| 134 |
+
{"time":"2025-11-07T10:30:20.518286051+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 135 |
+
{"time":"2025-11-07T10:30:30.529576756+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16206}
|
| 136 |
+
{"time":"2025-11-07T10:30:30.529673928+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 137 |
+
{"time":"2025-11-07T10:30:30.530082694+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16238}
|
| 138 |
+
{"time":"2025-11-07T10:30:30.532515502+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":284}
|
| 139 |
+
{"time":"2025-11-07T10:30:35.538915645+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16805}
|
| 140 |
+
{"time":"2025-11-07T10:30:35.539012451+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 141 |
+
{"time":"2025-11-07T10:30:35.53942978+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16837}
|
| 142 |
+
{"time":"2025-11-07T10:30:35.540269789+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":56}
|
| 143 |
+
{"time":"2025-11-07T10:30:40.544226242+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16944}
|
| 144 |
+
{"time":"2025-11-07T10:30:40.544343441+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 145 |
+
{"time":"2025-11-07T10:30:40.544779826+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16976}
|
| 146 |
+
{"time":"2025-11-07T10:30:40.548714455+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 147 |
+
{"time":"2025-11-07T10:30:45.554068318+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17393}
|
| 148 |
+
{"time":"2025-11-07T10:30:45.554160917+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 149 |
+
{"time":"2025-11-07T10:30:45.555212294+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17426}
|
| 150 |
+
{"time":"2025-11-07T10:30:45.556956894+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":205}
|
| 151 |
+
{"time":"2025-11-07T10:30:50.564112084+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17818}
|
| 152 |
+
{"time":"2025-11-07T10:30:50.564991459+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 153 |
+
{"time":"2025-11-07T10:30:50.567275445+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17850}
|
| 154 |
+
{"time":"2025-11-07T10:30:50.568448329+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":111}
|
| 155 |
+
{"time":"2025-11-07T10:30:55.575175818+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18012}
|
| 156 |
+
{"time":"2025-11-07T10:30:55.575313884+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 157 |
+
{"time":"2025-11-07T10:30:55.575718877+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18044}
|
| 158 |
+
{"time":"2025-11-07T10:30:55.57816212+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 159 |
+
{"time":"2025-11-07T10:31:00.582052443+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18417}
|
| 160 |
+
{"time":"2025-11-07T10:31:00.582137728+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 161 |
+
{"time":"2025-11-07T10:31:00.582667455+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18449}
|
| 162 |
+
{"time":"2025-11-07T10:31:00.585301219+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":250}
|
| 163 |
+
{"time":"2025-11-07T10:31:10.596861654+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19363}
|
| 164 |
+
{"time":"2025-11-07T10:31:10.596914261+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 165 |
+
{"time":"2025-11-07T10:31:10.597466165+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19395}
|
| 166 |
+
{"time":"2025-11-07T10:31:10.598123022+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":44}
|
| 167 |
+
{"time":"2025-11-07T10:31:20.610659076+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19820}
|
| 168 |
+
{"time":"2025-11-07T10:31:20.610764714+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 169 |
+
{"time":"2025-11-07T10:31:20.611124722+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19852}
|
| 170 |
+
{"time":"2025-11-07T10:31:20.613309934+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 171 |
+
{"time":"2025-11-07T10:31:25.617061073+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20198}
|
| 172 |
+
{"time":"2025-11-07T10:31:25.61719025+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 173 |
+
{"time":"2025-11-07T10:31:25.617706379+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20230}
|
| 174 |
+
{"time":"2025-11-07T10:31:25.621751248+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":277}
|
| 175 |
+
{"time":"2025-11-07T10:31:35.641998758+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20929}
|
| 176 |
+
{"time":"2025-11-07T10:31:35.64212159+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 177 |
+
{"time":"2025-11-07T10:31:35.642553825+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20961}
|
| 178 |
+
{"time":"2025-11-07T10:31:35.645901846+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":245}
|
| 179 |
+
{"time":"2025-11-07T10:31:40.64944534+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21257}
|
| 180 |
+
{"time":"2025-11-07T10:31:40.649572308+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 181 |
+
{"time":"2025-11-07T10:31:40.649925229+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21289}
|
| 182 |
+
{"time":"2025-11-07T10:31:40.652748134+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 183 |
+
{"time":"2025-11-07T10:31:45.656732285+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21627}
|
| 184 |
+
{"time":"2025-11-07T10:31:45.656804166+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 185 |
+
{"time":"2025-11-07T10:31:45.657157332+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21659}
|
| 186 |
+
{"time":"2025-11-07T10:31:45.659331659+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":285}
|
| 187 |
+
{"time":"2025-11-07T10:31:50.663524025+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22068}
|
| 188 |
+
{"time":"2025-11-07T10:31:50.663644198+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 189 |
+
{"time":"2025-11-07T10:31:50.664544855+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22101}
|
| 190 |
+
{"time":"2025-11-07T10:31:50.666148276+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":214}
|
| 191 |
+
{"time":"2025-11-07T10:31:55.670845697+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22485}
|
| 192 |
+
{"time":"2025-11-07T10:31:55.670921361+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 193 |
+
{"time":"2025-11-07T10:31:55.671330596+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22517}
|
| 194 |
+
{"time":"2025-11-07T10:31:55.673056616+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":126}
|
| 195 |
+
{"time":"2025-11-07T10:32:00.676947335+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22694}
|
| 196 |
+
{"time":"2025-11-07T10:32:00.677057913+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 197 |
+
{"time":"2025-11-07T10:32:00.677427193+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22726}
|
| 198 |
+
{"time":"2025-11-07T10:32:00.680283995+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":286}
|
| 199 |
+
{"time":"2025-11-07T10:32:05.683856877+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23090}
|
| 200 |
+
{"time":"2025-11-07T10:32:05.68395789+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 201 |
+
{"time":"2025-11-07T10:32:05.684365549+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23122}
|
| 202 |
+
{"time":"2025-11-07T10:32:05.688121324+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":261}
|
| 203 |
+
{"time":"2025-11-07T10:32:10.69230954+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23483}
|
| 204 |
+
{"time":"2025-11-07T10:32:10.692383474+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 205 |
+
{"time":"2025-11-07T10:32:10.69277669+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23515}
|
| 206 |
+
{"time":"2025-11-07T10:32:10.694559666+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":237}
|
| 207 |
+
{"time":"2025-11-07T10:32:15.698531312+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23804}
|
| 208 |
+
{"time":"2025-11-07T10:32:15.698590195+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 209 |
+
{"time":"2025-11-07T10:32:15.699153865+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23836}
|
| 210 |
+
{"time":"2025-11-07T10:32:15.70155554+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":285}
|
| 211 |
+
{"time":"2025-11-07T10:32:20.70670464+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24213}
|
| 212 |
+
{"time":"2025-11-07T10:32:20.706773936+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 213 |
+
{"time":"2025-11-07T10:32:20.7071748+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24245}
|
| 214 |
+
{"time":"2025-11-07T10:32:20.708921999+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":206}
|
| 215 |
+
{"time":"2025-11-07T10:32:25.715336191+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24557}
|
| 216 |
+
{"time":"2025-11-07T10:32:25.715410672+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 217 |
+
{"time":"2025-11-07T10:32:25.715858076+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24589}
|
| 218 |
+
{"time":"2025-11-07T10:32:25.718257413+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":231}
|
| 219 |
+
{"time":"2025-11-07T10:32:28.712161761+08:00","level":"INFO","msg":"stream: closing","id":"lu2iu68t"}
|
| 220 |
+
{"time":"2025-11-07T10:32:28.714878124+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24866}
|
| 221 |
+
{"time":"2025-11-07T10:32:28.716691076+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":200}
|
| 222 |
+
{"time":"2025-11-07T10:32:30.640307526+08:00","level":"INFO","msg":"fileTransfer: Close: file transfer manager closed"}
|
| 223 |
+
{"time":"2025-11-07T10:32:31.028402195+08:00","level":"INFO","msg":"handler: closed","stream_id":"lu2iu68t"}
|
| 224 |
+
{"time":"2025-11-07T10:32:31.030068564+08:00","level":"INFO","msg":"sender: closed","stream_id":"lu2iu68t"}
|
| 225 |
+
{"time":"2025-11-07T10:32:31.030166843+08:00","level":"INFO","msg":"stream: closed","id":"lu2iu68t"}
|
cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug.log
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-11-07 10:26:33,767 INFO MainThread:132004 [wandb_setup.py:_flush():81] Current SDK version is 0.22.3
|
| 2 |
+
2025-11-07 10:26:33,768 INFO MainThread:132004 [wandb_setup.py:_flush():81] Configure stats pid to 132004
|
| 3 |
+
2025-11-07 10:26:33,768 INFO MainThread:132004 [wandb_setup.py:_flush():81] Loading settings from /root/.config/wandb/settings
|
| 4 |
+
2025-11-07 10:26:33,768 INFO MainThread:132004 [wandb_setup.py:_flush():81] Loading settings from /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/settings
|
| 5 |
+
2025-11-07 10:26:33,768 INFO MainThread:132004 [wandb_setup.py:_flush():81] Loading settings from environment variables
|
| 6 |
+
2025-11-07 10:26:33,768 INFO MainThread:132004 [wandb_init.py:setup_run_log_directory():706] Logging user logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug.log
|
| 7 |
+
2025-11-07 10:26:33,769 INFO MainThread:132004 [wandb_init.py:setup_run_log_directory():707] Logging internal logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_102633-lu2iu68t/logs/debug-internal.log
|
| 8 |
+
2025-11-07 10:26:33,770 INFO MainThread:132004 [wandb_init.py:init():833] calling init triggers
|
| 9 |
+
2025-11-07 10:26:33,770 INFO MainThread:132004 [wandb_init.py:init():838] wandb.init called with sweep_config: {}
|
| 10 |
+
config: {'exp_name': 'ppo_bandit', 'seed': 1, 'torch_deterministic': True, 'cuda': True, 'track': True, 'wandb_project_name': 'ragen-bandit', 'wandb_entity': None, 'capture_video': False, 'env_id': 'Bandit', 'total_timesteps': 10000000, 'learning_rate': 0.00025, 'num_envs': 32, 'num_steps': 512, 'anneal_lr': True, 'gamma': 0.99, 'gae_lambda': 0.95, 'num_minibatches': 4, 'update_epochs': 4, 'norm_adv': True, 'clip_coef': 0.2, 'clip_vloss': True, 'ent_coef': 0.01, 'vf_coef': 0.5, 'max_grad_norm': 0.5, 'target_kl': None, 'batch_size': 16384, 'minibatch_size': 4096, 'num_iterations': 610, '_wandb': {'code_path': 'code/cleanrl/ppo_bandit.py'}}
|
| 11 |
+
2025-11-07 10:26:33,770 INFO MainThread:132004 [wandb_init.py:init():881] starting backend
|
| 12 |
+
2025-11-07 10:26:33,976 INFO MainThread:132004 [wandb_init.py:init():884] sending inform_init request
|
| 13 |
+
2025-11-07 10:26:33,986 INFO MainThread:132004 [wandb_init.py:init():892] backend started and connected
|
| 14 |
+
2025-11-07 10:26:33,987 INFO MainThread:132004 [wandb_init.py:init():962] updated telemetry
|
| 15 |
+
2025-11-07 10:26:34,019 INFO MainThread:132004 [wandb_init.py:init():986] communicating run to backend with 90.0 second timeout
|
| 16 |
+
2025-11-07 10:26:34,837 INFO MainThread:132004 [wandb_init.py:init():1033] starting run threads in backend
|
| 17 |
+
2025-11-07 10:26:34,980 INFO MainThread:132004 [wandb_run.py:_console_start():2506] atexit reg
|
| 18 |
+
2025-11-07 10:26:34,980 INFO MainThread:132004 [wandb_run.py:_redirect():2354] redirect: wrap_raw
|
| 19 |
+
2025-11-07 10:26:34,980 INFO MainThread:132004 [wandb_run.py:_redirect():2423] Wrapping output streams.
|
| 20 |
+
2025-11-07 10:26:34,980 INFO MainThread:132004 [wandb_run.py:_redirect():2446] Redirects installed.
|
| 21 |
+
2025-11-07 10:26:34,982 INFO MainThread:132004 [wandb_init.py:init():1073] run started, returning control to user process
|
| 22 |
+
2025-11-07 10:26:34,983 INFO MainThread:132004 [wandb_run.py:_tensorboard_callback():1598] tensorboard callback: runs/Bandit__ppo_bandit__1__1762482386, True
|
| 23 |
+
2025-11-07 10:32:28,712 INFO wandb-AsyncioManager-main:132004 [service_client.py:_forward_responses():80] Reached EOF.
|
| 24 |
+
2025-11-07 10:32:28,712 INFO wandb-AsyncioManager-main:132004 [mailbox.py:close():137] Closing mailbox, abandoning 1 handles.
|
cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/files/requirements.txt
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
ragen==0.1
|
| 2 |
+
setuptools==80.9.0
|
| 3 |
+
wheel==0.45.1
|
| 4 |
+
pip==25.2
|
| 5 |
+
zipp==3.23.0
|
| 6 |
+
verl==0.2.0.dev0
|
| 7 |
+
ragen==0.1
|
| 8 |
+
triton==3.2.0
|
| 9 |
+
nvidia-cusparselt-cu12==0.6.2
|
| 10 |
+
mpmath==1.3.0
|
| 11 |
+
typing_extensions==4.15.0
|
| 12 |
+
sympy==1.13.1
|
| 13 |
+
nvidia-nvtx-cu12==12.4.127
|
| 14 |
+
nvidia-nvjitlink-cu12==12.4.127
|
| 15 |
+
nvidia-nccl-cu12==2.21.5
|
| 16 |
+
nvidia-curand-cu12==10.3.5.147
|
| 17 |
+
nvidia-cufft-cu12==11.2.1.3
|
| 18 |
+
nvidia-cuda-runtime-cu12==12.4.127
|
| 19 |
+
nvidia-cuda-nvrtc-cu12==12.4.127
|
| 20 |
+
nvidia-cuda-cupti-cu12==12.4.127
|
| 21 |
+
nvidia-cublas-cu12==12.4.5.8
|
| 22 |
+
networkx==3.5
|
| 23 |
+
MarkupSafe==2.1.5
|
| 24 |
+
fsspec==2025.9.0
|
| 25 |
+
filelock==3.19.1
|
| 26 |
+
nvidia-cusparse-cu12==12.3.1.170
|
| 27 |
+
nvidia-cudnn-cu12==9.1.0.70
|
| 28 |
+
Jinja2==3.1.6
|
| 29 |
+
nvidia-cusolver-cu12==11.6.1.9
|
| 30 |
+
torch==2.6.0+cu124
|
| 31 |
+
einops==0.8.1
|
| 32 |
+
flash_attn==2.7.4.post1
|
| 33 |
+
pytz==2025.2
|
| 34 |
+
pyperclip==1.11.0
|
| 35 |
+
pylatexenc==2.10
|
| 36 |
+
pyjnius==1.7.0
|
| 37 |
+
py-cpuinfo==9.0.0
|
| 38 |
+
pure_eval==0.2.3
|
| 39 |
+
ptyprocess==0.7.0
|
| 40 |
+
gym-notices==0.1.0
|
| 41 |
+
flatbuffers==25.9.23
|
| 42 |
+
fastrlock==0.8.3
|
| 43 |
+
Farama-Notifications==0.0.4
|
| 44 |
+
cymem==2.0.11
|
| 45 |
+
antlr4-python3-runtime==4.9.3
|
| 46 |
+
xxhash==3.6.0
|
| 47 |
+
wrapt==2.0.0
|
| 48 |
+
Werkzeug==3.1.3
|
| 49 |
+
websockets==15.0.1
|
| 50 |
+
wcwidth==0.2.14
|
| 51 |
+
wasabi==1.1.3
|
| 52 |
+
uvloop==0.22.1
|
| 53 |
+
urllib3==2.5.0
|
| 54 |
+
tzdata==2025.2
|
| 55 |
+
typing-inspection==0.4.2
|
| 56 |
+
traitlets==5.14.3
|
| 57 |
+
tqdm==4.67.1
|
| 58 |
+
threadpoolctl==3.6.0
|
| 59 |
+
tabulate==0.9.0
|
| 60 |
+
spacy-loggers==1.0.5
|
| 61 |
+
spacy-legacy==3.0.12
|
| 62 |
+
soupsieve==2.8
|
| 63 |
+
sniffio==1.3.1
|
| 64 |
+
smmap==5.0.2
|
| 65 |
+
six==1.17.0
|
| 66 |
+
shellingham==1.5.4
|
| 67 |
+
sentencepiece==0.2.1
|
| 68 |
+
safetensors==0.6.2
|
| 69 |
+
rpds-py==0.28.0
|
| 70 |
+
rignore==0.7.6
|
| 71 |
+
regex==2025.11.3
|
| 72 |
+
RapidFuzz==3.14.3
|
| 73 |
+
pyzmq==27.1.0
|
| 74 |
+
PyYAML==6.0.3
|
| 75 |
+
pytokens==0.3.0
|
| 76 |
+
python-multipart==0.0.20
|
| 77 |
+
python-json-logger==4.0.0
|
| 78 |
+
python-dotenv==1.2.1
|
| 79 |
+
PySocks==1.7.1
|
| 80 |
+
pyparsing==3.2.5
|
| 81 |
+
PyJWT==2.10.1
|
| 82 |
+
Pygments==2.19.2
|
| 83 |
+
pygame==2.6.1
|
| 84 |
+
pydantic_core==2.41.5
|
| 85 |
+
pycparser==2.23
|
| 86 |
+
pycountry==24.6.1
|
| 87 |
+
pybind11==3.0.1
|
| 88 |
+
pyarrow==22.0.0
|
| 89 |
+
psutil==7.1.3
|
| 90 |
+
protobuf==6.33.0
|
| 91 |
+
propcache==0.4.1
|
| 92 |
+
prometheus_client==0.23.1
|
| 93 |
+
platformdirs==4.5.0
|
| 94 |
+
pillow==11.3.0
|
| 95 |
+
pexpect==4.9.0
|
| 96 |
+
pathvalidate==3.3.1
|
| 97 |
+
pathspec==0.12.1
|
| 98 |
+
pathable==0.4.4
|
| 99 |
+
partial-json-parser==0.2.1.1.post6
|
| 100 |
+
parso==0.8.5
|
| 101 |
+
packaging==25.0
|
| 102 |
+
orjson==3.11.4
|
| 103 |
+
numpy==1.26.4
|
| 104 |
+
ninja==1.13.0
|
| 105 |
+
nest-asyncio==1.6.0
|
| 106 |
+
mypy_extensions==1.1.0
|
| 107 |
+
murmurhash==1.0.13
|
| 108 |
+
multidict==6.7.0
|
| 109 |
+
msgspec==0.19.0
|
| 110 |
+
msgpack==1.1.2
|
| 111 |
+
more-itertools==10.8.0
|
| 112 |
+
mdurl==0.1.2
|
| 113 |
+
marisa-trie==1.3.1
|
| 114 |
+
llvmlite==0.43.0
|
| 115 |
+
llguidance==0.7.30
|
| 116 |
+
lark==1.2.2
|
| 117 |
+
kiwisolver==1.4.9
|
| 118 |
+
joblib==1.5.2
|
| 119 |
+
jiter==0.11.1
|
| 120 |
+
jeepney==0.9.0
|
| 121 |
+
jaraco.context==6.0.1
|
| 122 |
+
itsdangerous==2.2.0
|
| 123 |
+
interegular==0.3.3
|
| 124 |
+
idna==3.11
|
| 125 |
+
humanfriendly==10.0
|
| 126 |
+
httpx-sse==0.4.3
|
| 127 |
+
httptools==0.7.1
|
| 128 |
+
html2text==2025.4.15
|
| 129 |
+
hf-xet==1.2.0
|
| 130 |
+
h11==0.16.0
|
| 131 |
+
frozenlist==1.8.0
|
| 132 |
+
fonttools==4.60.1
|
| 133 |
+
executing==2.2.1
|
| 134 |
+
exceptiongroup==1.3.0
|
| 135 |
+
eval_type_backport==0.2.2
|
| 136 |
+
docutils==0.22.3
|
| 137 |
+
docstring_parser==0.17.0
|
| 138 |
+
dnspython==2.8.0
|
| 139 |
+
distro==1.9.0
|
| 140 |
+
diskcache==5.6.3
|
| 141 |
+
dill==0.4.0
|
| 142 |
+
decorator==5.2.1
|
| 143 |
+
debugpy==1.8.17
|
| 144 |
+
Cython==3.2.0
|
| 145 |
+
cycler==0.12.1
|
| 146 |
+
codetiming==1.4.0
|
| 147 |
+
cloudpickle==3.1.2
|
| 148 |
+
cloudpathlib==0.23.0
|
| 149 |
+
click==8.2.1
|
| 150 |
+
charset-normalizer==3.4.4
|
| 151 |
+
certifi==2025.10.5
|
| 152 |
+
catalogue==2.0.10
|
| 153 |
+
cachetools==6.2.1
|
| 154 |
+
blinker==1.9.0
|
| 155 |
+
blake3==1.0.8
|
| 156 |
+
beartype==0.22.5
|
| 157 |
+
attrs==25.4.0
|
| 158 |
+
asttokens==3.0.0
|
| 159 |
+
astor==0.8.1
|
| 160 |
+
annotated-types==0.7.0
|
| 161 |
+
annotated-doc==0.0.3
|
| 162 |
+
airportsdata==20250909
|
| 163 |
+
aiohappyeyeballs==2.6.1
|
| 164 |
+
yarl==1.22.0
|
| 165 |
+
uvicorn==0.38.0
|
| 166 |
+
typer-slim==0.20.0
|
| 167 |
+
thefuzz==0.22.1
|
| 168 |
+
stack-data==0.6.3
|
| 169 |
+
srsly==2.5.1
|
| 170 |
+
smart_open==7.4.4
|
| 171 |
+
sentry-sdk==2.43.0
|
| 172 |
+
scipy==1.16.3
|
| 173 |
+
requests==2.32.5
|
| 174 |
+
referencing==0.36.2
|
| 175 |
+
rank-bm25==0.2.2
|
| 176 |
+
python-dateutil==2.9.0.post0
|
| 177 |
+
pydantic==2.12.4
|
| 178 |
+
py-key-value-shared==0.2.8
|
| 179 |
+
prompt_toolkit==3.0.52
|
| 180 |
+
preshed==3.0.10
|
| 181 |
+
opencv-python-headless==4.11.0.86
|
| 182 |
+
omegaconf==2.3.0
|
| 183 |
+
numba==0.60.0
|
| 184 |
+
nltk==3.9.2
|
| 185 |
+
multiprocess==0.70.18
|
| 186 |
+
matplotlib-inline==0.2.1
|
| 187 |
+
markdown-it-py==4.0.0
|
| 188 |
+
language_data==1.3.0
|
| 189 |
+
jedi==0.19.2
|
| 190 |
+
jaraco.functools==4.3.0
|
| 191 |
+
jaraco.classes==3.4.0
|
| 192 |
+
ipython_pygments_lexers==1.1.1
|
| 193 |
+
importlib_metadata==8.7.0
|
| 194 |
+
ImageIO==2.37.2
|
| 195 |
+
httpcore==1.0.9
|
| 196 |
+
gymnasium==1.2.2
|
| 197 |
+
gym==0.26.2
|
| 198 |
+
gitdb==4.0.12
|
| 199 |
+
gguf==0.10.0
|
| 200 |
+
Flask==3.1.2
|
| 201 |
+
faiss-cpu==1.12.0
|
| 202 |
+
email-validator==2.3.0
|
| 203 |
+
depyf==0.18.0
|
| 204 |
+
cupy-cuda12x==13.6.0
|
| 205 |
+
contourpy==1.3.3
|
| 206 |
+
coloredlogs==15.0.1
|
| 207 |
+
cffi==2.0.0
|
| 208 |
+
blis==1.3.0
|
| 209 |
+
black==25.9.0
|
| 210 |
+
beautifulsoup4==4.14.2
|
| 211 |
+
anyio==4.11.0
|
| 212 |
+
aiosignal==1.4.0
|
| 213 |
+
watchfiles==1.1.1
|
| 214 |
+
tiktoken==0.12.0
|
| 215 |
+
starlette==0.49.3
|
| 216 |
+
sse-starlette==3.0.3
|
| 217 |
+
scikit-learn==1.7.2
|
| 218 |
+
rich==14.2.0
|
| 219 |
+
pydantic-settings==2.11.0
|
| 220 |
+
pydantic-extra-types==2.10.6
|
| 221 |
+
py-key-value-aio==0.2.8
|
| 222 |
+
pandas==2.3.3
|
| 223 |
+
openapi-pydantic==0.5.1
|
| 224 |
+
onnxruntime==1.23.2
|
| 225 |
+
matplotlib==3.10.7
|
| 226 |
+
lm-format-enforcer==0.10.12
|
| 227 |
+
langcodes==3.5.0
|
| 228 |
+
jsonschema-specifications==2025.9.1
|
| 229 |
+
jsonschema-path==0.3.4
|
| 230 |
+
ipython==9.7.0
|
| 231 |
+
hydra-core==1.3.2
|
| 232 |
+
huggingface-hub==0.36.0
|
| 233 |
+
httpx==0.28.1
|
| 234 |
+
gym-sokoban==0.0.6
|
| 235 |
+
GitPython==3.1.45
|
| 236 |
+
cryptography==46.0.3
|
| 237 |
+
confection==0.1.5
|
| 238 |
+
cleantext==1.1.4
|
| 239 |
+
aiohttp==3.13.2
|
| 240 |
+
xformers==0.0.29.post2
|
| 241 |
+
weasel==0.4.2
|
| 242 |
+
wandb==0.22.3
|
| 243 |
+
typer==0.19.2
|
| 244 |
+
torchvision==0.21.0
|
| 245 |
+
torchdata==0.11.0
|
| 246 |
+
torchaudio==2.6.0
|
| 247 |
+
tokenizers==0.22.1
|
| 248 |
+
thinc==8.3.7
|
| 249 |
+
tensordict==0.8.3
|
| 250 |
+
SecretStorage==3.4.0
|
| 251 |
+
rich-toolkit==0.15.1
|
| 252 |
+
rich-rst==1.3.2
|
| 253 |
+
prometheus-fastapi-instrumentator==7.1.0
|
| 254 |
+
openai==2.7.1
|
| 255 |
+
jsonschema==4.25.1
|
| 256 |
+
gdown==5.2.0
|
| 257 |
+
fastapi==0.121.0
|
| 258 |
+
Authlib==1.6.5
|
| 259 |
+
anthropic==0.72.0
|
| 260 |
+
accelerate==1.11.0
|
| 261 |
+
transformers==4.57.1
|
| 262 |
+
together==1.5.30
|
| 263 |
+
spacy==3.8.7
|
| 264 |
+
ray==2.51.1
|
| 265 |
+
outlines_core==0.1.26
|
| 266 |
+
mistral_common==1.8.5
|
| 267 |
+
mcp==1.20.0
|
| 268 |
+
keyring==25.6.0
|
| 269 |
+
fastapi-cloud-cli==0.3.1
|
| 270 |
+
fastapi-cli==0.0.14
|
| 271 |
+
datasets==4.4.1
|
| 272 |
+
cyclopts==4.2.1
|
| 273 |
+
xgrammar==0.1.16
|
| 274 |
+
peft==0.17.1
|
| 275 |
+
outlines==0.1.11
|
| 276 |
+
compressed-tensors==0.9.2
|
| 277 |
+
fastmcp==2.13.0.2
|
| 278 |
+
vllm==0.8.2
|
| 279 |
+
pyserini==1.3.0
|
| 280 |
+
typeguard==4.4.4
|
| 281 |
+
shtab==1.7.2
|
| 282 |
+
tyro==0.9.35
|
| 283 |
+
tensorboard-data-server==0.7.2
|
| 284 |
+
Markdown==3.10
|
| 285 |
+
grpcio==1.76.0
|
| 286 |
+
absl-py==2.3.1
|
| 287 |
+
tensorboard==2.20.0
|
| 288 |
+
ragen==0.1
|
| 289 |
+
verl==0.2.0.dev0
|
| 290 |
+
autocommand==2.2.2
|
| 291 |
+
backports.tarfile==1.2.0
|
| 292 |
+
importlib_metadata==8.0.0
|
| 293 |
+
inflect==7.3.1
|
| 294 |
+
jaraco.collections==5.1.0
|
| 295 |
+
jaraco.context==5.3.0
|
| 296 |
+
jaraco.functools==4.0.1
|
| 297 |
+
jaraco.text==3.12.1
|
| 298 |
+
more-itertools==10.3.0
|
| 299 |
+
packaging==24.2
|
| 300 |
+
platformdirs==4.2.2
|
| 301 |
+
tomli==2.0.1
|
| 302 |
+
typeguard==4.3.0
|
| 303 |
+
typing_extensions==4.12.2
|
| 304 |
+
wheel==0.45.1
|
| 305 |
+
zipp==3.19.2
|
cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/files/wandb-summary.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"losses/entropy":0.24892157,"charts/SPS":3573,"charts/learning_rate":2.5614753e-07,"_step":12687,"_wandb":{"runtime":281},"charts/avg_value":0.63738394,"_timestamp":1.762483093763157e+09,"losses/policy_loss":-1.9334257e-05,"charts/min_reward":0,"losses/approx_kl":2.8405339e-08,"_runtime":281,"global_step":999424,"losses/clipfrac":0,"losses/explained_variance":0.47075754,"losses/old_approx_kl":-1.279125e-05,"charts/max_reward":1,"charts/avg_reward":0.068359375,"losses/value_loss":0.044154726}
|
cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug-internal.log
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"time":"2025-11-07T10:33:31.614061411+08:00","level":"INFO","msg":"stream: starting","core version":"0.22.3"}
|
| 2 |
+
{"time":"2025-11-07T10:33:31.984255546+08:00","level":"INFO","msg":"stream: created new stream","id":"e2e7wd2b"}
|
| 3 |
+
{"time":"2025-11-07T10:33:31.984490658+08:00","level":"INFO","msg":"handler: started","stream_id":"e2e7wd2b"}
|
| 4 |
+
{"time":"2025-11-07T10:33:31.987878921+08:00","level":"INFO","msg":"stream: started","id":"e2e7wd2b"}
|
| 5 |
+
{"time":"2025-11-07T10:33:31.987895518+08:00","level":"INFO","msg":"writer: started","stream_id":"e2e7wd2b"}
|
| 6 |
+
{"time":"2025-11-07T10:33:31.987900181+08:00","level":"INFO","msg":"sender: started","stream_id":"e2e7wd2b"}
|
| 7 |
+
{"time":"2025-11-07T10:33:32.409366358+08:00","level":"ERROR","msg":"git repo not found","error":"repository does not exist"}
|
| 8 |
+
{"time":"2025-11-07T10:33:42.545223339+08:00","level":"WARN","msg":"tensorboard: no root directory","error":"timed out after 10s"}
|
| 9 |
+
{"time":"2025-11-07T10:33:42.545754694+08:00","level":"INFO","msg":"tensorboard: tracking new log directory","rootDir":{},"logDir":"LocalOrCloudPath(LocalPath=\"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/FrozenLake__ppo_frozenlake__1__1762482804\")","namespace":""}
|
| 10 |
+
{"time":"2025-11-07T10:33:42.547582969+08:00","level":"INFO","msg":"tensorboard: saving file","fileLocation":"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/FrozenLake__ppo_frozenlake__1__1762482804/events.out.tfevents.1762482812.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.132354.0","runPath":"runs/FrozenLake__ppo_frozenlake__1__1762482804/events.out.tfevents.1762482812.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.132354.0"}
|
| 11 |
+
{"time":"2025-11-07T10:33:42.550551293+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":144}
|
| 12 |
+
{"time":"2025-11-07T10:33:42.550636768+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 13 |
+
{"time":"2025-11-07T10:33:42.55069706+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":176}
|
| 14 |
+
{"time":"2025-11-07T10:33:42.556834201+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":723}
|
| 15 |
+
{"time":"2025-11-07T10:33:47.562448213+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1270}
|
| 16 |
+
{"time":"2025-11-07T10:33:47.811128663+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":671}
|
| 17 |
+
{"time":"2025-11-07T10:33:52.574443041+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2361}
|
| 18 |
+
{"time":"2025-11-07T10:33:52.574536664+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 19 |
+
{"time":"2025-11-07T10:33:52.57506063+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2393}
|
| 20 |
+
{"time":"2025-11-07T10:33:52.577088323+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":278}
|
| 21 |
+
{"time":"2025-11-07T10:33:57.586920766+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3222}
|
| 22 |
+
{"time":"2025-11-07T10:33:57.587008682+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 23 |
+
{"time":"2025-11-07T10:33:57.587517901+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3254}
|
| 24 |
+
{"time":"2025-11-07T10:33:57.588639877+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":120}
|
| 25 |
+
{"time":"2025-11-07T10:34:02.596123897+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3445}
|
| 26 |
+
{"time":"2025-11-07T10:34:02.852404015+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":671}
|
| 27 |
+
{"time":"2025-11-07T10:34:07.60408084+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4214}
|
| 28 |
+
{"time":"2025-11-07T10:34:07.604176707+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 29 |
+
{"time":"2025-11-07T10:34:07.604622587+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":4246}
|
| 30 |
+
{"time":"2025-11-07T10:34:07.610388793+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":606}
|
| 31 |
+
{"time":"2025-11-07T10:34:12.617556092+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5312}
|
| 32 |
+
{"time":"2025-11-07T10:34:12.617741948+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 33 |
+
{"time":"2025-11-07T10:34:12.618562139+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5344}
|
| 34 |
+
{"time":"2025-11-07T10:34:12.620356592+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":246}
|
| 35 |
+
{"time":"2025-11-07T10:34:17.62454859+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":5661}
|
| 36 |
+
{"time":"2025-11-07T10:34:17.890320497+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":671}
|
| 37 |
+
{"time":"2025-11-07T10:34:22.636094998+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6572}
|
| 38 |
+
{"time":"2025-11-07T10:34:22.636173084+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 39 |
+
{"time":"2025-11-07T10:34:22.636651662+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":6604}
|
| 40 |
+
{"time":"2025-11-07T10:34:22.639405547+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":464}
|
| 41 |
+
{"time":"2025-11-07T10:34:27.645638559+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7137}
|
| 42 |
+
{"time":"2025-11-07T10:34:27.645753433+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 43 |
+
{"time":"2025-11-07T10:34:27.646109854+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7169}
|
| 44 |
+
{"time":"2025-11-07T10:34:27.652363469+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":637}
|
| 45 |
+
{"time":"2025-11-07T10:34:32.681515613+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":7916}
|
| 46 |
+
{"time":"2025-11-07T10:34:32.915240594+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":673}
|
| 47 |
+
{"time":"2025-11-07T10:34:37.69085891+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8827}
|
| 48 |
+
{"time":"2025-11-07T10:34:37.690946672+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 49 |
+
{"time":"2025-11-07T10:34:37.691338382+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":8859}
|
| 50 |
+
{"time":"2025-11-07T10:34:37.694474541+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":466}
|
| 51 |
+
{"time":"2025-11-07T10:34:42.70107648+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":9812}
|
| 52 |
+
{"time":"2025-11-07T10:34:42.70113031+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 53 |
+
{"time":"2025-11-07T10:34:42.70156025+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":9844}
|
| 54 |
+
{"time":"2025-11-07T10:34:42.703109465+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":219}
|
| 55 |
+
{"time":"2025-11-07T10:34:47.708115179+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":10131}
|
| 56 |
+
{"time":"2025-11-07T10:34:47.818784531+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":672}
|
| 57 |
+
{"time":"2025-11-07T10:34:52.7178812+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11075}
|
| 58 |
+
{"time":"2025-11-07T10:34:52.717944337+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 59 |
+
{"time":"2025-11-07T10:34:52.718390497+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":11107}
|
| 60 |
+
{"time":"2025-11-07T10:34:52.722639082+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":434}
|
| 61 |
+
{"time":"2025-11-07T10:34:57.727392949+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12009}
|
| 62 |
+
{"time":"2025-11-07T10:34:57.727469401+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 63 |
+
{"time":"2025-11-07T10:34:57.72793627+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12041}
|
| 64 |
+
{"time":"2025-11-07T10:34:57.729845282+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":238}
|
| 65 |
+
{"time":"2025-11-07T10:35:02.734452342+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":12348}
|
| 66 |
+
{"time":"2025-11-07T10:35:02.87983679+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":671}
|
| 67 |
+
{"time":"2025-11-07T10:35:07.745676237+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13086}
|
| 68 |
+
{"time":"2025-11-07T10:35:07.745797535+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 69 |
+
{"time":"2025-11-07T10:35:07.746314425+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13118}
|
| 70 |
+
{"time":"2025-11-07T10:35:07.752368686+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":598}
|
| 71 |
+
{"time":"2025-11-07T10:35:12.757217156+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13790}
|
| 72 |
+
{"time":"2025-11-07T10:35:12.757301003+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 73 |
+
{"time":"2025-11-07T10:35:12.758521266+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":13823}
|
| 74 |
+
{"time":"2025-11-07T10:35:12.763861607+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":607}
|
| 75 |
+
{"time":"2025-11-07T10:35:17.774861994+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":14515}
|
| 76 |
+
{"time":"2025-11-07T10:35:17.818026612+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":638}
|
| 77 |
+
{"time":"2025-11-07T10:35:22.783137701+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15352}
|
| 78 |
+
{"time":"2025-11-07T10:35:22.783262767+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 79 |
+
{"time":"2025-11-07T10:35:22.783594236+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":15384}
|
| 80 |
+
{"time":"2025-11-07T10:35:22.78903687+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":466}
|
| 81 |
+
{"time":"2025-11-07T10:35:27.793419415+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16054}
|
| 82 |
+
{"time":"2025-11-07T10:35:27.793474126+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 83 |
+
{"time":"2025-11-07T10:35:27.794054602+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16086}
|
| 84 |
+
{"time":"2025-11-07T10:35:27.798455809+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":461}
|
| 85 |
+
{"time":"2025-11-07T10:35:32.802503923+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":16614}
|
| 86 |
+
{"time":"2025-11-07T10:35:32.890905379+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":632}
|
| 87 |
+
{"time":"2025-11-07T10:35:37.811947009+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17422}
|
| 88 |
+
{"time":"2025-11-07T10:35:37.812001508+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 89 |
+
{"time":"2025-11-07T10:35:37.8129594+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":17455}
|
| 90 |
+
{"time":"2025-11-07T10:35:37.818115269+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":529}
|
| 91 |
+
{"time":"2025-11-07T10:35:42.821455742+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18052}
|
| 92 |
+
{"time":"2025-11-07T10:35:42.821574802+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 93 |
+
{"time":"2025-11-07T10:35:42.822404969+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18085}
|
| 94 |
+
{"time":"2025-11-07T10:35:42.827493199+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":596}
|
| 95 |
+
{"time":"2025-11-07T10:35:47.829869179+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18750}
|
| 96 |
+
{"time":"2025-11-07T10:35:47.8300214+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 97 |
+
{"time":"2025-11-07T10:35:47.830472363+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":18782}
|
| 98 |
+
{"time":"2025-11-07T10:35:47.836490956+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":598}
|
| 99 |
+
{"time":"2025-11-07T10:35:52.838832173+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19449}
|
| 100 |
+
{"time":"2025-11-07T10:35:52.838948252+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 101 |
+
{"time":"2025-11-07T10:35:52.839686209+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":19482}
|
| 102 |
+
{"time":"2025-11-07T10:35:52.845167183+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":636}
|
| 103 |
+
{"time":"2025-11-07T10:35:57.850237976+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20234}
|
| 104 |
+
{"time":"2025-11-07T10:35:57.850307289+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 105 |
+
{"time":"2025-11-07T10:35:57.850722633+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":20266}
|
| 106 |
+
{"time":"2025-11-07T10:35:57.855770193+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":590}
|
| 107 |
+
{"time":"2025-11-07T10:36:02.861578838+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21050}
|
| 108 |
+
{"time":"2025-11-07T10:36:02.861662775+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 109 |
+
{"time":"2025-11-07T10:36:02.862067037+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21082}
|
| 110 |
+
{"time":"2025-11-07T10:36:02.866762453+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":473}
|
| 111 |
+
{"time":"2025-11-07T10:36:07.870746776+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21663}
|
| 112 |
+
{"time":"2025-11-07T10:36:07.870846506+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 113 |
+
{"time":"2025-11-07T10:36:07.871280938+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":21695}
|
| 114 |
+
{"time":"2025-11-07T10:36:07.877814374+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":598}
|
| 115 |
+
{"time":"2025-11-07T10:36:12.882238564+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22400}
|
| 116 |
+
{"time":"2025-11-07T10:36:12.882318668+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 117 |
+
{"time":"2025-11-07T10:36:12.882852217+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":22432}
|
| 118 |
+
{"time":"2025-11-07T10:36:12.888180029+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":558}
|
| 119 |
+
{"time":"2025-11-07T10:36:17.892127298+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23072}
|
| 120 |
+
{"time":"2025-11-07T10:36:17.892204759+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 121 |
+
{"time":"2025-11-07T10:36:17.893317454+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23105}
|
| 122 |
+
{"time":"2025-11-07T10:36:17.898573523+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":584}
|
| 123 |
+
{"time":"2025-11-07T10:36:22.902720548+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":23759}
|
| 124 |
+
{"time":"2025-11-07T10:36:22.908628832+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":668}
|
| 125 |
+
{"time":"2025-11-07T10:36:27.912557424+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":24495}
|
| 126 |
+
{"time":"2025-11-07T10:36:27.918401209+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":629}
|
| 127 |
+
{"time":"2025-11-07T10:36:32.9237659+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":25246}
|
| 128 |
+
{"time":"2025-11-07T10:36:32.923903707+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 129 |
+
{"time":"2025-11-07T10:36:32.924341981+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":25278}
|
| 130 |
+
{"time":"2025-11-07T10:36:32.927950632+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":545}
|
| 131 |
+
{"time":"2025-11-07T10:36:37.931818699+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":25899}
|
| 132 |
+
{"time":"2025-11-07T10:36:37.931931329+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 133 |
+
{"time":"2025-11-07T10:36:37.932441952+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":25931}
|
| 134 |
+
{"time":"2025-11-07T10:36:37.937479402+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":589}
|
| 135 |
+
{"time":"2025-11-07T10:36:42.941415016+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":26629}
|
| 136 |
+
{"time":"2025-11-07T10:36:42.941540111+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 137 |
+
{"time":"2025-11-07T10:36:42.94202926+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":26661}
|
| 138 |
+
{"time":"2025-11-07T10:36:42.945415017+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":570}
|
| 139 |
+
{"time":"2025-11-07T10:36:47.952442993+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":27309}
|
| 140 |
+
{"time":"2025-11-07T10:36:47.952576601+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 141 |
+
{"time":"2025-11-07T10:36:47.953668183+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":27342}
|
| 142 |
+
{"time":"2025-11-07T10:36:47.959317083+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":615}
|
| 143 |
+
{"time":"2025-11-07T10:36:52.962886709+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":28055}
|
| 144 |
+
{"time":"2025-11-07T10:36:52.962990505+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 145 |
+
{"time":"2025-11-07T10:36:52.963498877+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":28087}
|
| 146 |
+
{"time":"2025-11-07T10:36:52.969988279+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":567}
|
| 147 |
+
{"time":"2025-11-07T10:36:57.973769293+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":28793}
|
| 148 |
+
{"time":"2025-11-07T10:36:57.973877683+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 149 |
+
{"time":"2025-11-07T10:36:57.974266339+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":28825}
|
| 150 |
+
{"time":"2025-11-07T10:36:57.979357622+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":526}
|
| 151 |
+
{"time":"2025-11-07T10:37:02.983984785+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":29699}
|
| 152 |
+
{"time":"2025-11-07T10:37:02.984085119+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 153 |
+
{"time":"2025-11-07T10:37:02.984738027+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":29732}
|
| 154 |
+
{"time":"2025-11-07T10:37:02.988536482+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":359}
|
| 155 |
+
{"time":"2025-11-07T10:37:07.992552162+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":30158}
|
| 156 |
+
{"time":"2025-11-07T10:37:07.992641364+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 157 |
+
{"time":"2025-11-07T10:37:07.993144794+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":30190}
|
| 158 |
+
{"time":"2025-11-07T10:37:07.999768666+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":598}
|
| 159 |
+
{"time":"2025-11-07T10:37:13.003169537+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":30855}
|
| 160 |
+
{"time":"2025-11-07T10:37:13.003306029+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 161 |
+
{"time":"2025-11-07T10:37:13.020595078+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":30887}
|
| 162 |
+
{"time":"2025-11-07T10:37:13.026684616+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":598}
|
| 163 |
+
{"time":"2025-11-07T10:37:18.031472188+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":31625}
|
| 164 |
+
{"time":"2025-11-07T10:37:18.031549787+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 165 |
+
{"time":"2025-11-07T10:37:18.032131463+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":31657}
|
| 166 |
+
{"time":"2025-11-07T10:37:18.037060268+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":541}
|
| 167 |
+
{"time":"2025-11-07T10:37:23.047236833+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":32283}
|
| 168 |
+
{"time":"2025-11-07T10:37:23.04739144+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 169 |
+
{"time":"2025-11-07T10:37:23.047851158+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":32315}
|
| 170 |
+
{"time":"2025-11-07T10:37:23.053879662+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":607}
|
| 171 |
+
{"time":"2025-11-07T10:37:28.05709474+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":32990}
|
| 172 |
+
{"time":"2025-11-07T10:37:28.057182567+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 173 |
+
{"time":"2025-11-07T10:37:28.057616661+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":33022}
|
| 174 |
+
{"time":"2025-11-07T10:37:28.063515514+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":597}
|
| 175 |
+
{"time":"2025-11-07T10:37:33.067449513+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":33767}
|
| 176 |
+
{"time":"2025-11-07T10:37:33.067554161+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 177 |
+
{"time":"2025-11-07T10:37:33.067988265+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":33799}
|
| 178 |
+
{"time":"2025-11-07T10:37:33.073352637+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":519}
|
| 179 |
+
{"time":"2025-11-07T10:37:38.079532496+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":34571}
|
| 180 |
+
{"time":"2025-11-07T10:37:38.079665041+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 181 |
+
{"time":"2025-11-07T10:37:38.080211537+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":34603}
|
| 182 |
+
{"time":"2025-11-07T10:37:38.084573199+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":444}
|
| 183 |
+
{"time":"2025-11-07T10:37:43.091705653+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":35169}
|
| 184 |
+
{"time":"2025-11-07T10:37:43.091894152+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 185 |
+
{"time":"2025-11-07T10:37:43.092335781+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":35201}
|
| 186 |
+
{"time":"2025-11-07T10:37:43.098259744+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":552}
|
| 187 |
+
{"time":"2025-11-07T10:37:48.102251363+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":35823}
|
| 188 |
+
{"time":"2025-11-07T10:37:48.102370693+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 189 |
+
{"time":"2025-11-07T10:37:48.102926689+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":35855}
|
| 190 |
+
{"time":"2025-11-07T10:37:48.1081816+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":597}
|
| 191 |
+
{"time":"2025-11-07T10:37:53.115144307+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":36789}
|
| 192 |
+
{"time":"2025-11-07T10:37:53.115224588+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 193 |
+
{"time":"2025-11-07T10:37:53.115621649+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":36821}
|
| 194 |
+
{"time":"2025-11-07T10:37:53.118244946+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":328}
|
| 195 |
+
{"time":"2025-11-07T10:37:58.123271446+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":37217}
|
| 196 |
+
{"time":"2025-11-07T10:37:58.123403735+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 197 |
+
{"time":"2025-11-07T10:37:58.123799568+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":37249}
|
| 198 |
+
{"time":"2025-11-07T10:37:58.129687573+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":597}
|
| 199 |
+
{"time":"2025-11-07T10:38:03.136981758+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":38275}
|
| 200 |
+
{"time":"2025-11-07T10:38:03.139718906+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":270}
|
| 201 |
+
{"time":"2025-11-07T10:38:08.147352578+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":38933}
|
| 202 |
+
{"time":"2025-11-07T10:38:08.147441059+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 203 |
+
{"time":"2025-11-07T10:38:08.147893762+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":38965}
|
| 204 |
+
{"time":"2025-11-07T10:38:08.150157021+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":277}
|
| 205 |
+
{"time":"2025-11-07T10:38:13.154973622+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":39310}
|
| 206 |
+
{"time":"2025-11-07T10:38:13.155110147+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 207 |
+
{"time":"2025-11-07T10:38:13.155522998+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":39342}
|
| 208 |
+
{"time":"2025-11-07T10:38:13.161765885+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":597}
|
| 209 |
+
{"time":"2025-11-07T10:38:13.785119903+08:00","level":"INFO","msg":"stream: closing","id":"e2e7wd2b"}
|
| 210 |
+
{"time":"2025-11-07T10:38:13.788036429+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":39983}
|
| 211 |
+
{"time":"2025-11-07T10:38:13.789237148+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":79}
|
| 212 |
+
{"time":"2025-11-07T10:38:15.846666009+08:00","level":"INFO","msg":"fileTransfer: Close: file transfer manager closed"}
|
| 213 |
+
{"time":"2025-11-07T10:38:16.491451351+08:00","level":"INFO","msg":"handler: closed","stream_id":"e2e7wd2b"}
|
| 214 |
+
{"time":"2025-11-07T10:38:16.493970964+08:00","level":"INFO","msg":"sender: closed","stream_id":"e2e7wd2b"}
|
| 215 |
+
{"time":"2025-11-07T10:38:16.494069974+08:00","level":"INFO","msg":"stream: closed","id":"e2e7wd2b"}
|
cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug.log
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-11-07 10:33:31,391 INFO MainThread:132354 [wandb_setup.py:_flush():81] Current SDK version is 0.22.3
|
| 2 |
+
2025-11-07 10:33:31,391 INFO MainThread:132354 [wandb_setup.py:_flush():81] Configure stats pid to 132354
|
| 3 |
+
2025-11-07 10:33:31,392 INFO MainThread:132354 [wandb_setup.py:_flush():81] Loading settings from /root/.config/wandb/settings
|
| 4 |
+
2025-11-07 10:33:31,392 INFO MainThread:132354 [wandb_setup.py:_flush():81] Loading settings from /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/settings
|
| 5 |
+
2025-11-07 10:33:31,392 INFO MainThread:132354 [wandb_setup.py:_flush():81] Loading settings from environment variables
|
| 6 |
+
2025-11-07 10:33:31,392 INFO MainThread:132354 [wandb_init.py:setup_run_log_directory():706] Logging user logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug.log
|
| 7 |
+
2025-11-07 10:33:31,393 INFO MainThread:132354 [wandb_init.py:setup_run_log_directory():707] Logging internal logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_103331-e2e7wd2b/logs/debug-internal.log
|
| 8 |
+
2025-11-07 10:33:31,394 INFO MainThread:132354 [wandb_init.py:init():833] calling init triggers
|
| 9 |
+
2025-11-07 10:33:31,394 INFO MainThread:132354 [wandb_init.py:init():838] wandb.init called with sweep_config: {}
|
| 10 |
+
config: {'exp_name': 'ppo_frozenlake', 'seed': 1, 'torch_deterministic': True, 'cuda': True, 'track': True, 'wandb_project_name': 'ragen-bandit', 'wandb_entity': None, 'capture_video': False, 'env_id': 'FrozenLake', 'total_timesteps': 1000000, 'learning_rate': 0.00025, 'num_envs': 8, 'num_steps': 128, 'anneal_lr': True, 'gamma': 0.99, 'gae_lambda': 0.95, 'num_minibatches': 4, 'update_epochs': 4, 'norm_adv': True, 'clip_coef': 0.2, 'clip_vloss': True, 'ent_coef': 0.01, 'vf_coef': 0.5, 'max_grad_norm': 0.5, 'target_kl': None, 'grid_size': 4, 'is_slippery': True, 'batch_size': 1024, 'minibatch_size': 256, 'num_iterations': 976, '_wandb': {'code_path': 'code/cleanrl/ppo_frozenlake.py'}}
|
| 11 |
+
2025-11-07 10:33:31,394 INFO MainThread:132354 [wandb_init.py:init():881] starting backend
|
| 12 |
+
2025-11-07 10:33:31,600 INFO MainThread:132354 [wandb_init.py:init():884] sending inform_init request
|
| 13 |
+
2025-11-07 10:33:31,611 INFO MainThread:132354 [wandb_init.py:init():892] backend started and connected
|
| 14 |
+
2025-11-07 10:33:31,612 INFO MainThread:132354 [wandb_init.py:init():962] updated telemetry
|
| 15 |
+
2025-11-07 10:33:31,657 INFO MainThread:132354 [wandb_init.py:init():986] communicating run to backend with 90.0 second timeout
|
| 16 |
+
2025-11-07 10:33:32,396 INFO MainThread:132354 [wandb_init.py:init():1033] starting run threads in backend
|
| 17 |
+
2025-11-07 10:33:32,541 INFO MainThread:132354 [wandb_run.py:_console_start():2506] atexit reg
|
| 18 |
+
2025-11-07 10:33:32,541 INFO MainThread:132354 [wandb_run.py:_redirect():2354] redirect: wrap_raw
|
| 19 |
+
2025-11-07 10:33:32,541 INFO MainThread:132354 [wandb_run.py:_redirect():2423] Wrapping output streams.
|
| 20 |
+
2025-11-07 10:33:32,542 INFO MainThread:132354 [wandb_run.py:_redirect():2446] Redirects installed.
|
| 21 |
+
2025-11-07 10:33:32,544 INFO MainThread:132354 [wandb_init.py:init():1073] run started, returning control to user process
|
| 22 |
+
2025-11-07 10:33:32,544 INFO MainThread:132354 [wandb_run.py:_tensorboard_callback():1598] tensorboard callback: runs/FrozenLake__ppo_frozenlake__1__1762482804, True
|
| 23 |
+
2025-11-07 10:38:13,785 INFO wandb-AsyncioManager-main:132354 [service_client.py:_forward_responses():80] Reached EOF.
|
| 24 |
+
2025-11-07 10:38:13,785 INFO wandb-AsyncioManager-main:132354 [mailbox.py:close():137] Closing mailbox, abandoning 1 handles.
|
cleanrl/cleanrl/wandb/run-20251107_112647-9utis4xx/files/wandb-summary.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"_runtime":10,"_wandb":{"runtime":10}}
|
cleanrl/cleanrl/wandb/run-20251107_112647-9utis4xx/logs/debug-internal.log
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"time":"2025-11-07T11:26:47.408857285+08:00","level":"INFO","msg":"stream: starting","core version":"0.22.3"}
|
| 2 |
+
{"time":"2025-11-07T11:26:47.785862786+08:00","level":"INFO","msg":"stream: created new stream","id":"9utis4xx"}
|
| 3 |
+
{"time":"2025-11-07T11:26:47.7861195+08:00","level":"INFO","msg":"handler: started","stream_id":"9utis4xx"}
|
| 4 |
+
{"time":"2025-11-07T11:26:47.789374485+08:00","level":"INFO","msg":"stream: started","id":"9utis4xx"}
|
| 5 |
+
{"time":"2025-11-07T11:26:47.789386794+08:00","level":"INFO","msg":"writer: started","stream_id":"9utis4xx"}
|
| 6 |
+
{"time":"2025-11-07T11:26:47.789396256+08:00","level":"INFO","msg":"sender: started","stream_id":"9utis4xx"}
|
| 7 |
+
{"time":"2025-11-07T11:26:48.283337823+08:00","level":"ERROR","msg":"git repo not found","error":"repository does not exist"}
|
| 8 |
+
{"time":"2025-11-07T11:26:48.527340569+08:00","level":"INFO","msg":"stream: closing","id":"9utis4xx"}
|
| 9 |
+
{"time":"2025-11-07T11:26:58.418279955+08:00","level":"WARN","msg":"tensorboard: no root directory","error":"timed out after 10s"}
|
| 10 |
+
{"time":"2025-11-07T11:26:58.421915183+08:00","level":"INFO","msg":"tensorboard: tracking new log directory","rootDir":{},"logDir":"LocalOrCloudPath(LocalPath=\"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Sokoban__ppo_sokoban__1__1762486000\")","namespace":""}
|
| 11 |
+
{"time":"2025-11-07T11:26:58.425154477+08:00","level":"INFO","msg":"tensorboard: saving file","fileLocation":"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/Sokoban__ppo_sokoban__1__1762486000/events.out.tfevents.1762486008.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.212707.0","runPath":"runs/Sokoban__ppo_sokoban__1__1762486000/events.out.tfevents.1762486008.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.212707.0"}
|
| 12 |
+
{"time":"2025-11-07T11:26:59.120221237+08:00","level":"INFO","msg":"fileTransfer: Close: file transfer manager closed"}
|
| 13 |
+
{"time":"2025-11-07T11:26:59.418043752+08:00","level":"INFO","msg":"handler: closed","stream_id":"9utis4xx"}
|
| 14 |
+
{"time":"2025-11-07T11:26:59.420537182+08:00","level":"INFO","msg":"sender: closed","stream_id":"9utis4xx"}
|
| 15 |
+
{"time":"2025-11-07T11:26:59.420626397+08:00","level":"INFO","msg":"stream: closed","id":"9utis4xx"}
|
cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/files/output.log
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[ 0.2%] Iter 1/610 | SPS: 2969 | Reward: 0.031 | Value: 0.452 | VLoss: 0.0581 | PLoss: -0.0004 | Ent: 1.3845
|
| 2 |
+
[ 0.3%] Iter 2/610 | SPS: 3156 | Reward: 0.031 | Value: 0.424 | VLoss: 0.0470 | PLoss: -0.0009 | Ent: 1.3818
|
| 3 |
+
[ 0.5%] Iter 3/610 | SPS: 2981 | Reward: 0.030 | Value: 0.410 | VLoss: 0.0447 | PLoss: -0.0015 | Ent: 1.3800
|
| 4 |
+
[ 0.7%] Iter 4/610 | SPS: 3308 | Reward: 0.031 | Value: 0.349 | VLoss: 0.0472 | PLoss: -0.0018 | Ent: 1.3813
|
| 5 |
+
[ 0.8%] Iter 5/610 | SPS: 3194 | Reward: 0.028 | Value: 0.353 | VLoss: 0.0429 | PLoss: -0.0001 | Ent: 1.3836
|
| 6 |
+
[ 1.0%] Iter 6/610 | SPS: 3252 | Reward: 0.028 | Value: 0.351 | VLoss: 0.0437 | PLoss: -0.0008 | Ent: 1.3848
|
| 7 |
+
[ 1.1%] Iter 7/610 | SPS: 3521 | Reward: 0.030 | Value: 0.344 | VLoss: 0.0445 | PLoss: -0.0005 | Ent: 1.3844
|
| 8 |
+
[ 1.3%] Iter 8/610 | SPS: 3629 | Reward: 0.032 | Value: 0.349 | VLoss: 0.0453 | PLoss: -0.0011 | Ent: 1.3828
|
| 9 |
+
[ 1.5%] Iter 9/610 | SPS: 3651 | Reward: 0.031 | Value: 0.357 | VLoss: 0.0457 | PLoss: -0.0006 | Ent: 1.3818
|
| 10 |
+
[ 1.6%] Iter 10/610 | SPS: 3663 | Reward: 0.029 | Value: 0.364 | VLoss: 0.0438 | PLoss: -0.0015 | Ent: 1.3807
|
| 11 |
+
[ 1.8%] Iter 11/610 | SPS: 3661 | Reward: 0.030 | Value: 0.378 | VLoss: 0.0445 | PLoss: -0.0010 | Ent: 1.3734
|
| 12 |
+
[ 2.0%] Iter 12/610 | SPS: 3624 | Reward: 0.034 | Value: 0.362 | VLoss: 0.0486 | PLoss: -0.0032 | Ent: 1.3547
|
| 13 |
+
[ 2.1%] Iter 13/610 | SPS: 3578 | Reward: 0.030 | Value: 0.379 | VLoss: 0.0438 | PLoss: -0.0027 | Ent: 1.3387
|
| 14 |
+
[ 2.3%] Iter 14/610 | SPS: 3558 | Reward: 0.034 | Value: 0.365 | VLoss: 0.0473 | PLoss: -0.0017 | Ent: 1.3347
|
| 15 |
+
[ 2.5%] Iter 15/610 | SPS: 3539 | Reward: 0.032 | Value: 0.371 | VLoss: 0.0470 | PLoss: -0.0028 | Ent: 1.3035
|
| 16 |
+
[ 2.6%] Iter 16/610 | SPS: 3523 | Reward: 0.029 | Value: 0.382 | VLoss: 0.0428 | PLoss: -0.0027 | Ent: 1.3432
|
| 17 |
+
[ 2.8%] Iter 17/610 | SPS: 3517 | Reward: 0.033 | Value: 0.390 | VLoss: 0.0447 | PLoss: -0.0025 | Ent: 1.3308
|
| 18 |
+
[ 3.0%] Iter 18/610 | SPS: 3453 | Reward: 0.034 | Value: 0.406 | VLoss: 0.0444 | PLoss: -0.0035 | Ent: 1.3329
|
| 19 |
+
[ 3.1%] Iter 19/610 | SPS: 3294 | Reward: 0.034 | Value: 0.399 | VLoss: 0.0465 | PLoss: -0.0021 | Ent: 1.3239
|
| 20 |
+
[ 3.3%] Iter 20/610 | SPS: 3162 | Reward: 0.035 | Value: 0.408 | VLoss: 0.0480 | PLoss: -0.0035 | Ent: 1.3201
|
| 21 |
+
[ 3.4%] Iter 21/610 | SPS: 3052 | Reward: 0.038 | Value: 0.420 | VLoss: 0.0490 | PLoss: -0.0057 | Ent: 1.2753
|
| 22 |
+
[ 3.6%] Iter 22/610 | SPS: 2958 | Reward: 0.038 | Value: 0.434 | VLoss: 0.0480 | PLoss: -0.0042 | Ent: 1.2446
|
| 23 |
+
[ 3.8%] Iter 23/610 | SPS: 2878 | Reward: 0.035 | Value: 0.425 | VLoss: 0.0458 | PLoss: -0.0034 | Ent: 1.2134
|
| 24 |
+
[ 3.9%] Iter 24/610 | SPS: 2808 | Reward: 0.037 | Value: 0.395 | VLoss: 0.0472 | PLoss: -0.0044 | Ent: 1.2284
|
| 25 |
+
[ 4.1%] Iter 25/610 | SPS: 2746 | Reward: 0.039 | Value: 0.407 | VLoss: 0.0502 | PLoss: -0.0053 | Ent: 1.1897
|
| 26 |
+
[ 4.3%] Iter 26/610 | SPS: 2691 | Reward: 0.042 | Value: 0.421 | VLoss: 0.0497 | PLoss: -0.0044 | Ent: 1.1790
|
| 27 |
+
[ 4.4%] Iter 27/610 | SPS: 2643 | Reward: 0.041 | Value: 0.445 | VLoss: 0.0483 | PLoss: -0.0035 | Ent: 1.1575
|
| 28 |
+
[ 4.6%] Iter 28/610 | SPS: 2599 | Reward: 0.042 | Value: 0.470 | VLoss: 0.0495 | PLoss: -0.0047 | Ent: 1.1303
|
| 29 |
+
[ 4.8%] Iter 29/610 | SPS: 2559 | Reward: 0.046 | Value: 0.480 | VLoss: 0.0517 | PLoss: -0.0017 | Ent: 1.1191
|
| 30 |
+
[ 4.9%] Iter 30/610 | SPS: 2523 | Reward: 0.047 | Value: 0.483 | VLoss: 0.0508 | PLoss: -0.0043 | Ent: 1.0895
|
| 31 |
+
[ 5.1%] Iter 31/610 | SPS: 2491 | Reward: 0.045 | Value: 0.508 | VLoss: 0.0488 | PLoss: -0.0063 | Ent: 1.0355
|
| 32 |
+
[ 5.2%] Iter 32/610 | SPS: 2461 | Reward: 0.044 | Value: 0.506 | VLoss: 0.0480 | PLoss: -0.0043 | Ent: 1.0273
|
| 33 |
+
[ 5.4%] Iter 33/610 | SPS: 2434 | Reward: 0.045 | Value: 0.492 | VLoss: 0.0480 | PLoss: -0.0031 | Ent: 0.9835
|
| 34 |
+
[ 5.6%] Iter 34/610 | SPS: 2408 | Reward: 0.046 | Value: 0.497 | VLoss: 0.0476 | PLoss: -0.0048 | Ent: 0.9524
|
| 35 |
+
[ 5.7%] Iter 35/610 | SPS: 2436 | Reward: 0.047 | Value: 0.522 | VLoss: 0.0478 | PLoss: -0.0026 | Ent: 0.9470
|
| 36 |
+
[ 5.9%] Iter 36/610 | SPS: 2478 | Reward: 0.048 | Value: 0.535 | VLoss: 0.0462 | PLoss: -0.0040 | Ent: 0.9404
|
| 37 |
+
[ 6.1%] Iter 37/610 | SPS: 2503 | Reward: 0.049 | Value: 0.537 | VLoss: 0.0482 | PLoss: -0.0034 | Ent: 0.9172
|
| 38 |
+
[ 6.2%] Iter 38/610 | SPS: 2526 | Reward: 0.051 | Value: 0.544 | VLoss: 0.0482 | PLoss: -0.0034 | Ent: 0.8812
|
| 39 |
+
[ 6.4%] Iter 39/610 | SPS: 2546 | Reward: 0.050 | Value: 0.532 | VLoss: 0.0478 | PLoss: -0.0020 | Ent: 0.8758
|
| 40 |
+
[ 6.6%] Iter 40/610 | SPS: 2556 | Reward: 0.049 | Value: 0.530 | VLoss: 0.0486 | PLoss: -0.0034 | Ent: 0.8411
|
| 41 |
+
[ 6.7%] Iter 41/610 | SPS: 2569 | Reward: 0.052 | Value: 0.545 | VLoss: 0.0445 | PLoss: -0.0033 | Ent: 0.8379
|
| 42 |
+
[ 6.9%] Iter 42/610 | SPS: 2582 | Reward: 0.049 | Value: 0.554 | VLoss: 0.0451 | PLoss: -0.0040 | Ent: 0.8258
|
| 43 |
+
[ 7.0%] Iter 43/610 | SPS: 2616 | Reward: 0.052 | Value: 0.546 | VLoss: 0.0453 | PLoss: -0.0043 | Ent: 0.8102
|
| 44 |
+
[ 7.2%] Iter 44/610 | SPS: 2643 | Reward: 0.050 | Value: 0.569 | VLoss: 0.0418 | PLoss: -0.0023 | Ent: 0.7770
|
| 45 |
+
[ 7.4%] Iter 45/610 | SPS: 2650 | Reward: 0.050 | Value: 0.564 | VLoss: 0.0413 | PLoss: -0.0034 | Ent: 0.7727
|
| 46 |
+
[ 7.5%] Iter 46/610 | SPS: 2659 | Reward: 0.048 | Value: 0.578 | VLoss: 0.0426 | PLoss: -0.0023 | Ent: 0.7614
|
| 47 |
+
[ 7.7%] Iter 47/610 | SPS: 2686 | Reward: 0.051 | Value: 0.591 | VLoss: 0.0421 | PLoss: -0.0034 | Ent: 0.7443
|
| 48 |
+
[ 7.9%] Iter 48/610 | SPS: 2703 | Reward: 0.052 | Value: 0.554 | VLoss: 0.0450 | PLoss: -0.0031 | Ent: 0.7543
|
| 49 |
+
[ 8.0%] Iter 49/610 | SPS: 2718 | Reward: 0.052 | Value: 0.576 | VLoss: 0.0424 | PLoss: -0.0034 | Ent: 0.7374
|
| 50 |
+
[ 8.2%] Iter 50/610 | SPS: 2723 | Reward: 0.052 | Value: 0.597 | VLoss: 0.0399 | PLoss: -0.0024 | Ent: 0.7337
|
| 51 |
+
[ 8.4%] Iter 51/610 | SPS: 2730 | Reward: 0.055 | Value: 0.573 | VLoss: 0.0441 | PLoss: -0.0028 | Ent: 0.7120
|
| 52 |
+
[ 8.5%] Iter 52/610 | SPS: 2733 | Reward: 0.054 | Value: 0.558 | VLoss: 0.0432 | PLoss: -0.0037 | Ent: 0.7162
|
| 53 |
+
[ 8.7%] Iter 53/610 | SPS: 2706 | Reward: 0.054 | Value: 0.591 | VLoss: 0.0423 | PLoss: -0.0035 | Ent: 0.6823
|
| 54 |
+
[ 8.9%] Iter 54/610 | SPS: 2681 | Reward: 0.056 | Value: 0.590 | VLoss: 0.0436 | PLoss: -0.0049 | Ent: 0.6676
|
| 55 |
+
[ 9.0%] Iter 55/610 | SPS: 2657 | Reward: 0.053 | Value: 0.592 | VLoss: 0.0405 | PLoss: -0.0015 | Ent: 0.6676
|
| 56 |
+
[ 9.2%] Iter 56/610 | SPS: 2634 | Reward: 0.058 | Value: 0.616 | VLoss: 0.0433 | PLoss: -0.0033 | Ent: 0.6467
|
| 57 |
+
[ 9.3%] Iter 57/610 | SPS: 2612 | Reward: 0.058 | Value: 0.618 | VLoss: 0.0427 | PLoss: -0.0034 | Ent: 0.6535
|
| 58 |
+
[ 9.5%] Iter 58/610 | SPS: 2592 | Reward: 0.053 | Value: 0.602 | VLoss: 0.0422 | PLoss: -0.0024 | Ent: 0.6411
|
| 59 |
+
[ 9.7%] Iter 59/610 | SPS: 2572 | Reward: 0.054 | Value: 0.606 | VLoss: 0.0388 | PLoss: -0.0043 | Ent: 0.6400
|
| 60 |
+
[ 9.8%] Iter 60/610 | SPS: 2554 | Reward: 0.055 | Value: 0.597 | VLoss: 0.0413 | PLoss: -0.0016 | Ent: 0.6419
|
| 61 |
+
[ 10.0%] Iter 61/610 | SPS: 2536 | Reward: 0.057 | Value: 0.593 | VLoss: 0.0431 | PLoss: -0.0035 | Ent: 0.6297
|
| 62 |
+
[ 10.2%] Iter 62/610 | SPS: 2519 | Reward: 0.054 | Value: 0.607 | VLoss: 0.0406 | PLoss: -0.0026 | Ent: 0.6072
|
| 63 |
+
[ 10.3%] Iter 63/610 | SPS: 2503 | Reward: 0.052 | Value: 0.590 | VLoss: 0.0384 | PLoss: -0.0037 | Ent: 0.5959
|
| 64 |
+
[ 10.5%] Iter 64/610 | SPS: 2487 | Reward: 0.061 | Value: 0.601 | VLoss: 0.0418 | PLoss: -0.0025 | Ent: 0.5980
|
| 65 |
+
[ 10.7%] Iter 65/610 | SPS: 2473 | Reward: 0.058 | Value: 0.614 | VLoss: 0.0404 | PLoss: -0.0036 | Ent: 0.5794
|
| 66 |
+
[ 10.8%] Iter 66/610 | SPS: 2458 | Reward: 0.061 | Value: 0.617 | VLoss: 0.0419 | PLoss: -0.0032 | Ent: 0.5619
|
| 67 |
+
[ 11.0%] Iter 67/610 | SPS: 2445 | Reward: 0.055 | Value: 0.603 | VLoss: 0.0391 | PLoss: -0.0017 | Ent: 0.5527
|
| 68 |
+
[ 11.1%] Iter 68/610 | SPS: 2432 | Reward: 0.058 | Value: 0.627 | VLoss: 0.0399 | PLoss: -0.0033 | Ent: 0.5474
|
| 69 |
+
[ 11.3%] Iter 69/610 | SPS: 2419 | Reward: 0.055 | Value: 0.617 | VLoss: 0.0385 | PLoss: -0.0048 | Ent: 0.5250
|
| 70 |
+
[ 11.5%] Iter 70/610 | SPS: 2407 | Reward: 0.058 | Value: 0.631 | VLoss: 0.0398 | PLoss: -0.0037 | Ent: 0.5213
|
| 71 |
+
[ 11.6%] Iter 71/610 | SPS: 2408 | Reward: 0.057 | Value: 0.634 | VLoss: 0.0379 | PLoss: -0.0040 | Ent: 0.5129
|
| 72 |
+
[ 11.8%] Iter 72/610 | SPS: 2426 | Reward: 0.055 | Value: 0.636 | VLoss: 0.0387 | PLoss: -0.0041 | Ent: 0.5090
|
| 73 |
+
[ 12.0%] Iter 73/610 | SPS: 2431 | Reward: 0.058 | Value: 0.605 | VLoss: 0.0431 | PLoss: -0.0028 | Ent: 0.5213
|
| 74 |
+
[ 12.1%] Iter 74/610 | SPS: 2442 | Reward: 0.055 | Value: 0.611 | VLoss: 0.0370 | PLoss: -0.0028 | Ent: 0.4909
|
| 75 |
+
[ 12.3%] Iter 75/610 | SPS: 2458 | Reward: 0.053 | Value: 0.621 | VLoss: 0.0426 | PLoss: -0.0041 | Ent: 0.4855
|
| 76 |
+
[ 12.5%] Iter 76/610 | SPS: 2470 | Reward: 0.056 | Value: 0.611 | VLoss: 0.0374 | PLoss: -0.0038 | Ent: 0.4799
|
| 77 |
+
[ 12.6%] Iter 77/610 | SPS: 2477 | Reward: 0.056 | Value: 0.623 | VLoss: 0.0359 | PLoss: -0.0030 | Ent: 0.4851
|
| 78 |
+
[ 12.8%] Iter 78/610 | SPS: 2488 | Reward: 0.060 | Value: 0.660 | VLoss: 0.0398 | PLoss: -0.0036 | Ent: 0.4659
|
| 79 |
+
[ 13.0%] Iter 79/610 | SPS: 2484 | Reward: 0.054 | Value: 0.655 | VLoss: 0.0357 | PLoss: -0.0026 | Ent: 0.4619
|
| 80 |
+
[ 13.1%] Iter 80/610 | SPS: 2472 | Reward: 0.059 | Value: 0.619 | VLoss: 0.0385 | PLoss: -0.0039 | Ent: 0.4868
|
| 81 |
+
[ 13.3%] Iter 81/610 | SPS: 2469 | Reward: 0.061 | Value: 0.624 | VLoss: 0.0397 | PLoss: -0.0026 | Ent: 0.4633
|
| 82 |
+
[ 13.4%] Iter 82/610 | SPS: 2484 | Reward: 0.063 | Value: 0.633 | VLoss: 0.0420 | PLoss: -0.0039 | Ent: 0.4571
|
| 83 |
+
[ 13.6%] Iter 83/610 | SPS: 2487 | Reward: 0.058 | Value: 0.646 | VLoss: 0.0396 | PLoss: -0.0025 | Ent: 0.4559
|
| 84 |
+
[ 13.8%] Iter 84/610 | SPS: 2496 | Reward: 0.061 | Value: 0.645 | VLoss: 0.0388 | PLoss: -0.0040 | Ent: 0.4552
|
| 85 |
+
Traceback (most recent call last):
|
| 86 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ppo_frozenlake.py", line 224, in <module>
|
| 87 |
+
next_obs, reward, terminations, truncations, infos = envs.step(action.cpu().numpy())
|
| 88 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 89 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/gymnasium/vector/sync_vector_env.py", line 265, in step
|
| 90 |
+
) = self.envs[i].step(action)
|
| 91 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 92 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/gymnasium/wrappers/common.py", line 513, in step
|
| 93 |
+
obs, reward, terminated, truncated, info = super().step(action)
|
| 94 |
+
^^^^^^^^^^^^^^^^^^^^
|
| 95 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/gymnasium/core.py", line 327, in step
|
| 96 |
+
return self.env.step(action)
|
| 97 |
+
^^^^^^^^^^^^^^^^^^^^^
|
| 98 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/ragen_wrappers.py", line 140, in step
|
| 99 |
+
text_obs, reward, done, info = self.env.step(ragen_action)
|
| 100 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 101 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/../../ragen/env/frozen_lake/env.py", line 42, in step
|
| 102 |
+
next_obs = self.render()
|
| 103 |
+
^^^^^^^^^^^^^
|
| 104 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/../../ragen/env/frozen_lake/env.py", line 57, in render
|
| 105 |
+
return '\n'.join(''.join(self.GRID_LOOKUP.get(cell, "?") for cell in row) for row in room)
|
| 106 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 107 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/../../ragen/env/frozen_lake/env.py", line 57, in <genexpr>
|
| 108 |
+
return '\n'.join(''.join(self.GRID_LOOKUP.get(cell, "?") for cell in row) for row in room)
|
| 109 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 110 |
+
File "/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/../../ragen/env/frozen_lake/env.py", line 57, in <genexpr>
|
| 111 |
+
return '\n'.join(''.join(self.GRID_LOOKUP.get(cell, "?") for cell in row) for row in room)
|
| 112 |
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| 113 |
+
KeyboardInterrupt
|
cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/files/wandb-summary.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"charts/avg_reward":0.061462402,"losses/value_loss":0.038800143,"charts/avg_value":0.6450379,"losses/entropy":0.4552039,"charts/min_reward":0,"_runtime":552,"losses/old_approx_kl":0.002151668,"_step":1091,"_wandb":{"runtime":552},"charts/max_reward":1,"charts/SPS":2496,"losses/clipfrac":0.012161255,"global_step":1376256,"losses/approx_kl":0.0012194765,"losses/explained_variance":0.34000987,"_timestamp":1.762486697135544e+09,"charts/learning_rate":0.0002159836,"losses/policy_loss":-0.004004655}
|
cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug-internal.log
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"time":"2025-11-07T11:29:03.809590629+08:00","level":"INFO","msg":"stream: starting","core version":"0.22.3"}
|
| 2 |
+
{"time":"2025-11-07T11:29:04.17891044+08:00","level":"INFO","msg":"stream: created new stream","id":"8xop3upl"}
|
| 3 |
+
{"time":"2025-11-07T11:29:04.179154693+08:00","level":"INFO","msg":"handler: started","stream_id":"8xop3upl"}
|
| 4 |
+
{"time":"2025-11-07T11:29:04.182809549+08:00","level":"INFO","msg":"stream: started","id":"8xop3upl"}
|
| 5 |
+
{"time":"2025-11-07T11:29:04.182826865+08:00","level":"INFO","msg":"writer: started","stream_id":"8xop3upl"}
|
| 6 |
+
{"time":"2025-11-07T11:29:04.182830482+08:00","level":"INFO","msg":"sender: started","stream_id":"8xop3upl"}
|
| 7 |
+
{"time":"2025-11-07T11:29:04.561507055+08:00","level":"ERROR","msg":"git repo not found","error":"repository does not exist"}
|
| 8 |
+
{"time":"2025-11-07T11:29:14.697521027+08:00","level":"WARN","msg":"tensorboard: no root directory","error":"timed out after 10s"}
|
| 9 |
+
{"time":"2025-11-07T11:29:14.699498441+08:00","level":"INFO","msg":"tensorboard: tracking new log directory","rootDir":{},"logDir":"LocalOrCloudPath(LocalPath=\"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/FrozenLake__ppo_frozenlake__1__1762486136\")","namespace":""}
|
| 10 |
+
{"time":"2025-11-07T11:29:14.702330111+08:00","level":"INFO","msg":"tensorboard: saving file","fileLocation":"/mnt/general/wanghy/RAGEN/cleanrl/cleanrl/runs/FrozenLake__ppo_frozenlake__1__1762486136/events.out.tfevents.1762486144.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.213027.0","runPath":"runs/FrozenLake__ppo_frozenlake__1__1762486136/events.out.tfevents.1762486144.pt-4d654cf4576f4d23ad3d3919f12932fe-worker-0.213027.0"}
|
| 11 |
+
{"time":"2025-11-07T11:29:19.714087234+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":88}
|
| 12 |
+
{"time":"2025-11-07T11:29:20.046069837+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 13 |
+
{"time":"2025-11-07T11:29:29.731549556+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":173}
|
| 14 |
+
{"time":"2025-11-07T11:29:29.73170942+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 15 |
+
{"time":"2025-11-07T11:29:34.741827173+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":213}
|
| 16 |
+
{"time":"2025-11-07T11:29:34.940387001+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 17 |
+
{"time":"2025-11-07T11:29:39.749382062+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":263}
|
| 18 |
+
{"time":"2025-11-07T11:29:39.749551017+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 19 |
+
{"time":"2025-11-07T11:29:39.749993195+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":295}
|
| 20 |
+
{"time":"2025-11-07T11:29:39.751604253+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 21 |
+
{"time":"2025-11-07T11:29:44.759731315+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":337}
|
| 22 |
+
{"time":"2025-11-07T11:29:44.759864472+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 23 |
+
{"time":"2025-11-07T11:29:49.770216089+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":379}
|
| 24 |
+
{"time":"2025-11-07T11:29:49.964405356+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 25 |
+
{"time":"2025-11-07T11:30:04.802231794+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":504}
|
| 26 |
+
{"time":"2025-11-07T11:30:04.964986531+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 27 |
+
{"time":"2025-11-07T11:30:19.832686975+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":629}
|
| 28 |
+
{"time":"2025-11-07T11:30:19.969389812+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 29 |
+
{"time":"2025-11-07T11:30:34.863632824+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":754}
|
| 30 |
+
{"time":"2025-11-07T11:30:34.99163122+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 31 |
+
{"time":"2025-11-07T11:30:44.880442978+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":796}
|
| 32 |
+
{"time":"2025-11-07T11:30:44.880515345+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 33 |
+
{"time":"2025-11-07T11:30:49.886783384+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":838}
|
| 34 |
+
{"time":"2025-11-07T11:30:50.053853179+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 35 |
+
{"time":"2025-11-07T11:31:19.93192999+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":965}
|
| 36 |
+
{"time":"2025-11-07T11:31:19.95978197+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 37 |
+
{"time":"2025-11-07T11:32:05.003752828+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1176}
|
| 38 |
+
{"time":"2025-11-07T11:32:05.011888005+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":6}
|
| 39 |
+
{"time":"2025-11-07T11:32:15.019977901+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1222}
|
| 40 |
+
{"time":"2025-11-07T11:32:15.02008222+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 41 |
+
{"time":"2025-11-07T11:33:40.173090751+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":1846}
|
| 42 |
+
{"time":"2025-11-07T11:33:40.173188566+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 43 |
+
{"time":"2025-11-07T11:34:20.257965996+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2181}
|
| 44 |
+
{"time":"2025-11-07T11:34:20.258025713+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 45 |
+
{"time":"2025-11-07T11:35:25.366060068+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2474}
|
| 46 |
+
{"time":"2025-11-07T11:35:25.366167371+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 47 |
+
{"time":"2025-11-07T11:36:30.460497096+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2769}
|
| 48 |
+
{"time":"2025-11-07T11:36:30.460618588+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 49 |
+
{"time":"2025-11-07T11:36:45.480377706+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":2853}
|
| 50 |
+
{"time":"2025-11-07T11:36:45.480526292+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 51 |
+
{"time":"2025-11-07T11:37:20.534469663+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3066}
|
| 52 |
+
{"time":"2025-11-07T11:37:20.53457352+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 53 |
+
{"time":"2025-11-07T11:37:30.54888915+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3148}
|
| 54 |
+
{"time":"2025-11-07T11:37:30.54905724+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":1}
|
| 55 |
+
{"time":"2025-11-07T11:37:30.550096767+08:00","level":"INFO","msg":"flowcontrol: backed up, offloading to disk","recordNumber":3181}
|
| 56 |
+
{"time":"2025-11-07T11:37:30.551104053+08:00","level":"INFO","msg":"flowcontrol: unblocked","totalOffloaded":11}
|
| 57 |
+
{"time":"2025-11-07T11:38:17.365980222+08:00","level":"INFO","msg":"stream: closing","id":"8xop3upl"}
|
| 58 |
+
{"time":"2025-11-07T11:38:18.37714031+08:00","level":"INFO","msg":"fileTransfer: Close: file transfer manager closed"}
|
| 59 |
+
{"time":"2025-11-07T11:38:18.683948729+08:00","level":"INFO","msg":"handler: closed","stream_id":"8xop3upl"}
|
| 60 |
+
{"time":"2025-11-07T11:38:18.686201474+08:00","level":"INFO","msg":"sender: closed","stream_id":"8xop3upl"}
|
| 61 |
+
{"time":"2025-11-07T11:38:18.68630277+08:00","level":"INFO","msg":"stream: closed","id":"8xop3upl"}
|
cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug.log
ADDED
|
@@ -0,0 +1,362 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
2025-11-07 11:29:03,586 INFO MainThread:213027 [wandb_setup.py:_flush():81] Current SDK version is 0.22.3
|
| 2 |
+
2025-11-07 11:29:03,586 INFO MainThread:213027 [wandb_setup.py:_flush():81] Configure stats pid to 213027
|
| 3 |
+
2025-11-07 11:29:03,586 INFO MainThread:213027 [wandb_setup.py:_flush():81] Loading settings from /root/.config/wandb/settings
|
| 4 |
+
2025-11-07 11:29:03,587 INFO MainThread:213027 [wandb_setup.py:_flush():81] Loading settings from /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/settings
|
| 5 |
+
2025-11-07 11:29:03,587 INFO MainThread:213027 [wandb_setup.py:_flush():81] Loading settings from environment variables
|
| 6 |
+
2025-11-07 11:29:03,587 INFO MainThread:213027 [wandb_init.py:setup_run_log_directory():706] Logging user logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug.log
|
| 7 |
+
2025-11-07 11:29:03,587 INFO MainThread:213027 [wandb_init.py:setup_run_log_directory():707] Logging internal logs to /mnt/general/wanghy/RAGEN/cleanrl/cleanrl/wandb/run-20251107_112903-8xop3upl/logs/debug-internal.log
|
| 8 |
+
2025-11-07 11:29:03,589 INFO MainThread:213027 [wandb_init.py:init():833] calling init triggers
|
| 9 |
+
2025-11-07 11:29:03,589 INFO MainThread:213027 [wandb_init.py:init():838] wandb.init called with sweep_config: {}
|
| 10 |
+
config: {'exp_name': 'ppo_frozenlake', 'seed': 1, 'torch_deterministic': True, 'cuda': True, 'track': True, 'wandb_project_name': 'ragen-bandit', 'wandb_entity': None, 'capture_video': False, 'env_id': 'FrozenLake', 'total_timesteps': 10000000, 'learning_rate': 0.00025, 'num_envs': 32, 'num_steps': 512, 'anneal_lr': True, 'gamma': 0.99, 'gae_lambda': 0.95, 'num_minibatches': 4, 'update_epochs': 4, 'norm_adv': True, 'clip_coef': 0.2, 'clip_vloss': True, 'ent_coef': 0.01, 'vf_coef': 0.5, 'max_grad_norm': 0.5, 'target_kl': None, 'grid_size': 4, 'is_slippery': True, 'batch_size': 16384, 'minibatch_size': 4096, 'num_iterations': 610, '_wandb': {'code_path': 'code/cleanrl/ppo_frozenlake.py'}}
|
| 11 |
+
2025-11-07 11:29:03,589 INFO MainThread:213027 [wandb_init.py:init():881] starting backend
|
| 12 |
+
2025-11-07 11:29:03,795 INFO MainThread:213027 [wandb_init.py:init():884] sending inform_init request
|
| 13 |
+
2025-11-07 11:29:03,807 INFO MainThread:213027 [wandb_init.py:init():892] backend started and connected
|
| 14 |
+
2025-11-07 11:29:03,808 INFO MainThread:213027 [wandb_init.py:init():962] updated telemetry
|
| 15 |
+
2025-11-07 11:29:03,841 INFO MainThread:213027 [wandb_init.py:init():986] communicating run to backend with 90.0 second timeout
|
| 16 |
+
2025-11-07 11:29:04,549 INFO MainThread:213027 [wandb_init.py:init():1033] starting run threads in backend
|
| 17 |
+
2025-11-07 11:29:04,693 INFO MainThread:213027 [wandb_run.py:_console_start():2506] atexit reg
|
| 18 |
+
2025-11-07 11:29:04,693 INFO MainThread:213027 [wandb_run.py:_redirect():2354] redirect: wrap_raw
|
| 19 |
+
2025-11-07 11:29:04,694 INFO MainThread:213027 [wandb_run.py:_redirect():2423] Wrapping output streams.
|
| 20 |
+
2025-11-07 11:29:04,694 INFO MainThread:213027 [wandb_run.py:_redirect():2446] Redirects installed.
|
| 21 |
+
2025-11-07 11:29:04,696 INFO MainThread:213027 [wandb_init.py:init():1073] run started, returning control to user process
|
| 22 |
+
2025-11-07 11:29:04,696 INFO MainThread:213027 [wandb_run.py:_tensorboard_callback():1598] tensorboard callback: runs/FrozenLake__ppo_frozenlake__1__1762486136, True
|
| 23 |
+
2025-11-07 11:38:17,366 INFO wandb-AsyncioManager-main:213027 [service_client.py:_forward_responses():80] Reached EOF.
|
| 24 |
+
2025-11-07 11:38:17,366 INFO wandb-AsyncioManager-main:213027 [mailbox.py:close():137] Closing mailbox, abandoning 1 handles.
|
| 25 |
+
2025-11-07 11:38:17,715 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 26 |
+
Traceback (most recent call last):
|
| 27 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 28 |
+
await fn()
|
| 29 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 30 |
+
await self._send_server_request(request)
|
| 31 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 32 |
+
await self._writer.drain()
|
| 33 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 34 |
+
await self._protocol._drain_helper()
|
| 35 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 36 |
+
raise ConnectionResetError('Connection lost')
|
| 37 |
+
ConnectionResetError: Connection lost
|
| 38 |
+
2025-11-07 11:38:17,718 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 39 |
+
Traceback (most recent call last):
|
| 40 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 41 |
+
await fn()
|
| 42 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 43 |
+
await self._send_server_request(request)
|
| 44 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 45 |
+
await self._writer.drain()
|
| 46 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 47 |
+
await self._protocol._drain_helper()
|
| 48 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 49 |
+
raise ConnectionResetError('Connection lost')
|
| 50 |
+
ConnectionResetError: Connection lost
|
| 51 |
+
2025-11-07 11:38:17,719 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 52 |
+
Traceback (most recent call last):
|
| 53 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 54 |
+
await fn()
|
| 55 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 56 |
+
await self._send_server_request(request)
|
| 57 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 58 |
+
await self._writer.drain()
|
| 59 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 60 |
+
await self._protocol._drain_helper()
|
| 61 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 62 |
+
raise ConnectionResetError('Connection lost')
|
| 63 |
+
ConnectionResetError: Connection lost
|
| 64 |
+
2025-11-07 11:38:17,719 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 65 |
+
Traceback (most recent call last):
|
| 66 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 67 |
+
await fn()
|
| 68 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 69 |
+
await self._send_server_request(request)
|
| 70 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 71 |
+
await self._writer.drain()
|
| 72 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 73 |
+
await self._protocol._drain_helper()
|
| 74 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 75 |
+
raise ConnectionResetError('Connection lost')
|
| 76 |
+
ConnectionResetError: Connection lost
|
| 77 |
+
2025-11-07 11:38:17,720 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 78 |
+
Traceback (most recent call last):
|
| 79 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 80 |
+
await fn()
|
| 81 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 82 |
+
await self._send_server_request(request)
|
| 83 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 84 |
+
await self._writer.drain()
|
| 85 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 86 |
+
await self._protocol._drain_helper()
|
| 87 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 88 |
+
raise ConnectionResetError('Connection lost')
|
| 89 |
+
ConnectionResetError: Connection lost
|
| 90 |
+
2025-11-07 11:38:17,726 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 91 |
+
Traceback (most recent call last):
|
| 92 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 93 |
+
await fn()
|
| 94 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 95 |
+
await self._send_server_request(request)
|
| 96 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 97 |
+
await self._writer.drain()
|
| 98 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 99 |
+
await self._protocol._drain_helper()
|
| 100 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 101 |
+
raise ConnectionResetError('Connection lost')
|
| 102 |
+
ConnectionResetError: Connection lost
|
| 103 |
+
2025-11-07 11:38:17,727 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 104 |
+
Traceback (most recent call last):
|
| 105 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 106 |
+
await fn()
|
| 107 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 108 |
+
await self._send_server_request(request)
|
| 109 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 110 |
+
await self._writer.drain()
|
| 111 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 112 |
+
await self._protocol._drain_helper()
|
| 113 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 114 |
+
raise ConnectionResetError('Connection lost')
|
| 115 |
+
ConnectionResetError: Connection lost
|
| 116 |
+
2025-11-07 11:38:17,728 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 117 |
+
Traceback (most recent call last):
|
| 118 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 119 |
+
await fn()
|
| 120 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 121 |
+
await self._send_server_request(request)
|
| 122 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 123 |
+
await self._writer.drain()
|
| 124 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 125 |
+
await self._protocol._drain_helper()
|
| 126 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 127 |
+
raise ConnectionResetError('Connection lost')
|
| 128 |
+
ConnectionResetError: Connection lost
|
| 129 |
+
2025-11-07 11:38:17,728 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 130 |
+
Traceback (most recent call last):
|
| 131 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 132 |
+
await fn()
|
| 133 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 134 |
+
await self._send_server_request(request)
|
| 135 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 136 |
+
await self._writer.drain()
|
| 137 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 138 |
+
await self._protocol._drain_helper()
|
| 139 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 140 |
+
raise ConnectionResetError('Connection lost')
|
| 141 |
+
ConnectionResetError: Connection lost
|
| 142 |
+
2025-11-07 11:38:17,728 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 143 |
+
Traceback (most recent call last):
|
| 144 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 145 |
+
await fn()
|
| 146 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 147 |
+
await self._send_server_request(request)
|
| 148 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 149 |
+
await self._writer.drain()
|
| 150 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 151 |
+
await self._protocol._drain_helper()
|
| 152 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 153 |
+
raise ConnectionResetError('Connection lost')
|
| 154 |
+
ConnectionResetError: Connection lost
|
| 155 |
+
2025-11-07 11:38:17,729 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 156 |
+
Traceback (most recent call last):
|
| 157 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 158 |
+
await fn()
|
| 159 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 160 |
+
await self._send_server_request(request)
|
| 161 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 162 |
+
await self._writer.drain()
|
| 163 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 164 |
+
await self._protocol._drain_helper()
|
| 165 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 166 |
+
raise ConnectionResetError('Connection lost')
|
| 167 |
+
ConnectionResetError: Connection lost
|
| 168 |
+
2025-11-07 11:38:17,729 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 169 |
+
Traceback (most recent call last):
|
| 170 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 171 |
+
await fn()
|
| 172 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 173 |
+
await self._send_server_request(request)
|
| 174 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 175 |
+
await self._writer.drain()
|
| 176 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 177 |
+
await self._protocol._drain_helper()
|
| 178 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 179 |
+
raise ConnectionResetError('Connection lost')
|
| 180 |
+
ConnectionResetError: Connection lost
|
| 181 |
+
2025-11-07 11:38:17,730 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 182 |
+
Traceback (most recent call last):
|
| 183 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 184 |
+
await fn()
|
| 185 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 186 |
+
await self._send_server_request(request)
|
| 187 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 188 |
+
await self._writer.drain()
|
| 189 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 190 |
+
await self._protocol._drain_helper()
|
| 191 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 192 |
+
raise ConnectionResetError('Connection lost')
|
| 193 |
+
ConnectionResetError: Connection lost
|
| 194 |
+
2025-11-07 11:38:17,730 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 195 |
+
Traceback (most recent call last):
|
| 196 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 197 |
+
await fn()
|
| 198 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 199 |
+
await self._send_server_request(request)
|
| 200 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 201 |
+
await self._writer.drain()
|
| 202 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 203 |
+
await self._protocol._drain_helper()
|
| 204 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 205 |
+
raise ConnectionResetError('Connection lost')
|
| 206 |
+
ConnectionResetError: Connection lost
|
| 207 |
+
2025-11-07 11:38:17,730 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 208 |
+
Traceback (most recent call last):
|
| 209 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 210 |
+
await fn()
|
| 211 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 212 |
+
await self._send_server_request(request)
|
| 213 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 214 |
+
await self._writer.drain()
|
| 215 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 216 |
+
await self._protocol._drain_helper()
|
| 217 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 218 |
+
raise ConnectionResetError('Connection lost')
|
| 219 |
+
ConnectionResetError: Connection lost
|
| 220 |
+
2025-11-07 11:38:17,731 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 221 |
+
Traceback (most recent call last):
|
| 222 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 223 |
+
await fn()
|
| 224 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 225 |
+
await self._send_server_request(request)
|
| 226 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 227 |
+
await self._writer.drain()
|
| 228 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 229 |
+
await self._protocol._drain_helper()
|
| 230 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 231 |
+
raise ConnectionResetError('Connection lost')
|
| 232 |
+
ConnectionResetError: Connection lost
|
| 233 |
+
2025-11-07 11:38:17,731 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 234 |
+
Traceback (most recent call last):
|
| 235 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 236 |
+
await fn()
|
| 237 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 238 |
+
await self._send_server_request(request)
|
| 239 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 240 |
+
await self._writer.drain()
|
| 241 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 242 |
+
await self._protocol._drain_helper()
|
| 243 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 244 |
+
raise ConnectionResetError('Connection lost')
|
| 245 |
+
ConnectionResetError: Connection lost
|
| 246 |
+
2025-11-07 11:38:17,731 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 247 |
+
Traceback (most recent call last):
|
| 248 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 249 |
+
await fn()
|
| 250 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 251 |
+
await self._send_server_request(request)
|
| 252 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 253 |
+
await self._writer.drain()
|
| 254 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 255 |
+
await self._protocol._drain_helper()
|
| 256 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 257 |
+
raise ConnectionResetError('Connection lost')
|
| 258 |
+
ConnectionResetError: Connection lost
|
| 259 |
+
2025-11-07 11:38:17,732 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 260 |
+
Traceback (most recent call last):
|
| 261 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 262 |
+
await fn()
|
| 263 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 264 |
+
await self._send_server_request(request)
|
| 265 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 266 |
+
await self._writer.drain()
|
| 267 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 268 |
+
await self._protocol._drain_helper()
|
| 269 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 270 |
+
raise ConnectionResetError('Connection lost')
|
| 271 |
+
ConnectionResetError: Connection lost
|
| 272 |
+
2025-11-07 11:38:17,733 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 273 |
+
Traceback (most recent call last):
|
| 274 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 275 |
+
await fn()
|
| 276 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 277 |
+
await self._send_server_request(request)
|
| 278 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 279 |
+
await self._writer.drain()
|
| 280 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 281 |
+
await self._protocol._drain_helper()
|
| 282 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 283 |
+
raise ConnectionResetError('Connection lost')
|
| 284 |
+
ConnectionResetError: Connection lost
|
| 285 |
+
2025-11-07 11:38:17,733 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 286 |
+
Traceback (most recent call last):
|
| 287 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 288 |
+
await fn()
|
| 289 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 290 |
+
await self._send_server_request(request)
|
| 291 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 292 |
+
await self._writer.drain()
|
| 293 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 294 |
+
await self._protocol._drain_helper()
|
| 295 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 296 |
+
raise ConnectionResetError('Connection lost')
|
| 297 |
+
ConnectionResetError: Connection lost
|
| 298 |
+
2025-11-07 11:38:17,734 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 299 |
+
Traceback (most recent call last):
|
| 300 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 301 |
+
await fn()
|
| 302 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 303 |
+
await self._send_server_request(request)
|
| 304 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 305 |
+
await self._writer.drain()
|
| 306 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 307 |
+
await self._protocol._drain_helper()
|
| 308 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 309 |
+
raise ConnectionResetError('Connection lost')
|
| 310 |
+
ConnectionResetError: Connection lost
|
| 311 |
+
2025-11-07 11:38:17,735 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 312 |
+
Traceback (most recent call last):
|
| 313 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 314 |
+
await fn()
|
| 315 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 316 |
+
await self._send_server_request(request)
|
| 317 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 318 |
+
await self._writer.drain()
|
| 319 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 320 |
+
await self._protocol._drain_helper()
|
| 321 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 322 |
+
raise ConnectionResetError('Connection lost')
|
| 323 |
+
ConnectionResetError: Connection lost
|
| 324 |
+
2025-11-07 11:38:17,736 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 325 |
+
Traceback (most recent call last):
|
| 326 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 327 |
+
await fn()
|
| 328 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 329 |
+
await self._send_server_request(request)
|
| 330 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 331 |
+
await self._writer.drain()
|
| 332 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 333 |
+
await self._protocol._drain_helper()
|
| 334 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 335 |
+
raise ConnectionResetError('Connection lost')
|
| 336 |
+
ConnectionResetError: Connection lost
|
| 337 |
+
2025-11-07 11:38:17,738 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 338 |
+
Traceback (most recent call last):
|
| 339 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 340 |
+
await fn()
|
| 341 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 342 |
+
await self._send_server_request(request)
|
| 343 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 344 |
+
await self._writer.drain()
|
| 345 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 346 |
+
await self._protocol._drain_helper()
|
| 347 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 348 |
+
raise ConnectionResetError('Connection lost')
|
| 349 |
+
ConnectionResetError: Connection lost
|
| 350 |
+
2025-11-07 11:38:17,739 ERROR wandb-AsyncioManager-main:213027 [asyncio_manager.py:fn_wrap_exceptions():183] Uncaught exception in run_soon callback.
|
| 351 |
+
Traceback (most recent call last):
|
| 352 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/asyncio_manager.py", line 181, in fn_wrap_exceptions
|
| 353 |
+
await fn()
|
| 354 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 38, in publish
|
| 355 |
+
await self._send_server_request(request)
|
| 356 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/site-packages/wandb/sdk/lib/service/service_client.py", line 64, in _send_server_request
|
| 357 |
+
await self._writer.drain()
|
| 358 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 392, in drain
|
| 359 |
+
await self._protocol._drain_helper()
|
| 360 |
+
File "/root/local/miniconda3/envs/ragen/lib/python3.12/asyncio/streams.py", line 166, in _drain_helper
|
| 361 |
+
raise ConnectionResetError('Connection lost')
|
| 362 |
+
ConnectionResetError: Connection lost
|