├── .gitignore ├── LICENSE ├── README.md ├── conda_env ├── 11-algo-both-v5-c2-3k.png ├── 2-comp-dfu-per-step-v2-3k.png ├── d4rl │ ├── README.md │ ├── extra_requirements.txt │ ├── pip_extra_req.sh │ ├── req_mujoco.sh │ └── requirements.txt ├── gen_pip_req.ipynb ├── install_ogb.sh ├── install_pre.sh ├── ogb_dset_download.ipynb └── requirements.txt ├── config ├── baselines │ ├── ben │ │ ├── README.md │ │ ├── dd_bline_m2d_Lg_BenPadex60FL_h192.py │ │ ├── dd_bline_m2d_Me_BenPadex68FL_h144.py │ │ ├── dd_bline_m2d_Umz_BenPadex40FL.py │ │ └── dd_bline_m2d_Umz_BenPadex40FL_luotest.py │ └── dd_ogb │ │ ├── dd_ogb_antM_Gi_Navi_o2d_noPad_h880_ts512.py │ │ ├── dd_ogb_antM_Gi_o2d_PadBuf_Ft64_h160_ts512.py │ │ ├── dd_ogb_pntM_Gi_o2d_PadBuf_Ft64_h160_ts512.py │ │ ├── dd_ogb_pntM_Lg_o2d_PadBuf_Ft64_h160_ts512.py │ │ └── dd_ogb_pntM_Me_o2d_PadBuf_Ft64_h160_ts512.py ├── og_antM_Gi_o2d_luotest.py ├── ogb_ant_maze │ ├── og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py │ ├── og_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit.py │ ├── og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py │ ├── og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py │ └── og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py ├── ogb_hum_maze │ ├── og_humM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts1k_h336_ovlp128_ovdm5_ts512_bs192_bd128_td96_drop02.py │ ├── og_humM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts1k_h336_ovlp128_ovdm5_ts512_bs192_bd128_td96_drop02.py │ └── og_humM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts1k_h336_ovlp128_ovdm5_ts512_bs192_bd128_td96_drop02.py ├── ogb_invdyn │ ├── og_inv_ant │ │ ├── og_antM_Gi_o29d_g15d_invdyn_h12.py │ │ ├── og_antM_Gi_o29d_g29d_invdyn_h12_dm5.py │ │ ├── og_antM_Gi_o29d_g2d_invdyn_h12.py │ │ ├── og_antM_Lg_o29d_g15d_invdyn_h12.py │ │ ├── og_antM_Lg_o29d_g29d_invdyn_h12.py │ │ ├── og_antM_Lg_o29d_g2d_invdyn_h12.py │ │ ├── og_antM_Me_o29d_g15d_invdyn_h12.py │ │ ├── og_antM_Me_o29d_g29d_invdyn_h12_dm5.py │ │ ├── og_antM_Me_o29d_g2d_invdyn_h12.py │ │ ├── og_antMexpl_Lg_o29d_g2d_invdyn_h12.py │ │ └── og_antMexpl_Me_o29d_g2d_invdyn_h12.py │ ├── og_inv_ant_soc │ │ ├── og_antSoc_Ar_o42d_g17d_invdyn_h120_dout02.py │ │ ├── og_antSoc_Ar_o42d_g4d_invdyn_h120_dout02.py │ │ ├── og_antSoc_Me_o42d_g17d_invdyn_h100_dm4_dout02.py │ │ └── og_antSoc_Me_o42d_g4d_invdyn_h120_dm4_dout02.py │ └── og_inv_hum │ │ ├── og_humM_Gi_o69d_g2d_invdyn_h80_dm5_dout02.py │ │ ├── og_humM_Lg_o69d_g2d_invdyn_h80_dm5_dout02.py │ │ └── og_humM_Me_o69d_g2d_invdyn_h80_dm5_dout02.py └── ogb_pnt_maze │ ├── og_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py │ ├── og_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py │ └── og_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py ├── data ├── m2d │ ├── ev_probs │ │ ├── ben │ │ │ ├── ben_maze2d_Me_ev_prob_numEp10_eSdSt0.hdf5 │ │ │ ├── ben_maze2d_Umz_ev_prob_numEp10_eSdSt0.hdf5 │ │ │ ├── ben_maze2d_lg_ev_prob_luotest.hdf5 │ │ │ └── ben_maze2d_lg_ev_prob_numEp10_eSdSt0.hdf5 │ │ ├── maze2d_lg_ev_prob_bt2way_nppp3.hdf5 │ │ ├── maze2d_lg_ev_prob_bt2way_nppp3_rprange02.hdf5 │ │ ├── maze2d_lg_ev_prob_luotest.hdf5 │ │ └── maze2d_lg_ev_prob_luotest_2.hdf5 │ ├── maze2d-large-sparse-v1-luotest.hdf5 │ ├── maze2d-medium-sparse-v1-luotest.hdf5 │ └── maze2d-umaze-sparse-v1-luotest.hdf5 └── ogb_maze │ ├── antmaze-giant-stitch-v0-luotest.npz │ ├── antmaze-large-stitch-v0-luotest.npz │ ├── antmaze-medium-explore-v0-luotest.npz │ └── ev_probs │ ├── ogb_HumM_Gi_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_HumM_Gi_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 │ ├── ogb_HumM_Lg_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 │ ├── ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt_same2_Jan11.hdf5 │ ├── ogb_HumM_Me_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_HumM_Me_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 │ ├── ogb_HumM_full_jnt_luotest.hdf5 │ ├── ogb_antM_Gi_Navi_ev_prob_numEp20_eSdSt0_preAct5.hdf5 │ ├── ogb_antM_Gi_ev_prob_luotest.hdf5 │ ├── ogb_antM_Gi_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antM_Gi_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antM_Lg_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antM_Lg_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antM_Me_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antM_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct10.hdf5 │ ├── ogb_antSoc_Me_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5 │ ├── ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct10.hdf5 │ ├── ogb_pointM_Gi_ev_prob_numEp20_eSdSt0.hdf5 │ ├── ogb_pointM_Lg_ev_prob_numEp20_eSdSt0.hdf5 │ └── ogb_pointM_Me_ev_prob_numEp20_eSdSt0.hdf5 ├── diffuser ├── __init__.py ├── baselines │ ├── dd_maze │ │ ├── dd_maze_diffusion_v1.py │ │ ├── dd_maze_policy_v1.py │ │ ├── dd_maze_temporal_v1.py │ │ ├── dd_maze_training_v1.py │ │ ├── plan_dd_bline.py │ │ ├── plan_dd_bline.sh │ │ ├── train_dd_bline.py │ │ └── train_dd_bline.sh │ └── dd_ogb │ │ ├── plan_dd_ogb.py │ │ ├── plan_dd_ogb.sh │ │ ├── train_dd_ogb.py │ │ └── train_dd_ogb.sh ├── datasets │ ├── __init__.py │ ├── buffer.py │ ├── comp │ │ ├── __init__.py │ │ ├── ben_pad_buffer.py │ │ ├── ben_pad_dataset_v1.py │ │ ├── comp_data_utils.py │ │ ├── comp_dataset_v1.py │ │ └── d4rl_m2d_const.py │ ├── d4rl.py │ ├── gym_robo_utils.py │ ├── normalization.py │ ├── ogb_dset │ │ ├── __init__.py │ │ ├── init_hum_const.py │ │ ├── ogb_buffer_v2.py │ │ ├── ogb_dataset_v1.py │ │ ├── ogb_dataset_v2.py │ │ ├── ogb_invdyn_dataset_v1.py │ │ └── ogb_utils.py │ ├── preprocessing.py │ └── sequence.py ├── guides │ ├── __init__.py │ ├── comp │ │ ├── cd_sml_policies.py │ │ └── traj_blender.py │ ├── planner_m2d.py │ ├── policies_invdyn.py │ ├── render_m2d.py │ └── render_utils.py ├── models │ ├── __init__.py │ ├── cd_stgl_sml_dfu │ │ ├── __init__.py │ │ ├── plan_stgl_sml.py │ │ ├── plan_stgl_sml.sh │ │ ├── stgl_sml_diffusion_v1.py │ │ ├── stgl_sml_planner_v1.py │ │ ├── stgl_sml_policy_v1.py │ │ ├── stgl_sml_temporal_cond_v1.py │ │ ├── stgl_sml_training_v1.py │ │ ├── train_stgl_sml.py │ │ └── train_stgl_sml.sh │ ├── comp_dfu │ │ └── comp_diffusion_v1.py │ ├── cond_cp_dfu │ │ ├── __init__.py │ │ ├── sml_helpers.py │ │ ├── sml_temporal_cond_v1.py │ │ └── sml_temporal_dd_v1.py │ ├── helpers.py │ └── hi_helpers.py ├── ogb_task │ ├── og_inv_dyn │ │ ├── __init__.py │ │ ├── og_invdyn_helpers.py │ │ ├── og_invdyn_model.py │ │ ├── og_invdyn_training.py │ │ ├── train_og_invdyn.py │ │ └── train_og_invdyn.sh │ ├── og_models │ │ ├── dit_1d_traj_encoder.py │ │ ├── dit_1d_utils.py │ │ └── stgl_sml_dit_1d.py │ └── ogb_maze_v1 │ │ ├── __init__.py │ │ ├── ogb_stgl_sml_planner_v1.py │ │ ├── ogb_stgl_sml_training_v1.py │ │ ├── plan_ogb_stgl_sml.py │ │ ├── plan_ogb_stgl_sml.sh │ │ ├── train_ogb_stgl_sml.py │ │ └── train_ogb_stgl_sml.sh ├── pl_eval │ └── gen_ev_probs │ │ ├── README.md │ │ ├── gen_m2d_our_probs.py │ │ ├── gen_m2d_our_probs.sh │ │ ├── gen_m2d_our_probs_confs.yaml │ │ ├── gen_m2d_probs_utils.py │ │ └── m2d_pl_const.py └── utils │ ├── __init__.py │ ├── arrays.py │ ├── config.py │ ├── cp_utils │ ├── cp_luo_utils.py │ ├── cp_serial.py │ ├── maze_utils.py │ └── plan_utils.py │ ├── eval_utils.py │ ├── git_utils.py │ ├── ogb_paper_vis_utils │ ├── README.md │ ├── __init__.py │ ├── ogb_vis_multi_agent_env.py │ ├── ogb_vis_multi_agent_utils.py │ └── vis_misc_utils.py │ ├── ogb_utils │ └── ogb_serial.py │ ├── progress.py │ ├── rendering.py │ ├── serialization.py │ ├── setup.py │ ├── timer.py │ ├── train_utils.py │ ├── training.py │ └── video.py ├── logs └── .gitkeep └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | bin/ 2 | logs/* 3 | wandb/ 4 | 5 | fuse.cfg 6 | 7 | *.ai 8 | 9 | ## --------- LUO ----------- 10 | .vscode/* 11 | trash/** 12 | luotest/** 13 | data/* 14 | !data/ogb_maze 15 | !data/m2d 16 | 17 | my_class_*.pkl 18 | scripts/cd_sml/**.ipynb 19 | scripts/stgl_sml/** 20 | scripts/luotest/** 21 | scripts/loc_stret/** 22 | scripts/ogb_stgl_maze/* 23 | ## ------------------------- 24 | 25 | ## ------- Luo New --------- 26 | scripts/* 27 | config/resume/* 28 | !logs/.gitkeep 29 | ckpts/* 30 | src/* 31 | 32 | 33 | ## ------------------------- 34 | 35 | 36 | # Generation results 37 | results/ 38 | 39 | ray/auth.json 40 | 41 | # Byte-compiled / optimized / DLL files 42 | __pycache__/ 43 | *.py[cod] 44 | *$py.class 45 | 46 | # C extensions 47 | *.so 48 | 49 | # Distribution / packaging 50 | .Python 51 | build/ 52 | develop-eggs/ 53 | dist/ 54 | downloads/ 55 | eggs/ 56 | .eggs/ 57 | lib/ 58 | lib64/ 59 | parts/ 60 | sdist/ 61 | var/ 62 | wheels/ 63 | pip-wheel-metadata/ 64 | share/python-wheels/ 65 | *.egg-info/ 66 | .installed.cfg 67 | *.egg 68 | MANIFEST 69 | 70 | # PyInstaller 71 | # Usually these files are written by a python script from a template 72 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 73 | *.manifest 74 | *.spec 75 | 76 | # Installer logs 77 | pip-log.txt 78 | pip-delete-this-directory.txt 79 | 80 | # Unit test / coverage reports 81 | htmlcov/ 82 | .tox/ 83 | .nox/ 84 | .coverage 85 | .coverage.* 86 | .cache 87 | nosetests.xml 88 | coverage.xml 89 | *.cover 90 | *.py,cover 91 | .hypothesis/ 92 | .pytest_cache/ 93 | 94 | # Translations 95 | *.mo 96 | *.pot 97 | 98 | # Django stuff: 99 | *.log 100 | local_settings.py 101 | db.sqlite3 102 | db.sqlite3-journal 103 | 104 | # Flask stuff: 105 | instance/ 106 | .webassets-cache 107 | 108 | # Scrapy stuff: 109 | .scrapy 110 | 111 | # Sphinx documentation 112 | docs/_build/ 113 | 114 | # PyBuilder 115 | target/ 116 | 117 | # Jupyter Notebook 118 | .ipynb_checkpoints 119 | 120 | # IPython 121 | profile_default/ 122 | ipython_config.py 123 | 124 | # pyenv 125 | .python-version 126 | 127 | # pipenv 128 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 129 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 130 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 131 | # install all needed dependencies. 132 | #Pipfile.lock 133 | 134 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 135 | __pypackages__/ 136 | 137 | # Celery stuff 138 | celerybeat-schedule 139 | celerybeat.pid 140 | 141 | # SageMath parsed files 142 | *.sage.py 143 | 144 | # Environments 145 | .env 146 | .venv 147 | env/ 148 | venv/ 149 | ENV/ 150 | env.bak/ 151 | venv.bak/ 152 | 153 | # Spyder project settings 154 | .spyderproject 155 | .spyproject 156 | 157 | # Rope project settings 158 | .ropeproject 159 | 160 | # mkdocs documentation 161 | /site 162 | 163 | # mypy 164 | .mypy_cache/ 165 | .dmypy.json 166 | dmypy.json 167 | 168 | # Pyre type checker 169 | .pyre/ 170 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Yunhao Luo 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /conda_env/11-algo-both-v5-c2-3k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/conda_env/11-algo-both-v5-c2-3k.png -------------------------------------------------------------------------------- /conda_env/2-comp-dfu-per-step-v2-3k.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/conda_env/2-comp-dfu-per-step-v2-3k.png -------------------------------------------------------------------------------- /conda_env/d4rl/README.md: -------------------------------------------------------------------------------- 1 | Files within this folder is not used for setting up the the OGBench env. But they might be helpful for creating conda env for d4rl. Just for reference proposes. -------------------------------------------------------------------------------- /conda_env/d4rl/extra_requirements.txt: -------------------------------------------------------------------------------- 1 | # decision making, since d4rl depends on old mujoco_py & binary 2 | ## -------- Luo ---------- 3 | pip==21 4 | scikit-image==0.17.2 5 | scikit-video==1.1.11 6 | 7 | ## ------ DF Boyuan -------- 8 | # cython<3 ## ori: <=3 # <3 ? 9 | ## install below one by one 10 | setuptools==65.5.0 11 | # wheel==0.40.0 12 | wheel==0.38.0 13 | gym==0.19.0 14 | d4rl==1.1 15 | shimmy>=0.2.1 16 | stable-baselines3 17 | 18 | -------------------------------------------------------------------------------- /conda_env/d4rl/pip_extra_req.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ~/.bashrc 4 | source activate hi_diffuser 5 | # module load patchelf glew ## for compling the mujoco 6 | 7 | pip install pip==21 && \ 8 | pip install "cython<3" ## ori: <=3 # <3 ? 9 | pip install setuptools==65.5.0 10 | 11 | ## 0.40.0 12 | pip install wheel==0.38.0 && \ 13 | pip install gym==0.19.0 && \ 14 | pip install d4rl==1.1 && \ 15 | pip install "shimmy>=0.2.1" && \ 16 | pip install stable-baselines3 && \ 17 | 18 | ## For Diffuser Legacy 19 | pip install scikit-image==0.17.2 scikit-video==1.1.11 -------------------------------------------------------------------------------- /conda_env/d4rl/req_mujoco.sh: -------------------------------------------------------------------------------- 1 | ## install mujoco210 first, just simply install it to 2 | ## ~/.mujoco/mujoco210, otherwise might have bugs! 3 | 4 | ## remember to put this to ~/.bashrc 5 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/nethome/yluo470/.mujoco/mujoco210/bin" 6 | ## actually it is a not existed path 7 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/lib/nvidia" 8 | 9 | 10 | ## install rendering dependencies 11 | conda install -y -c conda-forge glew 12 | conda install -y -c conda-forge mesalib 13 | conda install -c menpo glfw3 14 | 15 | ## oneline version 16 | conda install -y -c conda-forge glew && conda install -y -c conda-forge mesalib && conda install -c menpo glfw3 17 | 18 | ### Sep 24: use another channel to prevent re-install another version of python 19 | # conda install -c pkgs/main glew 20 | 21 | 22 | ## Then add your conda environment include to CPATH (put this in your .bashrc to make it permanent): 23 | export CPATH=$CONDA_PREFIX/include 24 | ## Finally, install patchelf with pip install patchelf 25 | 26 | ## for libmamba solver 27 | ## $ conda install --solver=classic conda-forge::conda-libmamba-solver conda-forge::libmamba conda-forge::libmambapy conda-forge::libarchive 28 | -------------------------------------------------------------------------------- /conda_env/d4rl/requirements.txt: -------------------------------------------------------------------------------- 1 | ## NEW July 19 2024 2 | # torch~=2.0.0 3 | # torchvision~=0.15.1 4 | # gpustat 5 | 6 | ## --- Oct 2024 ---- 7 | # pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu118 8 | ## ----------------- 9 | 10 | colorama==0.4.6 11 | einops 12 | GitPython==3.1.37 13 | # gym==0.17.3 14 | h5py 15 | huggingface-hub==0.17.3 16 | hypothesis==6.87.1 17 | imageio 18 | imageio-ffmpeg 19 | ipython 20 | jupyter==1.0.0 21 | matplotlib==3.7.2 22 | mediapy 23 | multiprocess==0.70.15 24 | # numpy==1.23.4 25 | omegaconf 26 | opencv-python==4.5.1.48 27 | pandas 28 | Pillow 29 | # pybullet==3.2.5 30 | pyogrio==0.6.0 31 | PyOpenGL==3.1.7 32 | pyparsing==3.0.9 33 | pyproj==3.6.1 34 | pyproject_hooks==1.1.0 35 | # pyquaternion==0.9.9 36 | pytest==7.4.2 37 | PyYAML==6.0.1 38 | scikit-learn==1.3.0 39 | scipy==1.11.1 40 | sortedcontainers==2.4.0 41 | termcolor==2.4.0 42 | testbook==0.4.2 43 | threadpoolctl==3.2.0 44 | timm==0.9.7 45 | tqdm==4.65.0 46 | transforms3d==0.4.1 47 | typed-argument-parser==1.10.0 48 | wandb==0.14.2 49 | gpustat 50 | 51 | 52 | -------------------------------------------------------------------------------- /conda_env/gen_pip_req.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": 1, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "def remove_comments(input_file, output_file):\n", 10 | " with open(input_file, 'r') as infile, open(output_file, 'w') as outfile:\n", 11 | " for line in infile:\n", 12 | " if not line.strip().startswith('#') and line != '\\n':\n", 13 | " outfile.write(line)\n", 14 | "\n", 15 | "# Example usage\n", 16 | "remove_comments('../req1.txt', './req_v1.txt')\n" 17 | ] 18 | } 19 | ], 20 | "metadata": { 21 | "kernelspec": { 22 | "display_name": "hi_diffuser_ogbench_v3", 23 | "language": "python", 24 | "name": "python3" 25 | }, 26 | "language_info": { 27 | "codemirror_mode": { 28 | "name": "ipython", 29 | "version": 3 30 | }, 31 | "file_extension": ".py", 32 | "mimetype": "text/x-python", 33 | "name": "python", 34 | "nbconvert_exporter": "python", 35 | "pygments_lexer": "ipython3", 36 | "version": "3.9.20" 37 | } 38 | }, 39 | "nbformat": 4, 40 | "nbformat_minor": 2 41 | } 42 | -------------------------------------------------------------------------------- /conda_env/install_ogb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## 4 | ## Env Install: Step 4 5 | ## 6 | 7 | source ~/.bashrc 8 | # source activate hi_diffuser_ogbench_v3 9 | source activate compdfu_ogb_release 10 | 11 | 12 | ## Install the customized OGBench env by CompDiffuser 13 | ## We do not change the env logics, but simply add some features for better visualization 14 | 15 | ## ** Please clone the 'ogbench_cpdfu_release' repo *** 16 | ## You can also replace '../ogbench_cpdfu_release' by the acutal path in your computer 17 | pip install -e '../ogbench_cpdfu_release' 18 | 19 | ## this mujoco version might not be compatible to 'gymnasium-robotics', but since we probably won't use gymnasium-robotics, so it should be fine. 20 | pip install mujoco==3.2.6 21 | pip install setuptools==65.5.0 -------------------------------------------------------------------------------- /conda_env/install_pre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## 4 | ## Env Install: Step 1 5 | ## 6 | 7 | source ~/.bashrc 8 | # source activate hi_diffuser_ogbench_v3 9 | source activate compdfu_ogb_release 10 | 11 | ## install gymnasium env, which will also install d4rl etc. 12 | ## d4rl is probably not used in OGBench, but since our code is inherent from diffuser, some files might still import d4rl (though these files probably also can be removed) 13 | pip install -e git+https://github.com/Farama-Foundation/Gymnasium.git@81b87efb9f011e975f3b646bab6b7871c522e15e#egg=gymnasium 14 | pip install -e git+https://github.com/Farama-Foundation/Gymnasium-Robotics.git@3e42c3061aa23ce7f29ae8ec150ca6224e13ef09#egg=gymnasium_robotics 15 | 16 | ## install torch 17 | pip install torch==2.5.0 torchvision==0.20.0 --index-url https://download.pytorch.org/whl/cu121 -------------------------------------------------------------------------------- /conda_env/requirements.txt: -------------------------------------------------------------------------------- 1 | absl-py==2.1.0 2 | colorama==0.4.6 3 | Cython==3.0.11 4 | dill==0.3.9 5 | dm-env==1.6 6 | dm-tree==0.1.8 7 | dm_control==1.0.24 8 | einops==0.8.0 9 | exceptiongroup==1.2.2 10 | executing==2.1.0 11 | Farama-Notifications==0.0.4 12 | fasteners==0.19 13 | fastjsonschema==2.20.0 14 | filelock==3.16.1 15 | fonttools==4.54.1 16 | fqdn==1.5.1 17 | fsspec==2024.10.0 18 | gitdb==4.0.11 19 | GitPython==3.1.37 20 | glfw==2.7.0 21 | google-api-core==2.22.0 22 | google-auth==2.35.0 23 | google-cloud-core==2.4.1 24 | google-cloud-storage==2.5.0 25 | google-crc32c==1.6.0 26 | google-resumable-media==2.7.2 27 | googleapis-common-protos==1.65.0 28 | gpustat==1.1.1 29 | gym==0.23.1 30 | gym-notices==0.0.8 31 | h5py==3.12.1 32 | huggingface-hub==0.17.3 33 | imageio==2.36.0 34 | imageio-ffmpeg==0.5.1 35 | ipython==8.18.1 36 | jupyter==1.0.0 37 | matplotlib==3.7.2 38 | mediapy==1.2.2 39 | minari==0.4.2 40 | mujoco==3.2.6 41 | multiprocess==0.70.15 42 | notebook==7.2.2 43 | numpy==1.26.4 44 | omegaconf==2.3.0 45 | opencv-python==4.5.1.48 46 | pandas==2.2.3 47 | pillow==11.0.0 48 | platformdirs==4.3.6 49 | protobuf==4.25.5 50 | psutil==6.1.0 51 | ptyprocess==0.7.0 52 | pure_eval==0.2.3 53 | pyasn1==0.6.1 54 | pyasn1_modules==0.4.1 55 | pybullet==3.2.6 56 | pycparser==2.22 57 | Pygments==2.18.0 58 | pyogrio==0.6.0 59 | PyOpenGL==3.1.7 60 | pyparsing==3.0.9 61 | pyproj==3.6.1 62 | pyproject_hooks==1.1.0 63 | pytest==7.4.2 64 | python-dateutil==2.9.0.post0 65 | python-json-logger==2.0.7 66 | pytz==2024.2 67 | PyYAML==6.0.1 68 | pyzmq==26.2.0 69 | qtconsole==5.6.0 70 | QtPy==2.4.1 71 | requests==2.32.3 72 | safetensors==0.4.5 73 | scikit-learn==1.3.0 74 | scikit-video==1.1.11 75 | scipy==1.11.1 76 | seaborn==0.13.2 77 | sympy==1.13.1 78 | termcolor==2.4.0 79 | terminado==0.18.1 80 | testbook==0.4.2 81 | threadpoolctl==3.2.0 82 | timm==0.9.7 83 | tornado==6.4.1 84 | tqdm==4.65.0 85 | traitlets==5.14.3 86 | transforms3d==0.4.1 87 | triton==3.1.0 88 | typed-argument-parser==1.10.0 89 | typer==0.9.0 90 | urllib3==2.2.3 91 | wandb==0.14.2 92 | xformers==0.0.28.post2 93 | zipp==3.20.2 94 | 95 | 96 | ## packages too new 97 | ## setuptools==75.8.0 98 | ## sentry-sdk==2.26.1 99 | ## seems fine 100 | setuptools==65.5.0 101 | sentry-sdk==2.17.0 -------------------------------------------------------------------------------- /config/baselines/ben/README.md: -------------------------------------------------------------------------------- 1 | config files inside this folder are not supported yet. -------------------------------------------------------------------------------- /config/baselines/ben/dd_bline_m2d_Lg_BenPadex60FL_h192.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 192 35 | 36 | tot_horizon = sm_horizon 37 | time_dim = 64 38 | 39 | 40 | base = { 41 | 'dataset': "maze2d-large-v1", 42 | 'dset_h5path': 'data/data_hdf5_ben/ben-maze2d-large-sparse-v1.hdf5', ##### 43 | 44 | 'diffusion': { 45 | 'config_fn': '', 46 | 47 | 'sm_horizon': sm_horizon, 48 | 'tot_horizon': tot_horizon, 49 | 50 | 51 | ## 52 | ## cnn model 53 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 54 | 'base_dim': 96, 55 | 'dim_mults': (1, 2, 4, 8), 56 | 'time_dim': time_dim, 57 | 'network_config': dict(t_seq_encoder_type='mlp', 58 | cat_t_w=True, 59 | resblock_ksize=5, 60 | energy_mode=False, 61 | time_mlp_config=3, 62 | ### 63 | inpaint_token_dim=32, 64 | inpaint_token_type='const', 65 | 66 | ), 67 | 68 | ## TODO: 69 | ## dd dfu 70 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 71 | # 'dfu_model': 'models.GaussianDiffusion', 72 | 73 | 'n_diffusion_steps': 512, 74 | 'action_weight': 1, 75 | 'loss_weights': None, 76 | 'loss_discount': 1, 77 | 'predict_epsilon': False, ## 78 | 'diff_config': dict( 79 | infer_deno_type='same', 80 | obs_manual_loss_weights={}, 81 | w_loss_type='all', 82 | is_direct_train=True, 83 | ## 84 | # len_ovlp_cd=len_ovlap, 85 | # tr_1side_drop_prob=0.15, 86 | ## --- NEW --- 87 | # tr_inpat_prob=0.5, 88 | # tr_ovlp_prob=0.5, 89 | ), 90 | 91 | 92 | 'trainer_dict': dict(), 93 | 94 | 95 | 'renderer': 'guides.Maze2dRenderer_V2', 96 | 97 | ## dataset 98 | 'loader': 'datasets.comp.Comp_SeqDataset_V1', 99 | 'termination_penalty': None, 100 | 'normalizer': 'LimitsNormalizer', 101 | 'preprocess_fns': ['ben_maze2d_set_terminals'], #### 102 | 'clip_denoised': True, 103 | 'use_padding': True, 104 | 'max_path_length': 500, 105 | 'max_n_episodes': 21500, 106 | 'dataset_config': dict( 107 | obs_select_dim=(0,1), 108 | dset_type='bens_pm_large', 109 | pad_type='first_last', 110 | extra_pad=60, 111 | ), 112 | 113 | ## serialization 114 | 'logbase': 'logs', 115 | 'prefix': 'diffusion/', 116 | 'exp_name': watch(diffusion_args_to_watch), 117 | 118 | ## training 119 | 'n_steps_per_epoch': 10000, 120 | 'loss_type': 'l2_inv_v3', 121 | # 'loss_type': 'l2_v2', 122 | 'n_train_steps': 2e6, 123 | 124 | 'batch_size': 128, 125 | 'learning_rate': 2e-4, 126 | 'gradient_accumulate_every': 1, 127 | 'ema_decay': 0.995, 128 | 'save_freq': 4000, 129 | 'sample_freq': 4000, 130 | 'n_saves': 5, 131 | 132 | 'n_reference': 60, 133 | 'n_samples': 10, 134 | 135 | 'device': 'cuda', 136 | }, 137 | 138 | 'plan': { 139 | 'config_fn': '', 140 | 141 | 'batch_size': 1, 142 | 'device': 'cuda', 143 | 144 | ## diffusion model 145 | 'horizon': tot_horizon, 146 | 'n_diffusion_steps': 512, 147 | 'normalizer': 'LimitsNormalizer', 148 | 149 | ## serialization 150 | 'vis_freq': 10, 151 | 'logbase': 'logs', 152 | 'prefix': 'plans/release', 153 | 'exp_name': watch(plan_args_to_watch), 154 | 'suffix': '0', 155 | 156 | 'conditional': False, 157 | 158 | ## loading 159 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 160 | 'diffusion_epoch': 'latest', 161 | }, 162 | 163 | } 164 | 165 | -------------------------------------------------------------------------------- /config/baselines/ben/dd_bline_m2d_Me_BenPadex68FL_h144.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 144 35 | 36 | tot_horizon = sm_horizon 37 | time_dim = 64 38 | 39 | 40 | base = { 41 | 'dataset': "maze2d-medium-v1", 42 | 'dset_h5path': 'data/data_hdf5_ben/ben-maze2d-medium-sparse-v1.hdf5', ##### 43 | 44 | 'diffusion': { 45 | 'config_fn': '', 46 | 47 | 'sm_horizon': sm_horizon, 48 | 'tot_horizon': tot_horizon, 49 | 50 | 51 | ## 52 | ## cnn model 53 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 54 | 'base_dim': 96, 55 | 'dim_mults': (1, 2, 4, 8), 56 | 'time_dim': time_dim, 57 | 'network_config': dict(t_seq_encoder_type='mlp', 58 | cat_t_w=True, 59 | resblock_ksize=5, 60 | energy_mode=False, 61 | time_mlp_config=3, 62 | ### 63 | inpaint_token_dim=32, 64 | inpaint_token_type='const', 65 | 66 | ), 67 | 68 | ## TODO: 69 | ## dd dfu 70 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 71 | # 'dfu_model': 'models.GaussianDiffusion', 72 | 73 | 'n_diffusion_steps': 512, 74 | 'action_weight': 1, 75 | 'loss_weights': None, 76 | 'loss_discount': 1, 77 | 'predict_epsilon': False, ## 78 | 'diff_config': dict( 79 | infer_deno_type='same', 80 | obs_manual_loss_weights={}, 81 | w_loss_type='all', 82 | is_direct_train=True, 83 | ## 84 | # len_ovlp_cd=len_ovlap, 85 | # tr_1side_drop_prob=0.15, 86 | ## --- NEW --- 87 | # tr_inpat_prob=0.5, 88 | # tr_ovlp_prob=0.5, 89 | ), 90 | 91 | 92 | 'trainer_dict': dict(), 93 | 94 | 95 | 'renderer': 'guides.Maze2dRenderer_V2', 96 | 97 | ## dataset 98 | 'loader': 'datasets.comp.Comp_SeqDataset_V1', 99 | 'termination_penalty': None, 100 | 'normalizer': 'LimitsNormalizer', 101 | 'preprocess_fns': ['ben_maze2d_set_terminals'], #### 102 | 'clip_denoised': True, 103 | 'use_padding': True, 104 | 'max_path_length': 500, 105 | 'max_n_episodes': 21500, 106 | 'dataset_config': dict( 107 | obs_select_dim=(0,1), 108 | dset_type='bens_pm_medium', 109 | pad_type='first_last', 110 | extra_pad=68, 111 | ), 112 | 113 | ## serialization 114 | 'logbase': 'logs', 115 | 'prefix': 'diffusion/', 116 | 'exp_name': watch(diffusion_args_to_watch), 117 | 118 | ## training 119 | 'n_steps_per_epoch': 10000, 120 | 'loss_type': 'l2_inv_v3', 121 | # 'loss_type': 'l2_v2', 122 | 'n_train_steps': 2e6, 123 | 124 | 'batch_size': 128, 125 | 'learning_rate': 2e-4, 126 | 'gradient_accumulate_every': 1, 127 | 'ema_decay': 0.995, 128 | 'save_freq': 4000, 129 | 'sample_freq': 4000, 130 | 'n_saves': 5, 131 | 132 | 'n_reference': 60, 133 | 'n_samples': 10, 134 | 135 | 'device': 'cuda', 136 | }, 137 | 138 | 'plan': { 139 | 'config_fn': '', 140 | 141 | 'batch_size': 1, 142 | 'device': 'cuda', 143 | 144 | ## diffusion model 145 | 'horizon': tot_horizon, 146 | 'n_diffusion_steps': 512, 147 | 'normalizer': 'LimitsNormalizer', 148 | 149 | ## serialization 150 | 'vis_freq': 10, 151 | 'logbase': 'logs', 152 | 'prefix': 'plans/release', 153 | 'exp_name': watch(plan_args_to_watch), 154 | 'suffix': '0', 155 | 156 | 'conditional': False, 157 | 158 | ## loading 159 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 160 | 'diffusion_epoch': 'latest', 161 | }, 162 | 163 | } 164 | 165 | -------------------------------------------------------------------------------- /config/baselines/ben/dd_bline_m2d_Umz_BenPadex40FL.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 40 35 | # len_ovlap = 16 36 | tot_horizon = sm_horizon 37 | time_dim = 64 38 | 39 | 40 | base = { 41 | 'dataset': "maze2d-umaze-v1", 42 | 'dset_h5path': 'data/data_hdf5_ben/ben-maze2d-umaze-sparse-v1.hdf5', ##### 43 | 44 | 'diffusion': { 45 | 'config_fn': '', 46 | 47 | 'sm_horizon': sm_horizon, 48 | 'tot_horizon': tot_horizon, 49 | 50 | 51 | ## 52 | ## cnn model 53 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 54 | 'base_dim': 96, 55 | 'dim_mults': (1, 2, 4, 8), 56 | 'time_dim': time_dim, 57 | 'network_config': dict(t_seq_encoder_type='mlp', 58 | cat_t_w=True, 59 | resblock_ksize=5, 60 | energy_mode=False, 61 | time_mlp_config=3, 62 | ### 63 | inpaint_token_dim=32, 64 | inpaint_token_type='const', 65 | 66 | ), 67 | 68 | ## TODO: 69 | ## dd dfu 70 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 71 | # 'dfu_model': 'models.GaussianDiffusion', 72 | 73 | 'n_diffusion_steps': 512, 74 | 'action_weight': 1, 75 | 'loss_weights': None, 76 | 'loss_discount': 1, 77 | 'predict_epsilon': False, ## 78 | 'diff_config': dict( 79 | infer_deno_type='same', 80 | obs_manual_loss_weights={}, 81 | w_loss_type='all', 82 | is_direct_train=True, 83 | ## 84 | # len_ovlp_cd=len_ovlap, 85 | # tr_1side_drop_prob=0.15, 86 | ## --- NEW --- 87 | # tr_inpat_prob=0.5, 88 | # tr_ovlp_prob=0.5, 89 | ), 90 | 91 | 92 | 'trainer_dict': dict(), 93 | 94 | 95 | 'renderer': 'guides.Maze2dRenderer_V2', 96 | 97 | ## dataset 98 | 'loader': 'datasets.comp.Comp_SeqDataset_V1', 99 | 'termination_penalty': None, 100 | 'normalizer': 'LimitsNormalizer', 101 | 'preprocess_fns': ['ben_maze2d_set_terminals'], #### 102 | 'clip_denoised': True, 103 | 'use_padding': True, 104 | 'max_path_length': 200, 105 | 'max_n_episodes': 51500, 106 | 'dataset_config': dict( 107 | obs_select_dim=(0,1), 108 | dset_type='bens_pm_umaze', 109 | pad_type='first_last', 110 | extra_pad=40, 111 | ), 112 | 113 | ## serialization 114 | 'logbase': 'logs', 115 | 'prefix': 'diffusion/', 116 | 'exp_name': watch(diffusion_args_to_watch), 117 | 118 | ## training 119 | 'n_steps_per_epoch': 10000, 120 | 'loss_type': 'l2_inv_v3', 121 | # 'loss_type': 'l2_v2', 122 | 'n_train_steps': 2e6, 123 | 124 | 'batch_size': 128, 125 | 'learning_rate': 2e-4, 126 | 'gradient_accumulate_every': 1, 127 | 'ema_decay': 0.995, 128 | 'save_freq': 4000, 129 | 'sample_freq': 4000, 130 | 'n_saves': 5, 131 | 132 | 'n_reference': 60, 133 | 'n_samples': 10, 134 | 135 | 'device': 'cuda', 136 | }, 137 | 138 | 'plan': { 139 | 'config_fn': '', 140 | 141 | 'batch_size': 1, 142 | 'device': 'cuda', 143 | 144 | ## diffusion model 145 | 'horizon': tot_horizon, 146 | 'n_diffusion_steps': 512, 147 | 'normalizer': 'LimitsNormalizer', 148 | 149 | ## serialization 150 | 'vis_freq': 10, 151 | 'logbase': 'logs', 152 | 'prefix': 'plans/release', 153 | 'exp_name': watch(plan_args_to_watch), 154 | 'suffix': '0', 155 | 156 | 'conditional': False, 157 | 158 | ## loading 159 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 160 | 'diffusion_epoch': 'latest', 161 | }, 162 | 163 | } 164 | 165 | -------------------------------------------------------------------------------- /config/baselines/ben/dd_bline_m2d_Umz_BenPadex40FL_luotest.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 40 35 | # len_ovlap = 16 36 | tot_horizon = sm_horizon 37 | time_dim = 64 38 | 39 | 40 | base = { 41 | 'dataset': "maze2d-umaze-v1", 42 | ## TODO: 43 | # 'dset_h5path': 'data/data_hdf5_ben/ben-maze2d-umaze-sparse-v1.hdf5', ##### 44 | 'dset_h5path': 'data/data_hdf5_ben/ben-maze2d-umaze-sparse-luotest-v1.hdf5', 45 | 46 | 'diffusion': { 47 | 'config_fn': '', 48 | 49 | 'sm_horizon': sm_horizon, 50 | 'tot_horizon': tot_horizon, 51 | 52 | 53 | ## 54 | ## cnn model 55 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 56 | 'base_dim': 96, 57 | 'dim_mults': (1, 2, 4, 8), 58 | 'time_dim': time_dim, 59 | 'network_config': dict(t_seq_encoder_type='mlp', 60 | cat_t_w=True, 61 | resblock_ksize=5, 62 | energy_mode=False, 63 | time_mlp_config=3, 64 | ### 65 | inpaint_token_dim=32, 66 | inpaint_token_type='const', 67 | 68 | ), 69 | 70 | ## TODO: 71 | ## dd dfu 72 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 73 | # 'dfu_model': 'models.GaussianDiffusion', 74 | 75 | 'n_diffusion_steps': 512, 76 | 'action_weight': 1, 77 | 'loss_weights': None, 78 | 'loss_discount': 1, 79 | 'predict_epsilon': False, ## 80 | 'diff_config': dict( 81 | infer_deno_type='same', 82 | obs_manual_loss_weights={}, 83 | w_loss_type='all', 84 | is_direct_train=True, 85 | ## 86 | # len_ovlp_cd=len_ovlap, 87 | # tr_1side_drop_prob=0.15, 88 | ## --- NEW --- 89 | # tr_inpat_prob=0.5, 90 | # tr_ovlp_prob=0.5, 91 | ), 92 | 93 | 94 | 'trainer_dict': dict(), 95 | 96 | 97 | 'renderer': 'guides.Maze2dRenderer_V2', 98 | 99 | ## dataset 100 | 'loader': 'datasets.comp.Comp_SeqDataset_V1', 101 | 'termination_penalty': None, 102 | 'normalizer': 'LimitsNormalizer', 103 | 'preprocess_fns': ['ben_maze2d_set_terminals'], #### 104 | 'clip_denoised': True, 105 | 'use_padding': True, 106 | 'max_path_length': 200, 107 | 'max_n_episodes': 51500, 108 | 'dataset_config': dict( 109 | obs_select_dim=(0,1), 110 | dset_type='bens_pm_umaze', 111 | pad_type='first_last', 112 | extra_pad=40, 113 | ), 114 | 115 | ## serialization 116 | 'logbase': 'logs', 117 | 'prefix': 'diffusion/', 118 | 'exp_name': watch(diffusion_args_to_watch), 119 | 120 | ## training 121 | 'n_steps_per_epoch': 10000, 122 | 'loss_type': 'l2_inv_v3', 123 | # 'loss_type': 'l2_v2', 124 | 'n_train_steps': 2e6, 125 | 126 | 'batch_size': 128, 127 | 'learning_rate': 2e-4, 128 | 'gradient_accumulate_every': 1, 129 | 'ema_decay': 0.995, 130 | 'save_freq': 4000, 131 | 'sample_freq': 4000, 132 | 'n_saves': 5, 133 | 134 | 'n_reference': 60, 135 | 'n_samples': 10, 136 | 137 | 'device': 'cuda', 138 | }, 139 | 140 | 'plan': { 141 | 'config_fn': '', 142 | 143 | 'batch_size': 1, 144 | 'device': 'cuda', 145 | 146 | ## diffusion model 147 | 'horizon': tot_horizon, 148 | 'n_diffusion_steps': 512, 149 | 'normalizer': 'LimitsNormalizer', 150 | 151 | ## serialization 152 | 'vis_freq': 10, 153 | 'logbase': 'logs', 154 | 'prefix': 'plans/release', 155 | 'exp_name': watch(plan_args_to_watch), 156 | 'suffix': '0', 157 | 158 | 'conditional': False, 159 | 160 | ## loading 161 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 162 | 'diffusion_epoch': 'latest', 163 | }, 164 | 165 | } 166 | 167 | -------------------------------------------------------------------------------- /config/baselines/dd_ogb/dd_ogb_antM_Gi_Navi_o2d_noPad_h880_ts512.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 880 35 | tot_horizon = sm_horizon 36 | time_dim = 96 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-giant-navigate-v0", 41 | 42 | 'diffusion': { 43 | 'config_fn': '', 44 | 45 | 'sm_horizon': sm_horizon, 46 | 'tot_horizon': tot_horizon, 47 | 48 | 49 | ## 50 | ## cnn model 51 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 52 | 'base_dim': 128, 53 | 'dim_mults': (1, 2, 4, 8), 54 | 'time_dim': time_dim, 55 | 'network_config': dict(t_seq_encoder_type='mlp', 56 | cat_t_w=True, 57 | resblock_ksize=5, 58 | energy_mode=False, 59 | time_mlp_config=3, 60 | ### 61 | inpaint_token_dim=32, 62 | inpaint_token_type='const', 63 | ), 64 | 65 | ## sm dfu model 66 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 67 | 68 | 'n_diffusion_steps': 512, 69 | 'action_weight': 1, 70 | 'loss_weights': None, 71 | 'loss_discount': 1, 72 | 'predict_epsilon': False, ## 73 | 'diff_config': dict( 74 | infer_deno_type='same', 75 | obs_manual_loss_weights={}, 76 | w_loss_type='all', 77 | is_direct_train=True, 78 | ## 79 | ), 80 | 81 | 82 | # 'trainer_cls': 'ogb_task.ogb_maze_v1.OgB_Stgl_Sml_Trainer_v1', 83 | 'trainer_dict': dict(), 84 | 85 | 86 | 'renderer': 'guides.Maze2dRenderer_V2', 87 | 88 | ## dataset 89 | 'loader': 'datasets.ogb_dset.OgB_SeqDataset_V2', 90 | 'termination_penalty': None, 91 | 'normalizer': 'LimitsNormalizer', 92 | 'preprocess_fns': [], 93 | 'clip_denoised': True, 94 | 'use_padding': False, ## True 95 | 'max_path_length': 2200, ## 300 96 | 'dataset_config': dict( 97 | obs_select_dim=(0,1), #### 98 | # obs_select_dim=list(range(29)), #### 99 | dset_type='ogb', 100 | ### 101 | # pad_option_2='buf', 102 | # pad_type='first', 103 | # extra_pad=64, ## 104 | ), 105 | 106 | ## serialization 107 | 'logbase': 'logs', 108 | 'prefix': 'diffusion/', 109 | 'exp_name': watch(diffusion_args_to_watch), 110 | 111 | ## training 112 | 'n_steps_per_epoch': 10000, 113 | 'loss_type': 'l2_inv_v3', 114 | 'n_train_steps': 2e6, 115 | 116 | 'batch_size': 128, 117 | 'learning_rate': 2e-4, 118 | 'gradient_accumulate_every': 1, 119 | 'ema_decay': 0.995, 120 | 'save_freq': 4000, 121 | 'sample_freq': 8000, 122 | 'n_saves': 5, 123 | 124 | 'n_reference': 40, 125 | 'n_samples': 10, 126 | 127 | 'device': 'cuda', 128 | }, 129 | 130 | 'plan': { 131 | 'config_fn': '', 132 | 133 | 'batch_size': 1, 134 | 'device': 'cuda', 135 | 136 | ## diffusion model 137 | 'horizon': tot_horizon, 138 | 'n_diffusion_steps': 512, 139 | 'normalizer': 'LimitsNormalizer', 140 | 141 | ## serialization 142 | 'vis_freq': 10, 143 | 'logbase': 'logs', 144 | 'prefix': 'plans/release', 145 | 'exp_name': watch(plan_args_to_watch), 146 | 'suffix': '0', 147 | 148 | 'conditional': False, 149 | 150 | ## loading 151 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 152 | 'diffusion_epoch': 'latest', 153 | }, 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /config/baselines/dd_ogb/dd_ogb_antM_Gi_o2d_PadBuf_Ft64_h160_ts512.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 160 35 | tot_horizon = sm_horizon 36 | time_dim = 96 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-giant-stitch-v0", 41 | 42 | 'diffusion': { 43 | 'config_fn': '', 44 | 45 | 'sm_horizon': sm_horizon, 46 | 'tot_horizon': tot_horizon, 47 | 48 | 49 | ## 50 | ## cnn model 51 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 52 | 'base_dim': 128, 53 | 'dim_mults': (1, 2, 4, 8), 54 | 'time_dim': time_dim, 55 | 'network_config': dict(t_seq_encoder_type='mlp', 56 | cat_t_w=True, 57 | resblock_ksize=5, 58 | energy_mode=False, 59 | time_mlp_config=3, 60 | ### 61 | inpaint_token_dim=32, 62 | inpaint_token_type='const', 63 | ), 64 | 65 | ## sm dfu model 66 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 67 | 68 | 'n_diffusion_steps': 512, 69 | 'action_weight': 1, 70 | 'loss_weights': None, 71 | 'loss_discount': 1, 72 | 'predict_epsilon': False, ## 73 | 'diff_config': dict( 74 | infer_deno_type='same', 75 | obs_manual_loss_weights={}, 76 | w_loss_type='all', 77 | is_direct_train=True, 78 | ## 79 | ), 80 | 81 | 82 | # 'trainer_cls': 'ogb_task.ogb_maze_v1.OgB_Stgl_Sml_Trainer_v1', 83 | 'trainer_dict': dict(), 84 | 85 | 86 | 'renderer': 'guides.Maze2dRenderer_V2', 87 | 88 | ## dataset 89 | 'loader': 'datasets.ogb_dset.OgB_SeqDataset_V2', 90 | 'termination_penalty': None, 91 | 'normalizer': 'LimitsNormalizer', 92 | 'preprocess_fns': [], 93 | 'clip_denoised': True, 94 | 'use_padding': True, 95 | 'max_path_length': 300, 96 | # 'max_path_length': 2200, 97 | 'dataset_config': dict( 98 | obs_select_dim=(0,1), #### 99 | dset_type='ogb', 100 | ### 101 | pad_option_2='buf', 102 | pad_type='first', 103 | extra_pad=64, ## 104 | ), 105 | 106 | ## serialization 107 | 'logbase': 'logs', 108 | 'prefix': 'diffusion/', 109 | 'exp_name': watch(diffusion_args_to_watch), 110 | 111 | ## training 112 | 'n_steps_per_epoch': 10000, 113 | 'loss_type': 'l2_inv_v3', 114 | 'n_train_steps': 2e6, 115 | 116 | 'batch_size': 128, 117 | 'learning_rate': 2e-4, 118 | 'gradient_accumulate_every': 1, 119 | 'ema_decay': 0.995, 120 | 'save_freq': 4000, 121 | 'sample_freq': 8000, 122 | 'n_saves': 5, 123 | 124 | 'n_reference': 40, 125 | 'n_samples': 10, 126 | 127 | 'device': 'cuda', 128 | }, 129 | 130 | 'plan': { 131 | 'config_fn': '', 132 | 133 | 'batch_size': 1, 134 | 'device': 'cuda', 135 | 136 | ## diffusion model 137 | 'horizon': tot_horizon, 138 | 'n_diffusion_steps': 512, 139 | 'normalizer': 'LimitsNormalizer', 140 | 141 | ## serialization 142 | 'vis_freq': 10, 143 | 'logbase': 'logs', 144 | 'prefix': 'plans/release', 145 | 'exp_name': watch(plan_args_to_watch), 146 | 'suffix': '0', 147 | 148 | 'conditional': False, 149 | 150 | ## loading 151 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 152 | 'diffusion_epoch': 'latest', 153 | }, 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /config/baselines/dd_ogb/dd_ogb_pntM_Gi_o2d_PadBuf_Ft64_h160_ts512.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 160 35 | tot_horizon = sm_horizon 36 | time_dim = 96 37 | 38 | 39 | base = { 40 | 'dataset': "pointmaze-giant-stitch-v0", 41 | 42 | 'diffusion': { 43 | 'config_fn': '', 44 | 45 | 'sm_horizon': sm_horizon, 46 | 'tot_horizon': tot_horizon, 47 | 48 | 49 | ## 50 | ## cnn model 51 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 52 | 'base_dim': 128, 53 | 'dim_mults': (1, 2, 4, 8), 54 | 'time_dim': time_dim, 55 | 'network_config': dict(t_seq_encoder_type='mlp', 56 | cat_t_w=True, 57 | resblock_ksize=5, 58 | energy_mode=False, 59 | time_mlp_config=3, 60 | ### 61 | inpaint_token_dim=32, 62 | inpaint_token_type='const', 63 | ), 64 | 65 | ## sm dfu model 66 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 67 | 68 | 'n_diffusion_steps': 512, 69 | 'action_weight': 1, 70 | 'loss_weights': None, 71 | 'loss_discount': 1, 72 | 'predict_epsilon': False, ## 73 | 'diff_config': dict( 74 | infer_deno_type='same', 75 | obs_manual_loss_weights={}, 76 | w_loss_type='all', 77 | is_direct_train=True, 78 | ## 79 | ), 80 | 81 | 82 | # 'trainer_cls': 'ogb_task.ogb_maze_v1.OgB_Stgl_Sml_Trainer_v1', 83 | 'trainer_dict': dict(), 84 | 85 | 86 | 'renderer': 'guides.Maze2dRenderer_V2', 87 | 88 | ## dataset 89 | 'loader': 'datasets.ogb_dset.OgB_SeqDataset_V2', 90 | 'termination_penalty': None, 91 | 'normalizer': 'LimitsNormalizer', 92 | 'preprocess_fns': [], 93 | 'clip_denoised': True, 94 | 'use_padding': True, 95 | 'max_path_length': 300, 96 | # 'max_path_length': 2200, 97 | 'dataset_config': dict( 98 | obs_select_dim=(0,1), #### 99 | dset_type='ogb', 100 | ### 101 | pad_option_2='buf', 102 | pad_type='first', 103 | extra_pad=64, ## 104 | ), 105 | 106 | ## serialization 107 | 'logbase': 'logs', 108 | 'prefix': 'diffusion/', 109 | 'exp_name': watch(diffusion_args_to_watch), 110 | 111 | ## training 112 | 'n_steps_per_epoch': 10000, 113 | 'loss_type': 'l2_inv_v3', 114 | 'n_train_steps': 2e6, 115 | 116 | 'batch_size': 128, 117 | 'learning_rate': 2e-4, 118 | 'gradient_accumulate_every': 1, 119 | 'ema_decay': 0.995, 120 | 'save_freq': 4000, 121 | 'sample_freq': 8000, 122 | 'n_saves': 5, 123 | 124 | 'n_reference': 40, 125 | 'n_samples': 10, 126 | 127 | 'device': 'cuda', 128 | }, 129 | 130 | 'plan': { 131 | 'config_fn': '', 132 | 133 | 'batch_size': 1, 134 | 'device': 'cuda', 135 | 136 | ## diffusion model 137 | 'horizon': tot_horizon, 138 | 'n_diffusion_steps': 512, 139 | 'normalizer': 'LimitsNormalizer', 140 | 141 | ## serialization 142 | 'vis_freq': 10, 143 | 'logbase': 'logs', 144 | 'prefix': 'plans/release', 145 | 'exp_name': watch(plan_args_to_watch), 146 | 'suffix': '0', 147 | 148 | 'conditional': False, 149 | 150 | ## loading 151 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 152 | 'diffusion_epoch': 'latest', 153 | }, 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /config/baselines/dd_ogb/dd_ogb_pntM_Lg_o2d_PadBuf_Ft64_h160_ts512.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 160 35 | tot_horizon = sm_horizon 36 | time_dim = 96 37 | 38 | 39 | base = { 40 | 'dataset': "pointmaze-large-stitch-v0", 41 | 42 | 'diffusion': { 43 | 'config_fn': '', 44 | 45 | 'sm_horizon': sm_horizon, 46 | 'tot_horizon': tot_horizon, 47 | 48 | 49 | ## 50 | ## cnn model 51 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 52 | 'base_dim': 128, 53 | 'dim_mults': (1, 2, 4, 8), 54 | 'time_dim': time_dim, 55 | 'network_config': dict(t_seq_encoder_type='mlp', 56 | cat_t_w=True, 57 | resblock_ksize=5, 58 | energy_mode=False, 59 | time_mlp_config=3, 60 | ### 61 | inpaint_token_dim=32, 62 | inpaint_token_type='const', 63 | ), 64 | 65 | ## sm dfu model 66 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 67 | 68 | 'n_diffusion_steps': 512, 69 | 'action_weight': 1, 70 | 'loss_weights': None, 71 | 'loss_discount': 1, 72 | 'predict_epsilon': False, ## 73 | 'diff_config': dict( 74 | infer_deno_type='same', 75 | obs_manual_loss_weights={}, 76 | w_loss_type='all', 77 | is_direct_train=True, 78 | ## 79 | ), 80 | 81 | 82 | # 'trainer_cls': 'ogb_task.ogb_maze_v1.OgB_Stgl_Sml_Trainer_v1', 83 | 'trainer_dict': dict(), 84 | 85 | 86 | 'renderer': 'guides.Maze2dRenderer_V2', 87 | 88 | ## dataset 89 | 'loader': 'datasets.ogb_dset.OgB_SeqDataset_V2', 90 | 'termination_penalty': None, 91 | 'normalizer': 'LimitsNormalizer', 92 | 'preprocess_fns': [], 93 | 'clip_denoised': True, 94 | 'use_padding': True, 95 | 'max_path_length': 300, 96 | # 'max_path_length': 2200, 97 | 'dataset_config': dict( 98 | obs_select_dim=(0,1), #### 99 | dset_type='ogb', 100 | ### 101 | pad_option_2='buf', 102 | pad_type='first', 103 | extra_pad=64, ## 104 | ), 105 | 106 | ## serialization 107 | 'logbase': 'logs', 108 | 'prefix': 'diffusion/', 109 | 'exp_name': watch(diffusion_args_to_watch), 110 | 111 | ## training 112 | 'n_steps_per_epoch': 10000, 113 | 'loss_type': 'l2_inv_v3', 114 | 'n_train_steps': 2e6, 115 | 116 | 'batch_size': 128, 117 | 'learning_rate': 2e-4, 118 | 'gradient_accumulate_every': 1, 119 | 'ema_decay': 0.995, 120 | 'save_freq': 4000, 121 | 'sample_freq': 8000, 122 | 'n_saves': 5, 123 | 124 | 'n_reference': 40, 125 | 'n_samples': 10, 126 | 127 | 'device': 'cuda', 128 | }, 129 | 130 | 'plan': { 131 | 'config_fn': '', 132 | 133 | 'batch_size': 1, 134 | 'device': 'cuda', 135 | 136 | ## diffusion model 137 | 'horizon': tot_horizon, 138 | 'n_diffusion_steps': 512, 139 | 'normalizer': 'LimitsNormalizer', 140 | 141 | ## serialization 142 | 'vis_freq': 10, 143 | 'logbase': 'logs', 144 | 'prefix': 'plans/release', 145 | 'exp_name': watch(plan_args_to_watch), 146 | 'suffix': '0', 147 | 148 | 'conditional': False, 149 | 150 | ## loading 151 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 152 | 'diffusion_epoch': 'latest', 153 | }, 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /config/baselines/dd_ogb/dd_ogb_pntM_Me_o2d_PadBuf_Ft64_h160_ts512.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | sm_horizon = 160 35 | tot_horizon = sm_horizon 36 | time_dim = 96 37 | 38 | 39 | base = { 40 | 'dataset': "pointmaze-medium-stitch-v0", 41 | 42 | 'diffusion': { 43 | 'config_fn': '', 44 | 45 | 'sm_horizon': sm_horizon, 46 | 'tot_horizon': tot_horizon, 47 | 48 | 49 | ## 50 | ## cnn model 51 | 'model': 'baselines.dd_maze.dd_maze_temporal_v1.Unet1D_DD_Maze_V1', 52 | 'base_dim': 128, 53 | 'dim_mults': (1, 2, 4, 8), 54 | 'time_dim': time_dim, 55 | 'network_config': dict(t_seq_encoder_type='mlp', 56 | cat_t_w=True, 57 | resblock_ksize=5, 58 | energy_mode=False, 59 | time_mlp_config=3, 60 | ### 61 | inpaint_token_dim=32, 62 | inpaint_token_type='const', 63 | ), 64 | 65 | ## sm dfu model 66 | 'dfu_model': 'baselines.dd_maze.dd_maze_diffusion_v1.DD_Maze_GauDiffusion_InvDyn_V1', 67 | 68 | 'n_diffusion_steps': 512, 69 | 'action_weight': 1, 70 | 'loss_weights': None, 71 | 'loss_discount': 1, 72 | 'predict_epsilon': False, ## 73 | 'diff_config': dict( 74 | infer_deno_type='same', 75 | obs_manual_loss_weights={}, 76 | w_loss_type='all', 77 | is_direct_train=True, 78 | ## 79 | ), 80 | 81 | 82 | # 'trainer_cls': 'ogb_task.ogb_maze_v1.OgB_Stgl_Sml_Trainer_v1', 83 | 'trainer_dict': dict(), 84 | 85 | 86 | 'renderer': 'guides.Maze2dRenderer_V2', 87 | 88 | ## dataset 89 | 'loader': 'datasets.ogb_dset.OgB_SeqDataset_V2', 90 | 'termination_penalty': None, 91 | 'normalizer': 'LimitsNormalizer', 92 | 'preprocess_fns': [], 93 | 'clip_denoised': True, 94 | 'use_padding': True, 95 | 'max_path_length': 300, 96 | # 'max_path_length': 2200, 97 | 'dataset_config': dict( 98 | obs_select_dim=(0,1), #### 99 | dset_type='ogb', 100 | ### 101 | pad_option_2='buf', 102 | pad_type='first', 103 | extra_pad=64, ## 104 | ), 105 | 106 | ## serialization 107 | 'logbase': 'logs', 108 | 'prefix': 'diffusion/', 109 | 'exp_name': watch(diffusion_args_to_watch), 110 | 111 | ## training 112 | 'n_steps_per_epoch': 10000, 113 | 'loss_type': 'l2_inv_v3', 114 | 'n_train_steps': 2e6, 115 | 116 | 'batch_size': 128, 117 | 'learning_rate': 2e-4, 118 | 'gradient_accumulate_every': 1, 119 | 'ema_decay': 0.995, 120 | 'save_freq': 4000, 121 | 'sample_freq': 8000, 122 | 'n_saves': 5, 123 | 124 | 'n_reference': 40, 125 | 'n_samples': 10, 126 | 127 | 'device': 'cuda', 128 | }, 129 | 130 | 'plan': { 131 | 'config_fn': '', 132 | 133 | 'batch_size': 1, 134 | 'device': 'cuda', 135 | 136 | ## diffusion model 137 | 'horizon': tot_horizon, 138 | 'n_diffusion_steps': 512, 139 | 'normalizer': 'LimitsNormalizer', 140 | 141 | ## serialization 142 | 'vis_freq': 10, 143 | 'logbase': 'logs', 144 | 'prefix': 'plans/release', 145 | 'exp_name': watch(plan_args_to_watch), 146 | 'suffix': '0', 147 | 148 | 'conditional': False, 149 | 150 | ## loading 151 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 152 | 'diffusion_epoch': 'latest', 153 | }, 154 | 155 | } 156 | 157 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g15d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-giant-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(15)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g29d_invdyn_h12_dm5.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-giant-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(29)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512, 256], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g2d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-giant-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g15d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-large-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(15)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-large-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(29)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g2d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-large-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Me_o29d_g15d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(15)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 40000, 102 | 'n_saves': 10, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Me_o29d_g29d_invdyn_h12_dm5.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(29)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512, 256], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 40000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antM_Me_o29d_g2d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 220, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 4000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antMexpl_Lg_o29d_g2d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-large-explore-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 550, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 40000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant/og_antMexpl_Me_o29d_g2d_invdyn_h12.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 12 36 | obs_dim = 29 37 | 38 | 39 | base = { 40 | 'dataset': "antmaze-medium-explore-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=False, 60 | ), 61 | 62 | ### 63 | 'trainer_dict': dict(), 64 | 65 | 66 | 67 | 'renderer': 'guides.Maze2dRenderer_V2', 68 | 69 | ## dataset 70 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 71 | 'termination_penalty': None, 72 | 'normalizer': 'LimitsNormalizer', 73 | 'preprocess_fns': [], 74 | 'clip_denoised': True, 75 | 'use_padding': True, 76 | 'max_path_length': 520, 77 | 'max_n_episodes': 10000, #### 78 | 'dataset_config': dict( 79 | obs_select_dim=tuple(range(obs_dim)), #### 80 | dset_type='ogb', 81 | ), 82 | 83 | 84 | ## serialization 85 | 'logbase': 'logs', 86 | 'prefix': 'diffusion/', 87 | 'exp_name': watch(diffusion_args_to_watch), 88 | 89 | 90 | ## training 91 | 'n_steps_per_epoch': 10000, 92 | 'loss_type': 'l2_inv_v3', 93 | 'n_train_steps': 2e6, 94 | 95 | 'ema_decay': 0.995, 96 | 'batch_size': 1024, 97 | 'learning_rate': 1e-4, 98 | 'gradient_accumulate_every': 1, 99 | 100 | 'sample_freq': 4000, 101 | 'save_freq': 40000, 102 | 'n_saves': 5, 103 | 104 | 'n_reference': 20, ## 105 | 'n_samples': 8, ## 106 | 107 | 'device': 'cuda', 108 | }, 109 | 110 | 'plan': { 111 | 'config_fn': '', 112 | 113 | 'batch_size': 1, 114 | 'device': 'cuda', 115 | 116 | ## diffusion model 117 | 'horizon': tot_horizon, 118 | 'n_diffusion_steps': 512, 119 | 'normalizer': 'LimitsNormalizer', 120 | 121 | ## serialization 122 | 'vis_freq': 10, 123 | 'logbase': 'logs', 124 | 'prefix': 'plans/release', 125 | 'exp_name': watch(plan_args_to_watch), 126 | 'suffix': '0', 127 | 128 | 'conditional': False, 129 | 130 | ## loading 131 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 132 | 'diffusion_epoch': 'latest', 133 | }, 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Ar_o42d_g17d_invdyn_h120_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 120 36 | obs_dim = 42 37 | 38 | 39 | base = { 40 | 'dataset': "antsoccer-arena-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(17)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 400, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 10, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Ar_o42d_g4d_invdyn_h120_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 120 36 | obs_dim = 42 37 | 38 | 39 | base = { 40 | 'dataset': "antsoccer-arena-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': (0,1,15,16), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 512, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 350, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 10, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Me_o42d_g17d_invdyn_h100_dm4_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 100 36 | obs_dim = 42 37 | 38 | 39 | base = { 40 | 'dataset': "antsoccer-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(17)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 700, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 10, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Me_o42d_g4d_invdyn_h120_dm4_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 120 36 | obs_dim = 42 37 | 38 | 39 | base = { 40 | 'dataset': "antsoccer-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': (0,1,15,16), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 700, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 10, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_hum/og_humM_Gi_o69d_g2d_invdyn_h80_dm5_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 80 36 | obs_dim = 69 37 | 38 | 39 | base = { 40 | 'dataset': "humanoidmaze-giant-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512, 256], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 550, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 5, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_hum/og_humM_Lg_o69d_g2d_invdyn_h80_dm5_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 80 36 | obs_dim = 69 37 | 38 | 39 | base = { 40 | 'dataset': "humanoidmaze-large-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512, 256], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 550, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 5, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /config/ogb_invdyn/og_inv_hum/og_humM_Me_o69d_g2d_invdyn_h80_dm5_dout02.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import os.path as osp 3 | 4 | from diffuser.utils import watch 5 | 6 | #------------------------ base ------------------------# 7 | 8 | ## automatically make experiment names for planning 9 | ## by labelling folders with these args 10 | config_fn = osp.splitext(osp.basename(__file__))[0] 11 | 12 | diffusion_args_to_watch = [ 13 | ('prefix', ''), 14 | ('config_fn', config_fn), 15 | ('horizon', 'H'), 16 | ('n_diffusion_steps', 'T'), 17 | ] 18 | 19 | 20 | plan_args_to_watch = [ 21 | ('prefix', ''), 22 | ('config_fn', config_fn), 23 | ## 24 | ('horizon', 'H'), 25 | ('n_diffusion_steps', 'T'), 26 | ('value_horizon', 'V'), 27 | ('discount', 'd'), 28 | ('normalizer', ''), 29 | ('batch_size', 'b'), 30 | ## 31 | ('conditional', 'cond'), 32 | ] 33 | 34 | 35 | tot_horizon = 80 36 | obs_dim = 69 37 | 38 | 39 | base = { 40 | 'dataset': "humanoidmaze-medium-stitch-v0", 41 | 42 | 43 | 'diffusion': { 44 | 'config_fn': '', 45 | 46 | 'tot_horizon': tot_horizon, 47 | 'goal_sel_idxs': tuple(range(2)), 48 | 49 | ## 50 | ## inv model 51 | 'model': 'ogb_task.og_inv_dyn.MLP_InvDyn_OgB_V3', 52 | 'inv_m_config': dict( 53 | hidden_dims=[512, 1024, 1024, 512, 256], 54 | final_fc_init_scale=1e-2, 55 | is_out_dist=False, 56 | ), 57 | 'act_net_config': dict( 58 | act_f='gelu', 59 | use_dpout=True, 60 | prob_dpout=0.2, 61 | ), 62 | 63 | ### 64 | 'trainer_dict': dict(), 65 | 66 | 67 | 68 | 'renderer': 'guides.Maze2dRenderer_V2', 69 | 70 | ## dataset 71 | 'loader': 'datasets.ogb_dset.OgB_InvDyn_SeqDataset_V1', 72 | 'termination_penalty': None, 73 | 'normalizer': 'LimitsNormalizer', 74 | 'preprocess_fns': [], 75 | 'clip_denoised': True, 76 | 'use_padding': True, 77 | 'max_path_length': 550, 78 | 'max_n_episodes': 10000, #### 79 | 'dataset_config': dict( 80 | obs_select_dim=tuple(range(obs_dim)), #### 81 | dset_type='ogb', 82 | ), 83 | 84 | 85 | ## serialization 86 | 'logbase': 'logs', 87 | 'prefix': 'diffusion/', 88 | 'exp_name': watch(diffusion_args_to_watch), 89 | 90 | 91 | ## training 92 | 'n_steps_per_epoch': 10000, 93 | 'loss_type': 'l2_inv_v3', 94 | 'n_train_steps': 2e6, 95 | 96 | 'ema_decay': 0.995, 97 | 'batch_size': 1024, 98 | 'learning_rate': 1e-4, 99 | 'gradient_accumulate_every': 1, 100 | 101 | 'sample_freq': 4000, 102 | 'save_freq': 40000, 103 | 'n_saves': 5, 104 | 105 | 'n_reference': 20, ## 106 | 'n_samples': 8, ## 107 | 108 | 'device': 'cuda', 109 | }, 110 | 111 | 'plan': { 112 | 'config_fn': '', 113 | 114 | 'batch_size': 1, 115 | 'device': 'cuda', 116 | 117 | ## diffusion model 118 | 'horizon': tot_horizon, 119 | 'n_diffusion_steps': 512, 120 | 'normalizer': 'LimitsNormalizer', 121 | 122 | ## serialization 123 | 'vis_freq': 10, 124 | 'logbase': 'logs', 125 | 'prefix': 'plans/release', 126 | 'exp_name': watch(plan_args_to_watch), 127 | 'suffix': '0', 128 | 129 | 'conditional': False, 130 | 131 | ## loading 132 | 'diffusion_loadpath': 'f:diffusion/H{horizon}_T{n_diffusion_steps}', 133 | 'diffusion_epoch': 'latest', 134 | }, 135 | 136 | } 137 | 138 | -------------------------------------------------------------------------------- /data/m2d/ev_probs/ben/ben_maze2d_Me_ev_prob_numEp10_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/ben/ben_maze2d_Me_ev_prob_numEp10_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/ben/ben_maze2d_Umz_ev_prob_numEp10_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/ben/ben_maze2d_Umz_ev_prob_numEp10_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/ben/ben_maze2d_lg_ev_prob_luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/ben/ben_maze2d_lg_ev_prob_luotest.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/ben/ben_maze2d_lg_ev_prob_numEp10_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/ben/ben_maze2d_lg_ev_prob_numEp10_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/maze2d_lg_ev_prob_bt2way_nppp3.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/maze2d_lg_ev_prob_bt2way_nppp3.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/maze2d_lg_ev_prob_bt2way_nppp3_rprange02.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/maze2d_lg_ev_prob_bt2way_nppp3_rprange02.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/maze2d_lg_ev_prob_luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/maze2d_lg_ev_prob_luotest.hdf5 -------------------------------------------------------------------------------- /data/m2d/ev_probs/maze2d_lg_ev_prob_luotest_2.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/ev_probs/maze2d_lg_ev_prob_luotest_2.hdf5 -------------------------------------------------------------------------------- /data/m2d/maze2d-large-sparse-v1-luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/maze2d-large-sparse-v1-luotest.hdf5 -------------------------------------------------------------------------------- /data/m2d/maze2d-medium-sparse-v1-luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/maze2d-medium-sparse-v1-luotest.hdf5 -------------------------------------------------------------------------------- /data/m2d/maze2d-umaze-sparse-v1-luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/m2d/maze2d-umaze-sparse-v1-luotest.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/antmaze-giant-stitch-v0-luotest.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/antmaze-giant-stitch-v0-luotest.npz -------------------------------------------------------------------------------- /data/ogb_maze/antmaze-large-stitch-v0-luotest.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/antmaze-large-stitch-v0-luotest.npz -------------------------------------------------------------------------------- /data/ogb_maze/antmaze-medium-explore-v0-luotest.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/antmaze-medium-explore-v0-luotest.npz -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Gi_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Gi_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Gi_ev_prob_numEp20_eSdSt0_full_jnt.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Gi_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt_same2_Jan11.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Lg_ev_prob_numEp20_eSdSt0_full_jnt_same2_Jan11.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Me_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Me_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_Me_ev_prob_numEp20_eSdSt0_full_jnt.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_Me_ev_prob_numEp20_eSdSt0_full_jnt.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_HumM_full_jnt_luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_HumM_full_jnt_luotest.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Gi_Navi_ev_prob_numEp20_eSdSt0_preAct5.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Gi_Navi_ev_prob_numEp20_eSdSt0_preAct5.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_luotest.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_luotest.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Gi_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_LgExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Lg_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Lg_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Lg_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Lg_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_MeExpl_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Me_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Me_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antM_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antM_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct10.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Ar_ev_prob_numEp20_eSdSt0_preAct10.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct1.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct10.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_antSoc_Me_ev_prob_numEp20_eSdSt0_preAct10.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_pointM_Gi_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_pointM_Gi_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_pointM_Lg_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_pointM_Lg_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /data/ogb_maze/ev_probs/ogb_pointM_Me_ev_prob_numEp20_eSdSt0.hdf5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/data/ogb_maze/ev_probs/ogb_pointM_Me_ev_prob_numEp20_eSdSt0.hdf5 -------------------------------------------------------------------------------- /diffuser/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/diffuser/__init__.py -------------------------------------------------------------------------------- /diffuser/baselines/dd_maze/dd_maze_policy_v1.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch, einops, pdb, time 3 | import diffuser.utils as utils 4 | from diffuser.guides.comp.cd_sml_policies import Trajectories_invdyn 5 | 6 | # from diffuser.models.cd_stgl_sml_dfu import Stgl_Sml_GauDiffusion_InvDyn_V1 7 | from diffuser.baselines.dd_maze.dd_maze_diffusion_v1 import DD_Maze_GauDiffusion_InvDyn_V1 8 | from diffuser.models.helpers import apply_conditioning 9 | from diffuser.models.cd_stgl_sml_dfu.stgl_sml_policy_v1 import Stgl_Sml_Ev_Pred 10 | 11 | 12 | class DD_Maze_Policy_V1: 13 | 14 | def __init__(self, diffusion_model, 15 | normalizer, 16 | pol_config, 17 | ): 18 | """ 19 | pick_type: how to pick from top_n 20 | """ 21 | self.diffusion_model: DD_Maze_GauDiffusion_InvDyn_V1 = diffusion_model 22 | self.diffusion_model.eval() ## NOTE: must be the ema one 23 | self.normalizer = normalizer 24 | self.action_dim = normalizer.action_dim 25 | self.pl_hzn = pol_config.get('ev_pl_hzn', diffusion_model.horizon,) 26 | ## if not set, cause error 27 | self.diffusion_model.horizon = self.pl_hzn 28 | # pdb.set_trace() 29 | self.ncp_pred_time_list = [] 30 | self.return_diffusion = False 31 | 32 | 33 | 34 | @property 35 | def device(self): 36 | parameters = list(self.diffusion_model.parameters()) 37 | return parameters[0].device 38 | 39 | 40 | 41 | 42 | def gen_cond_stgl_parallel(self, g_cond, debug=False, b_s=1): 43 | """ 44 | st_gl: *not normed*, np2d [2, ndim], e.g., [ [st], [end] ], [[2,1], [3,4]], 45 | b_s: batch_size, 10-20+ 46 | """ 47 | 48 | hzn = self.diffusion_model.horizon 49 | o_dim = self.diffusion_model.observation_dim ## TODO: obs_dim only? 50 | # c_shape = [b_s, hzn, o_dim] ## e.g.,(20,160,2) 51 | 52 | 53 | st_gl = g_cond['st_gl'] 54 | st_gl = torch.tensor(self.normalizer.normalize(st_gl, 'observations')) 55 | 56 | # pdb.set_trace() ## Oct 24 TODO: From Here, check the format of repeat 57 | ## shape: 2, n_probs, dim 58 | assert st_gl.ndim == 3 and st_gl.shape[0] == 2 59 | n_probs = st_gl.shape[1] 60 | 61 | ## NOTE: in Decision Diffuser Baseline, ignore the input b_s 62 | b_s = 1 63 | 64 | 65 | ## TODO: Oct 25: 14:08 pm check c_shape 66 | # c_shape = [b_s*n_probs, hzn, o_dim] ## e.g.,(b_s*n_p: 20*10=200,160,2) 67 | 68 | ## 0: tensor (n_parallel_probs,2); hzn-1: same 69 | ## make sure return is not a view 70 | stgl_cond = { 71 | 0: einops.repeat(st_gl[0,:,:], 'n_p d -> (n_p rr) d', rr=b_s).clone(), 72 | hzn-1: einops.repeat(st_gl[1,:,:], 'n_p d -> (n_p rr) d', rr=b_s).clone(), 73 | } 74 | 75 | # pdb.set_trace() ## check if repeat is correct 76 | 77 | g_cond = dict(stgl_cond=stgl_cond) 78 | 79 | sample = self.diffusion_model.conditional_sample(g_cond, horizon=self.pl_hzn, verbose=False, 80 | return_diffusion=self.return_diffusion) 81 | if self.return_diffusion: 82 | self.dfu_proc_all = sample[1] 83 | sample = sample[0] 84 | 85 | ## NOTE: NEW inpaint start and goal again 86 | sample = apply_conditioning(sample, stgl_cond, 0) # start from dim 0, different from diffuser 87 | 88 | sample = utils.to_np(sample) 89 | 90 | # pdb.set_trace() 91 | 92 | normed_observations = sample[:, :, 0:] ## act_dim 93 | pred_obs_trajs_un = self.normalizer.unnormalize(normed_observations, 'observations') 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | out_list = [] ## store output for each problems 102 | pick_traj_acc = [] 103 | 104 | # pdb.set_trace() 105 | assert len(pred_obs_trajs_un) == n_probs 106 | 107 | for i_pb in range(n_probs): 108 | 109 | ###### 110 | ## an unnormed H,D np traj 111 | pick_traj = pred_obs_trajs_un[i_pb] 112 | out = Stgl_Sml_Ev_Pred(pick_traj, None, None) 113 | 114 | out_list.append(out) 115 | pick_traj_acc.append(out.pick_traj) 116 | 117 | 118 | 119 | ## 120 | # pdb.set_trace() 121 | ## return a list of out and pick_traj 122 | return out_list, pick_traj_acc 123 | 124 | 125 | 126 | 127 | 128 | def gen_cond_stgl(self, g_cond, debug=False, b_s=1): 129 | 130 | cur_time = time.time() 131 | out_list, pick_traj_acc = self.gen_cond_stgl_parallel(g_cond, debug, b_s,) 132 | 133 | # pdb.set_trace() ## TODO: Feb 15 20:20 start from test time the time on L40s 134 | 135 | assert len(out_list) == 1 136 | 137 | self.ncp_pred_time_list.append( [1, time.time() - cur_time] ) ## unit: sec 138 | 139 | return out_list[0] 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /diffuser/baselines/dd_maze/plan_dd_bline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ev-hi 4 | #SBATCH --output=trash/slurm/plan_StglSml/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=4 8 | #SBATCH --exclude="clippy,voltron, claptrap" 9 | ###SBATCH --partition="rl2-lab" 10 | 11 | ##SBATCH --gres=gpu:a40:1 12 | #SBATCH --gres=gpu:rtx_6000:1 13 | ## 14 | #SBATCH --qos="debug" 15 | #SBATCH --time=5:00:00 16 | ## 17 | ###SBATCH --qos="debug" 18 | ###SBATCH --time=48:00:00 19 | 20 | source ~/.bashrc 21 | source activate hi_diffuser 22 | cd /coc/flash7/yluo470/robot2024/hi_diffuser/ 23 | echo $(hostname) 24 | 25 | #### Jan 18 26 | #### Ben 27 | conda activate hi_diffuser_ben 28 | config="" 29 | config="config/baselines/ben/dd_bline_m2d_Umz_BenPadex40FL.py" ## hzn=136 30 | 31 | # config="config/baselines/ben/dd_bline_m2d_Me_BenPadex68FL_h144.py" 32 | # config="config/baselines/ben/dd_bline_m2d_Lg_BenPadex60FL_h192.py" 33 | 34 | 35 | { 36 | 37 | # PYTHONBREAKPOINT=0 \ ## -B 38 | PYTHONDONTWRITEBYTECODE=1 \ 39 | CUDA_VISIBLE_DEVICES=${1:-0} \ 40 | python diffuser/baselines/dd_maze/plan_dd_bline.py \ 41 | --config $config \ 42 | --plan_n_ep $2 \ 43 | --pl_seeds ${3:--1} \ 44 | 45 | 46 | exit 0 47 | 48 | } -------------------------------------------------------------------------------- /diffuser/baselines/dd_maze/train_dd_bline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-hi-dd-bl 4 | #SBATCH --output=trash/slurm/train_dd_maze_bline/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=6 8 | #SBATCH --exclude="clippy,voltron" 9 | ###SBATCH --partition="rl2-lab" 10 | 11 | #SBATCH --gres=gpu:l40s:1 12 | ##SBATCH --gres=gpu:a40:1 13 | ###SBATCH --gres=gpu:rtx_6000:1 14 | ## 15 | ##SBATCH --qos="long" 16 | ##SBATCH --time=72:00:00 17 | ## 18 | #SBATCH --qos="debug" 19 | #SBATCH --time=48:00:00 20 | 21 | source ~/.bashrc 22 | source activate hi_diffuser 23 | cd /coc/flash7/yluo470/robot2024/hi_diffuser/ 24 | 25 | ## Jan 17 26 | config="config/baselines/ben/dd_bline_m2d_Umz_BenPadex40FL_luotest.py" 27 | # config="config/baselines/ben/dd_bline_m2d_Umz_BenPadex40FL.py" 28 | 29 | # config="config/baselines/ben/dd_bline_m2d_Me_BenPadex68FL_h144.py" 30 | # config="config/baselines/ben/dd_bline_m2d_Lg_BenPadex60FL_h192.py" 31 | 32 | { 33 | 34 | # PYTHONBREAKPOINT=0 \ ## -B 35 | PYTHONDONTWRITEBYTECODE=1 \ 36 | CUDA_VISIBLE_DEVICES=${1:-0} \ 37 | python diffuser/baselines/dd_maze/train_dd_bline.py --config $config \ 38 | 39 | 40 | exit 0 41 | 42 | } -------------------------------------------------------------------------------- /diffuser/baselines/dd_ogb/plan_dd_ogb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | #SBATCH --job-name=script-ev-hi 5 | #SBATCH --output=trash/slurm/plan_OG_DD_Feb15/slurm-%j.out 6 | #SBATCH --nodes=1 7 | #SBATCH --ntasks-per-node=1 8 | #SBATCH --cpus-per-task=4 9 | ### brainiac, 2080: alexa,alexa 10 | #SBATCH --exclude="clippy,voltron,claptrap,alexa,bmo,olivaw,oppy" 11 | 12 | ##SBATCH --partition="rl2-lab" 13 | ##SBATCH --gres=gpu:a40:1 14 | #SBATCH --gres=gpu:l40s:1 15 | ##SBATCH --qos="short" 16 | 17 | ##SBATCH --gres=gpu:rtx_6000:1 18 | ##SBATCH --gres=gpu:a5000:1 19 | 20 | #SBATCH --qos="debug" 21 | #SBATCH --time=16:00:00 22 | 23 | echo $(hostname) 24 | 25 | source ~/.bashrc 26 | source activate compdfu_ogb_release 27 | 28 | ## ============================================ 29 | ## Evaluation Script for Decision Diffuser (DD) 30 | ## ============================================ 31 | 32 | 33 | ## --------- Planning: OGBench PointMaze Stitch 2D Planner ---------- 34 | ## Giant 35 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Gi_o2d_PadBuf_Ft64_h160_ts512.py" 36 | ## Large 37 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Lg_o2d_PadBuf_Ft64_h160_ts512.py" 38 | ## Medium 39 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Me_o2d_PadBuf_Ft64_h160_ts512.py" 40 | 41 | ## --------- Planning: OGBench AntMaze Navigation 2D Planner ---------- 42 | # config="config/baselines/dd_ogb/dd_ogb_antM_Gi_Navi_o2d_noPad_h880_ts512.py" 43 | 44 | ## --------- Planning: OGBench AntMaze Stitch 2D Planner ---------- 45 | config="config/baselines/dd_ogb/dd_ogb_antM_Gi_o2d_PadBuf_Ft64_h160_ts512.py" 46 | 47 | 48 | 49 | { 50 | 51 | EGL_ID=0 52 | 53 | PYTHONDONTWRITEBYTECODE=1 \ 54 | CUDA_VISIBLE_DEVICES=${1:-0} \ 55 | MUJOCO_EGL_DEVICE_ID=$EGL_ID \ 56 | python diffuser/baselines/dd_ogb/plan_dd_ogb.py \ 57 | --config $config \ 58 | --plan_n_ep $2 \ 59 | --pl_seeds ${3:--1} \ 60 | 61 | 62 | exit 0 63 | 64 | } -------------------------------------------------------------------------------- /diffuser/baselines/dd_ogb/train_dd_ogb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ohi 4 | #SBATCH --output=trash/slurm/train_OG_DD_jan3/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=6 8 | #SBATCH --exclude="clippy,voltron,alexa" 9 | ##SBATCH --partition="rl2-lab" 10 | #SBATCH --mem=100G 11 | 12 | ##SBATCH --gres=gpu:rtx_6000:1 13 | #SBATCH --gres=gpu:a40:1 14 | ##SBATCH --gres=gpu:l40s:1 15 | ##SBATCH --gres=gpu:a5000:1 16 | ## 17 | ##SBATCH --qos="long" 18 | ##SBATCH --time=100:00:00 19 | ##SBATCH --time=160:00:00 20 | ## 21 | #SBATCH --qos="debug" 22 | #SBATCH --time=48:00:00 23 | 24 | source ~/.bashrc 25 | source activate compdfu_ogb_release 26 | 27 | ## OGBench AntMaze, to be supported 28 | # config="config/baselines/dd_ogb/dd_ogb_antM_Gi_o2d_PadBuf_Ft64_h160_ts512.py" 29 | config="config/baselines/dd_ogb/dd_ogb_antM_Gi_Navi_o2d_noPad_h880_ts512.py" 30 | 31 | ## OGBench PointMaze 32 | ## giant maze 33 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Gi_o2d_PadBuf_Ft64_h160_ts512.py" 34 | ## large maze 35 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Lg_o2d_PadBuf_Ft64_h160_ts512.py" 36 | ## medium maze 37 | # config="config/baselines/dd_ogb/dd_ogb_pntM_Me_o2d_PadBuf_Ft64_h160_ts512.py" 38 | 39 | { 40 | 41 | echo $(hostname) 42 | 43 | PYTHONDONTWRITEBYTECODE=1 \ 44 | CUDA_VISIBLE_DEVICES=${1:-0} \ 45 | python diffuser/baselines/dd_ogb/train_dd_ogb.py --config $config \ 46 | 47 | 48 | exit 0 49 | 50 | } -------------------------------------------------------------------------------- /diffuser/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | from .sequence import * 2 | from .d4rl import load_environment 3 | from .d4rl import load_env_gym_robo 4 | 5 | import numpy as np 6 | MAZE_Large_Obs_Min = np.array([0.39643136, 0.44179875], dtype=np.float32) 7 | MAZE_Large_Obs_Max = np.array([ 7.2163844, 10.219488 ], dtype=np.float32) 8 | 9 | MAZE_Large_Act_Min = np.array([-1., -1.], dtype=np.float32) 10 | MAZE_Large_Act_Max = np.array([ 1., 1.], dtype=np.float32) 11 | 12 | ## ======= Ben ======= 13 | Ben_maze_large_Obs_Min = np.array( [-4.9163504, -3.4131463], dtype=np.float32 ) 14 | Ben_maze_large_Obs_Max = np.array( [4.8761816, 3.3245058], dtype=np.float32 ) 15 | Ben_maze_large_Act_Min = np.array([-1., -1.], dtype=np.float32) 16 | Ben_maze_large_Act_Max = np.array([ 1., 1.], dtype=np.float32) 17 | 18 | ## ------- Ben Medium --------- 19 | 20 | Ben_maze_Medium_Obs_Min = np.array( [ -2.9093022346, -2.9120881557 ], dtype=np.float32 ) 21 | Ben_maze_Medium_Obs_Max = np.array( [ 2.8583071232, 2.7509465218 ], dtype=np.float32 ) 22 | 23 | 24 | Ben_maze_UMaze_Obs_Min = np.array( [ -1.2499687672, -1.2705398798 ], dtype=np.float32 ) 25 | Ben_maze_UMaze_Obs_Max = np.array( [ 1.2770261765, 1.2761843204 ], dtype=np.float32 ) 26 | 27 | 28 | ## =================== 29 | 30 | 31 | 32 | ## For Diffuser Baseline: 33 | MAZE_Large_ObsVel_Min = np.array([0.39643136, 0.44179875, -5.2262554, -5.2262554], dtype=np.float32) 34 | MAZE_Large_ObsVel_Max = np.array([ 7.2163844, 10.219488, 5.2262554, 5.2262554], dtype=np.float32) -------------------------------------------------------------------------------- /diffuser/datasets/comp/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.datasets.comp.comp_dataset_v1 import Comp_SeqDataset_V1 2 | from diffuser.datasets.comp.ben_pad_dataset_v1 import Ben_Pad_SeqDataset_V1 -------------------------------------------------------------------------------- /diffuser/datasets/comp/comp_data_utils.py: -------------------------------------------------------------------------------- 1 | import collections, pdb 2 | import numpy as np 3 | from diffuser.datasets.d4rl import get_dataset 4 | 5 | def comp_sequence_dataset(env, preprocess_fn, dataset_config): 6 | """ 7 | Copy init from sequence_dataset 8 | Returns an iterator through trajectories. 9 | Args: 10 | env: An OfflineEnv object. 11 | dataset: An optional dataset to pass in for processing. If None, 12 | the dataset will default to env.get_dataset() 13 | **kwargs: Arguments to pass to env.get_dataset(). 14 | Returns: 15 | An iterator through dictionaries with keys: 16 | observations 17 | actions 18 | rewards 19 | terminals 20 | """ 21 | obs_select_dim = list(dataset_config['obs_select_dim']) # must be list 22 | ## a dict: (['actions', 'infos/goal', 'infos/qpos', 23 | ## 'infos/qvel', 'observations', 'rewards', 'terminals', 'timeouts']) 24 | dataset = get_dataset(env) 25 | dataset = preprocess_fn(dataset) 26 | 27 | N = dataset['rewards'].shape[0] 28 | data_ = collections.defaultdict(list) 29 | 30 | # The newer version of the dataset adds an explicit 31 | # timeouts field. Keep old method for backwards compatability. 32 | use_timeouts = 'timeouts' in dataset 33 | # pdb.set_trace() ## True 34 | 35 | episode_step = 0 36 | for i in range(N): 37 | done_bool = bool(dataset['terminals'][i]) 38 | if use_timeouts: 39 | final_timestep = dataset['timeouts'][i] 40 | else: 41 | final_timestep = (episode_step == env._max_episode_steps - 1) 42 | 43 | 44 | # pdb.set_trace() ## check key name correct 45 | ## important: add each field in dataset to data_ 46 | for k in dataset: 47 | if 'metadata' in k: continue 48 | if k == 'observations': 49 | ## obs_select_dim must be list 50 | data_[k].append( dataset[k][i][ obs_select_dim ] ) 51 | else: 52 | data_[k].append(dataset[k][i]) 53 | 54 | ## if True, cut and create on episode here 55 | if done_bool or final_timestep: 56 | episode_step = 0 57 | episode_data = {} 58 | for k in data_: 59 | episode_data[k] = np.array(data_[k]) 60 | 61 | ## in ori, but feels no need 62 | # if 'maze2d' in env.name: 63 | # episode_data = process_maze2d_episode(episode_data) 64 | 65 | yield episode_data 66 | data_ = collections.defaultdict(list) 67 | 68 | episode_step += 1 69 | -------------------------------------------------------------------------------- /diffuser/datasets/comp/d4rl_m2d_const.py: -------------------------------------------------------------------------------- 1 | 2 | ## holds some constant value 3 | ## for rendering 4 | MAZE_Large_str_maze_spec = \ 5 | '############\\#OOOO#OOOOO#\\#O##O#O#O#O#\\#OOOOOO#OOO#\\#O####O###O#\\#OO#O#OOOOO#\\##O#O#O#O###\\#OO#OOO#OGO#\\############' 6 | 7 | MAZE_Medium_str_maze_spec = \ 8 | '########\\#OO##OO#\\#OO#OOO#\\##OOO###\\#OO#OOO#\\#O#OO#O#\\#OOO#OG#\\########' 9 | 10 | MAZE_Umaze_str_maze_spec = '#####\\#GOO#\\###O#\\#OOO#\\#####' 11 | ## check back load env 12 | 13 | def get_str_maze_spec(gr_e_name: str): 14 | """for gym robot env""" 15 | e_name_low = gr_e_name.lower() 16 | if gr_e_name == 'PointMaze_Large-v3': 17 | return MAZE_Large_str_maze_spec 18 | elif gr_e_name == 'PointMaze_Medium-v3': 19 | return MAZE_Medium_str_maze_spec 20 | elif gr_e_name == 'PointMaze_UMaze-v3': 21 | return MAZE_Umaze_str_maze_spec 22 | 23 | ## Nov 14 24 | elif 'antmaze' in e_name_low and 'large' in e_name_low: 25 | return MAZE_Large_str_maze_spec 26 | elif 'antmaze' in e_name_low and 'medium' in e_name_low: 27 | return MAZE_Medium_str_maze_spec 28 | elif 'antmaze' in e_name_low and 'umaze' in e_name_low: 29 | return MAZE_Umaze_str_maze_spec 30 | else: 31 | assert False -------------------------------------------------------------------------------- /diffuser/datasets/gym_robo_utils.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | def get_gym_robo_env_name(env_name_ori): 4 | ''' 5 | The input is our d4rl env_name 6 | while we would like to get the corresponding env_name in gym_robot package, 7 | for Ben's Maze2D and potentially AntMaze 8 | ''' 9 | if "maze2d-umaze-v1" == env_name_ori: ## in 10 | env_name = "PointMaze_UMaze-v3" 11 | elif "maze2d-medium-v1" == env_name_ori: 12 | env_name = "PointMaze_Medium-v3" 13 | elif "maze2d-large-v1" == env_name_ori: 14 | env_name = "PointMaze_Large-v3" 15 | else: 16 | raise NotImplementedError 17 | 18 | return env_name 19 | 20 | -------------------------------------------------------------------------------- /diffuser/guides/__init__.py: -------------------------------------------------------------------------------- 1 | from .render_m2d import Maze2dRenderer_V2 -------------------------------------------------------------------------------- /diffuser/guides/comp/cd_sml_policies.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | Trajectories_invdyn = namedtuple('Trajectories', 'actions observations') -------------------------------------------------------------------------------- /diffuser/guides/policies_invdyn.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | # import numpy as np 3 | import torch 4 | import einops 5 | import pdb 6 | 7 | import diffuser.utils as utils 8 | # from diffusion.datasets.preprocessing import get_policy_preprocess_fn 9 | 10 | Trajectories_invdyn = namedtuple('Trajectories', 'actions observations') 11 | # GuidedTrajectories = namedtuple('GuidedTrajectories', 'actions observations value') 12 | 13 | class Policy_InvDyn: 14 | 15 | def __init__(self, diffusion_model, 16 | normalizer): 17 | self.diffusion_model = diffusion_model 18 | self.normalizer = normalizer 19 | self.action_dim = normalizer.action_dim 20 | 21 | @property 22 | def device(self): 23 | parameters = list(self.diffusion_model.parameters()) 24 | return parameters[0].device 25 | 26 | def _format_conditions(self, conditions, batch_size): 27 | conditions = utils.apply_dict( 28 | self.normalizer.normalize, 29 | conditions, 30 | 'observations', 31 | ) 32 | conditions = utils.to_torch(conditions, dtype=torch.float32, device='cuda:0') 33 | conditions = utils.apply_dict( 34 | einops.repeat, 35 | conditions, 36 | 'd -> repeat d', repeat=batch_size, 37 | ) 38 | return conditions 39 | 40 | def __call__(self, conditions, debug=False, batch_size=1): 41 | 42 | 43 | conditions = self._format_conditions(conditions, batch_size) 44 | 45 | ## batchify and move to tensor [ batch_size x observation_dim ] 46 | # observation_np = observation_np[None].repeat(batch_size, axis=0) 47 | # observation = utils.to_torch(observation_np, device=self.device) 48 | 49 | ## run reverse diffusion process 50 | sample = self.diffusion_model(conditions) 51 | ## prev_obs, next_obs; ([1, 383, 8]) 52 | obs_comb = torch.cat([sample[:, :-1, :], sample[:, 1:, :]], dim=2) 53 | obs_flat = einops.rearrange(obs_comb, 'b h d -> (b h) d') 54 | ## [383, 2] 55 | actions_flat = self.diffusion_model.inv_model(obs_flat) 56 | # pdb.set_trace() 57 | actions = einops.rearrange(actions_flat, '(b h) d -> b h d', b=sample.shape[0]) 58 | sample = utils.to_np(sample) 59 | actions = utils.to_np(actions) 60 | 61 | # pdb.set_trace() 62 | 63 | ## extract action [ batch_size x horizon x transition_dim ] 64 | # actions = sample[:, :, :self.action_dim] 65 | 66 | 67 | 68 | actions = self.normalizer.unnormalize(actions, 'actions') 69 | # actions = np.tanh(actions) 70 | 71 | ## extract first action 72 | action = actions[0, 0] 73 | 74 | # if debug: 75 | normed_observations = sample[:, :, 0:] 76 | observations = self.normalizer.unnormalize(normed_observations, 'observations') 77 | 78 | # if deltas.shape[-1] < observation.shape[-1]: 79 | # qvel_dim = observation.shape[-1] - deltas.shape[-1] 80 | # padding = np.zeros([*deltas.shape[:-1], qvel_dim]) 81 | # deltas = np.concatenate([deltas, padding], axis=-1) 82 | 83 | # ## [ batch_size x horizon x observation_dim ] 84 | # next_observations = observation_np + deltas.cumsum(axis=1) 85 | # ## [ batch_size x (horizon + 1) x observation_dim ] 86 | # observations = np.concatenate([observation_np[:,None], next_observations], axis=1) 87 | 88 | trajectories = Trajectories_invdyn(actions, observations) 89 | return action, trajectories 90 | # else: 91 | # return action 92 | -------------------------------------------------------------------------------- /diffuser/guides/render_m2d.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | import einops 4 | import imageio 5 | import matplotlib.pyplot as plt 6 | from matplotlib.colors import ListedColormap 7 | import warnings, pdb 8 | 9 | from diffuser.datasets.d4rl import load_environment 10 | from diffuser.datasets.d4rl import Is_Gym_Robot_Env, load_env_gym_robo, Is_OgB_Robot_Env 11 | from .render_utils import make_traj_images 12 | import diffuser.utils as utils 13 | 14 | class Maze2dRenderer_V2: 15 | '''Luo Implement Version, July 22''' 16 | 17 | def __init__(self, env, observation_dim=None): 18 | ## FIXME: multiple env creation... 19 | ## Oct 29 20 | if Is_Gym_Robot_Env: 21 | self.env = load_env_gym_robo(env) 22 | elif Is_OgB_Robot_Env: 23 | # pdb.set_trace() ## TODO: 24 | from diffuser.datasets.ogb_dset.ogb_utils import ogb_load_env 25 | self.env = ogb_load_env(env) ## can be a str or already an env 26 | # assert type(env) != str 27 | # self.env = env 28 | 29 | else: 30 | self.env = load_environment(env) 31 | self.env_name = self.env.name 32 | self.observation_dim = np.prod(self.env.observation_space.shape) 33 | self.action_dim = np.prod(self.env.action_space.shape) 34 | # self.goal = None 35 | # self._background = self.env.maze_arr == 10 36 | # self._remove_margins = False 37 | # self._extent = (0, 1, 1, 0) 38 | 39 | def renders(self, obs_traj, conditions=None, **kwargs): 40 | ''' 41 | renders one traj: H,dim(2) 42 | ''' 43 | assert obs_traj.ndim == 2 44 | ## A list of np (h,w,4) 45 | imgs = make_traj_images(self.env, obs_traj[None,], **kwargs ) 46 | img = imgs[0] 47 | return img 48 | 49 | 50 | 51 | def composite(self, savepath, obs_trajs, ncol=5, pad_len=0, 52 | return_rows=False, **kwargs): 53 | ''' 54 | savepath : str 55 | obs_trajs : [ n_paths x horizon x 2 ] 56 | pad_len: pad around each sub img 57 | return_rows: if True, return imgs splited by row, shape: (n_rows, H, W*ncol, C) 58 | ''' 59 | n_res = len(obs_trajs) % ncol 60 | if n_res != 0: # and len(obs_trajs) > ncol: 61 | ncol = len(obs_trajs) 62 | # tmp_pad_trajs = np.zeros_like(obs_trajs[:ncol-n_res]) 63 | # obs_trajs = np.concatenate([obs_trajs, tmp_pad_trajs], axis=0) 64 | 65 | ## --------- New Jan 4 ------------ 66 | if type(obs_trajs) == list: 67 | ## when the input is a list with diff hzn 68 | if len(obs_trajs) >= 2: ## and obs_trajs[0].shape[0] != obs_trajs[1].shape[0]: 69 | ## padding to the max len and convert to np 70 | obs_trajs = np.array(utils.pad_traj2d_list(obs_trajs)) 71 | # pdb.set_trace() 72 | else: 73 | obs_trajs = np.array(obs_trajs) 74 | ## ------------------------------- 75 | 76 | 77 | assert len(obs_trajs) % ncol == 0, 'Number of paths must be divisible by number of columns' 78 | 79 | ## list of H W 4 80 | images = make_traj_images(self.env, obs_trajs, **kwargs ) 81 | ## B H W 4 82 | images = np.stack(images, axis=0) 83 | 84 | if 'large' in self.env_name and len(obs_trajs) > 1: 85 | pad_len = 30 86 | if pad_len > 0: ## pad 0 87 | images = np.pad(images, ((0,0), (pad_len,)*2, (pad_len,)*2, (0,0)), constant_values=255) 88 | 89 | 90 | nrow = len(images) // ncol 91 | img_whole = einops.rearrange(images, 92 | '(nrow ncol) H W C -> (nrow H) (ncol W) C', nrow=nrow, ncol=ncol) 93 | 94 | if savepath is not None: 95 | if savepath[-3:] == 'jpg': ## seems to be even larger than png 96 | ## e.g. (3360, 3000, 4) 97 | img_whole = img_whole[:, :, :3] 98 | imageio.imsave(savepath, img_whole) 99 | print(f'Saved {len(obs_trajs)} samples to: {savepath}') 100 | 101 | if return_rows: 102 | img_rows = einops.rearrange(images, 103 | '(nrow ncol) H W C -> nrow H (ncol W) C', nrow=nrow, ncol=ncol) 104 | return img_whole, img_rows 105 | 106 | 107 | return img_whole 108 | 109 | 110 | -------------------------------------------------------------------------------- /diffuser/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/diffuser/models/__init__.py -------------------------------------------------------------------------------- /diffuser/models/cd_stgl_sml_dfu/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.models.cd_stgl_sml_dfu.stgl_sml_temporal_cond_v1 import Unet1D_TjTi_Stgl_Cond_V1 2 | from diffuser.models.cd_stgl_sml_dfu.stgl_sml_diffusion_v1 import Stgl_Sml_GauDiffusion_InvDyn_V1 3 | from diffuser.models.cd_stgl_sml_dfu.stgl_sml_training_v1 import Stgl_Sml_Trainer_v1 -------------------------------------------------------------------------------- /diffuser/models/cd_stgl_sml_dfu/plan_stgl_sml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ev-hi 4 | #SBATCH --output=trash/slurm/plan_StglSml/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=4 8 | #SBATCH --exclude="clippy,voltron, claptrap" 9 | ###SBATCH --partition="rl2-lab" 10 | 11 | ##SBATCH --gres=gpu:a40:1 12 | #SBATCH --gres=gpu:rtx_6000:1 13 | ## 14 | #SBATCH --qos="debug" 15 | #SBATCH --time=5:00:00 16 | ## 17 | ###SBATCH --qos="debug" 18 | ###SBATCH --time=48:00:00 19 | 20 | source ~/.bashrc 21 | source activate hi_diffuser 22 | 23 | echo $(hostname) 24 | config="config/cp_maze_v1/cd_stgl_ben_Jan14/m2d_Me_BenPadex68FL_Cd_Stgl_h144_o48_ts512_bs128f_drop015.py" 25 | 26 | { 27 | 28 | # PYTHONBREAKPOINT=0 \ ## -B 29 | PYTHONDONTWRITEBYTECODE=1 \ 30 | CUDA_VISIBLE_DEVICES=${1:-0} \ 31 | python diffuser/models/cd_stgl_sml_dfu/plan_stgl_sml.py \ 32 | --config $config \ 33 | --plan_n_ep $2 \ 34 | --pl_seeds ${3:--1} \ 35 | 36 | 37 | exit 0 38 | 39 | } -------------------------------------------------------------------------------- /diffuser/models/cd_stgl_sml_dfu/train_stgl_sml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-hi 4 | #SBATCH --output=trash/slurm/train_StglSml/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=6 8 | #SBATCH --exclude="clippy,voltron" 9 | ###SBATCH --partition="rl2-lab" 10 | 11 | #SBATCH --gres=gpu:l40s:1 12 | ##SBATCH --gres=gpu:a40:1 13 | ###SBATCH --gres=gpu:rtx_6000:1 14 | ## 15 | ##SBATCH --qos="long" 16 | ##SBATCH --time=72:00:00 17 | ## 18 | #SBATCH --qos="debug" 19 | #SBATCH --time=48:00:00 20 | 21 | source ~/.bashrc 22 | source activate hi_diffuser 23 | 24 | ## Oct 8 25 | config="config/cp_maze_v1/cd_stgl/m2d_lg_Cd_Stgl_luotest.py" 26 | 27 | 28 | 29 | 30 | { 31 | 32 | # PYTHONBREAKPOINT=0 \ ## -B 33 | PYTHONDONTWRITEBYTECODE=1 \ 34 | CUDA_VISIBLE_DEVICES=${1:-0} \ 35 | python diffuser/models/cd_stgl_sml_dfu/train_stgl_sml.py --config $config \ 36 | 37 | 38 | exit 0 39 | 40 | } -------------------------------------------------------------------------------- /diffuser/models/comp_dfu/comp_diffusion_v1.py: -------------------------------------------------------------------------------- 1 | from collections import namedtuple 2 | ModelPrediction = namedtuple("ModelPrediction", ["pred_noise", "pred_x_start", "model_out"]) 3 | -------------------------------------------------------------------------------- /diffuser/models/cond_cp_dfu/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.models.cond_cp_dfu.sml_temporal_cond_v1 import Unet1D_TjTiCond_V1 -------------------------------------------------------------------------------- /diffuser/models/cond_cp_dfu/sml_temporal_dd_v1.py: -------------------------------------------------------------------------------- 1 | import torch 2 | import torch.nn as nn 3 | import einops 4 | from einops.layers.torch import Rearrange 5 | import pdb 6 | 7 | from diffuser.models.helpers import Conv1dBlock_dd 8 | 9 | class ResidualTemporalBlock_dd(nn.Module): 10 | 11 | def __init__(self, inp_channels, out_channels, embed_dim, horizon, kernel_size=5, mish=True,conv_zero_init=False, resblock_config={}, **kwargs): 12 | '''kwargs: place holder for some useless args e.g. wall_embed_dim''' 13 | super().__init__() 14 | assert conv_zero_init == False 15 | force_residual_conv = resblock_config.get('force_residual_conv', False) 16 | time_mlp_config = resblock_config['time_mlp_config'] 17 | 18 | convblock_type = Conv1dBlock_dd 19 | 20 | self.blocks = nn.ModuleList([ 21 | convblock_type(inp_channels, out_channels, kernel_size, mish, conv_zero_init=False), # conv_zero_init, only difference bewteen ori and ori2 22 | convblock_type(out_channels, out_channels, kernel_size, mish, conv_zero_init=conv_zero_init), 23 | ]) 24 | 25 | if mish: 26 | act_fn = nn.Mish() 27 | else: 28 | act_fn = nn.SiLU() 29 | 30 | # pdb.set_trace() ## check time_mlp_config 31 | 32 | if time_mlp_config == 2: 33 | self.time_mlp = nn.Sequential( 34 | act_fn, 35 | nn.Linear(embed_dim, out_channels * 2), 36 | act_fn, 37 | nn.Linear(out_channels * 2, out_channels), 38 | Rearrange('batch t -> batch t 1'), 39 | ) 40 | elif time_mlp_config == 3: 41 | self.time_mlp = nn.Sequential( 42 | nn.Linear(embed_dim, embed_dim * 2), 43 | act_fn, 44 | nn.Linear(embed_dim * 2, out_channels), 45 | Rearrange('batch t -> batch t 1'), 46 | ) 47 | elif time_mlp_config == 0: ## default setting, same as else below 48 | self.time_mlp = nn.Sequential( 49 | act_fn, 50 | nn.Linear(embed_dim, out_channels), 51 | Rearrange('batch t -> batch t 1'), 52 | ) 53 | else: 54 | self.time_mlp = nn.Sequential( 55 | act_fn, 56 | nn.Linear(embed_dim, out_channels), 57 | Rearrange('batch t -> batch t 1'), 58 | ) 59 | 60 | if not force_residual_conv: 61 | self.residual_conv = nn.Conv1d(inp_channels, out_channels, 1) \ 62 | if inp_channels != out_channels else nn.Identity() 63 | else: 64 | self.residual_conv = nn.Conv1d(inp_channels, out_channels, 1) 65 | 66 | def forward(self, x, t,): 67 | ''' 68 | pipeline: 69 | 1. process x only 70 | 2. process t only 71 | 3. process (x + t) *zero init* 72 | 4. process skip connection 73 | 74 | x : [ batch_size x inp_channels x horizon ] 75 | t : [ batch_size x embed_dim ] 76 | w : placeholder 77 | returns: 78 | out : [ batch_size x out_channels x horizon ] 79 | ''' 80 | out = self.blocks[0](x) + self.time_mlp(t) 81 | out = self.blocks[1](out) 82 | 83 | return out + self.residual_conv(x) -------------------------------------------------------------------------------- /diffuser/ogb_task/og_inv_dyn/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.ogb_task.og_inv_dyn.og_invdyn_model import MLP_InvDyn_OgB_V3 -------------------------------------------------------------------------------- /diffuser/ogb_task/og_inv_dyn/og_invdyn_helpers.py: -------------------------------------------------------------------------------- 1 | import torch.nn as nn 2 | import torch, math 3 | import torch.nn.functional as F 4 | 5 | def ogb_get_default_init_unif_a(weight: torch.Tensor, scale=1.0): 6 | """ Implemented following default_init in networks.py 7 | Default kernel initializer. 8 | ### 9 | remember to init bias to 0 10 | nn.init.zeros_(tensor) 11 | """ 12 | fan_out, fan_in = weight.data.shape 13 | print(f'[ogb_get_default_init_unif_a] {fan_out=}, {fan_in=}') 14 | avg_fan = (fan_in + fan_out) / 2 15 | init_unif_a = math.sqrt( scale / avg_fan ) 16 | return -init_unif_a, init_unif_a 17 | 18 | 19 | 20 | class OgB_MLP(nn.Module): # encoder 21 | def __init__(self, 22 | input_dim: int, 23 | hidden_dims: list, 24 | output_dim, ## int or None 25 | activate_final, 26 | mlp_config): 27 | ''' 28 | This is just a helper model for the OGBench GC Policy 29 | Args: 30 | hidden_dims (list): [512, 512, 512] or [in, 256, 256, out] 31 | final_fc_init_scale: 1e-2 32 | ''' 33 | super().__init__() 34 | self.input_dim = input_dim 35 | self.hidden_dims = hidden_dims 36 | self.output_dim = output_dim 37 | module_list = [] 38 | 39 | # final_fc_init_scale = mlp_config['final_fc_init_scale'] 40 | 41 | if output_dim is None: 42 | layer_dim = [self.input_dim,] + hidden_dims 43 | self.output_dim = hidden_dims[-1] 44 | else: 45 | # (in, 512, 256, 128, out) ? out of date 46 | layer_dim = [self.input_dim,] + hidden_dims + [output_dim,] 47 | 48 | ## Jan 8 NEW, default: the last 2 layers do not have dropout 49 | n_dpout_until = mlp_config.get('n_dpout_until', 2) 50 | assert n_dpout_until in [2,1,0] 51 | 52 | num_layer = len(layer_dim) - 1 53 | 54 | for i_l in range(num_layer): 55 | tmp_linear = nn.Linear(layer_dim[i_l], layer_dim[i_l+1]) 56 | nn.init.zeros_(tmp_linear.bias) 57 | 58 | ## --- Customized Init Func, No Need --- 59 | # tmp_a, tmp_b = ogb_get_default_init_unif_a( 60 | # tmp_linear.weight, scale=final_fc_init_scale) 61 | # nn.init.uniform_(tmp_linear.weight, a=tmp_a, b=tmp_b) 62 | ## ------------------------------------- 63 | 64 | module_list.append( tmp_linear ) 65 | 66 | if mlp_config['act_f'] == 'relu': 67 | assert False 68 | act_fn_2 = nn.ReLU 69 | elif mlp_config['act_f'] == 'Prelu': 70 | assert False 71 | act_fn_2 = nn.PReLU 72 | elif mlp_config['act_f'] == 'gelu': 73 | act_fn_2 = nn.GELU 74 | else: 75 | assert False 76 | module_list.append( act_fn_2() ) 77 | 78 | if mlp_config['use_dpout'] and i_l < num_layer - n_dpout_until: 79 | # assert False, 'bug free, but not used.' 80 | module_list.append( nn.Dropout(p=mlp_config['prob_dpout']), ) 81 | 82 | # pdb.set_trace() 83 | if not activate_final: 84 | del module_list[-1] # no relu at last 85 | 86 | self.encoder = nn.Sequential(*module_list) 87 | self.mlp_config = mlp_config 88 | self.n_dpout_until = n_dpout_until 89 | 90 | # from diffuser.utils import print_color 91 | # print_color(f'[MLP_InvDyn_OgB_V3] {num_layer=}, {layer_dim=}') 92 | 93 | def forward(self, x): 94 | x = self.encoder(x) 95 | return x 96 | 97 | 98 | 99 | 100 | from diffuser.utils import load_config, get_latest_epoch 101 | import diffuser.utils as utils 102 | 103 | 104 | def ogb_load_invdyn_maze_v1(loadpath: str, epoch='latest', device='cuda:0', ld_config={}): 105 | model_config = load_config(loadpath, 'model_config.pkl') 106 | 107 | model = model_config() 108 | ema_model = model_config() 109 | 110 | # ema_diffusion = diffusion_config(model) 111 | if epoch == 'latest': 112 | epoch = get_latest_epoch([loadpath,]) 113 | ckpt_path = f'{loadpath}/state_{epoch}.pt' 114 | ckpt_data = torch.load(ckpt_path, weights_only=False) 115 | 116 | # trainer.load(epoch) 117 | 118 | utils.print_color( 119 | f'\n[ utils/serialization ] Loading Ours V1 Diffuser Inv model epoch: {epoch}\n', c='c') 120 | 121 | model.load_state_dict( ckpt_data['model'] ) 122 | ema_model.load_state_dict( ckpt_data['ema'] ) 123 | 124 | model.eval() 125 | ema_model.eval() 126 | utils.freeze_model(model) 127 | utils.freeze_model(ema_model) 128 | 129 | # pdb.set_trace() 130 | 131 | return model, ema_model, epoch 132 | 133 | 134 | -------------------------------------------------------------------------------- /diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ohi-inv 4 | #SBATCH --output=trash/slurm/train_OG_inv/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=8 8 | #SBATCH --exclude="clippy,voltron,dendrite,claptrap" ## glados,oppy 9 | #SBATCH --qos="debug" 10 | #SBATCH --time=18:00:00 11 | #SBATCH --gres=gpu:a40:1 12 | ##SBATCH --partition="rl2-lab" 13 | ##SBATCH --gres=gpu:rtx_6000:1 14 | ##SBATCH --gres=gpu:a5000:1 15 | 16 | 17 | source ~/.bashrc 18 | source activate compdfu_ogb_release 19 | 20 | ## optionally 'cd' to 'comp_diffuser_release' folder 21 | # cd $Folder 22 | 23 | # echo $(hostname) 24 | 25 | 26 | ## ------------ AntMaze Explore ------------ 27 | ## AntMaze Medium Explore 28 | # config="config/maze_og/og_inv/og_antMexpl_Me_o29d_g2d_invdyn_h12.py" 29 | 30 | ## AntMaze Large Explore 31 | # config="config/maze_og/og_inv_Jan1/og_antMexpl_Lg_o29d_g2d_invdyn_h12.py" 32 | 33 | ## ----------------------------------------- 34 | 35 | 36 | ## humanoid 37 | # config="config/maze_og/og_inv_Jan4/og_humM_Gi_o69d_g2d_invdyn_h80_dm5_dout02.py" 38 | # config="config/maze_og/og_inv_Jan4/og_humM_Lg_o69d_g2d_invdyn_h80_dm5_dout02.py" 39 | # config="config/maze_og/og_inv_Jan4/og_humM_Me_o69d_g2d_invdyn_h80_dm5_dout02.py" 40 | 41 | 42 | ## ------------ AntSoccer Arena ------------ 43 | # config="config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Ar_o42d_g4d_invdyn_h120_dout02.py" 44 | # config="config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Ar_o42d_g17d_invdyn_h120_dout02.py" 45 | 46 | ## ------------ AntSoccer Medium ------------ 47 | # config="config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Me_o42d_g4d_invdyn_h120_dm4_dout02.py" 48 | # config="config/ogb_invdyn/og_inv_ant_soc/og_antSoc_Me_o42d_g17d_invdyn_h100_dm4_dout02.py" 49 | 50 | 51 | 52 | ## --------- Training Inverse Dynamics Models: OGBench AntMaze Stitch 2D Planner ---------- 53 | 54 | ## ** Example: ** 55 | ## the state space of ant is 29D (so observation is 29D) 56 | ## 2D (x-y) diffusion planner (so goal is 2D) 57 | ## to set which inverse dynamics model to use, check 'diffuser/utils/ogb_utils/ogb_serial.py' 58 | 59 | ## ant maze giant stitch 60 | config="config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g2d_invdyn_h12.py" ## for 2D planner 61 | # config="config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g15d_invdyn_h12.py" 62 | # config="config/ogb_invdyn/og_inv_ant/og_antM_Gi_o29d_g29d_invdyn_h12_dm5.py" 63 | 64 | ## Large 65 | ## ant maze large stitch 66 | # config="config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g2d_invdyn_h12.py" 67 | # config="config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g15d_invdyn_h12.py" 68 | # config="config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py" 69 | 70 | ## Medium 71 | ## ant maze medium stitch 72 | # config="config/maze_og/og_inv_Jan1/og_antM_Me_o29d_g2d_invdyn_h12.py" 73 | # config="config/maze_og/og_inv_Jan6/og_antM_Me_o29d_g15d_invdyn_h12.py" 74 | # config="config/maze_og/og_inv_Jan1/og_antM_Me_o29d_g29d_invdyn_h12_dm5.py" 75 | 76 | 77 | 78 | { 79 | 80 | PYTHONDONTWRITEBYTECODE=1 \ 81 | CUDA_VISIBLE_DEVICES=${1:-0} \ 82 | python diffuser/ogb_task/og_inv_dyn/train_og_invdyn.py --config $config \ 83 | 84 | 85 | exit 0 86 | 87 | } 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /diffuser/ogb_task/ogb_maze_v1/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.ogb_task.ogb_maze_v1.ogb_stgl_sml_training_v1 import OgB_Stgl_Sml_Trainer_v1 -------------------------------------------------------------------------------- /diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ev-hi 4 | #SBATCH --output=trash/slurm/plan_OG_StglSml_Jan27/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=4 8 | ### brainiac, 2080: alexa,alexa 9 | #SBATCH --exclude="clippy,voltron,claptrap,alexa,bmo,olivaw,oppy" 10 | 11 | ##SBATCH --partition="rl2-lab" 12 | 13 | #SBATCH --gres=gpu:a40:1 14 | ##SBATCH --gres=gpu:l40s:1 15 | ##SBATCH --qos="short" 16 | 17 | ##SBATCH --gres=gpu:rtx_6000:1 18 | ##SBATCH --gres=gpu:a5000:1 19 | 20 | #SBATCH --qos="debug" 21 | #SBATCH --time=16:00:00 22 | 23 | echo $(hostname) 24 | 25 | source ~/.bashrc 26 | source activate compdfu_ogb_release 27 | 28 | # config="" 29 | 30 | # config="config/og_antM_Gi_o2d_luotest.py" ## test only, placeholder config file 31 | 32 | 33 | ## --------- Planning: OGBench AntMaze Stitch 15/29D Planner ---------- 34 | ## i.e., the diffusion planner generates trajectory of shape (Horizon, 15/29) 35 | # config="config/ogb_ant_maze/og_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit.py" 36 | # config="config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py" 37 | 38 | 39 | ## --------- Planning: OGBench AntMaze Stitch 2D Planner ---------- 40 | ## Giant 41 | # config="config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 42 | ## Large 43 | # config="config/ogb_ant_maze/og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 44 | ## Medium 45 | # config="config/ogb_ant_maze/og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 46 | 47 | ## --------- Planning: OGBench AntMaze Explore 2D Planner ---------- 48 | ## TODO: 49 | 50 | 51 | ## --------- Planning: OGBench PointMaze Stitch 2D Planner ---------- 52 | ## Giant 53 | config="config/ogb_pnt_maze/og_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 54 | ## Large 55 | # config="config/ogb_pnt_maze/og_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 56 | ## Medium 57 | # config="config/ogb_pnt_maze/og_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 58 | 59 | 60 | 61 | 62 | { 63 | 64 | PYTHONDONTWRITEBYTECODE=1 \ 65 | CUDA_VISIBLE_DEVICES=${1:-0} \ 66 | MUJOCO_EGL_DEVICE_ID=${1:-0} \ 67 | python diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py \ 68 | --config $config \ 69 | --plan_n_ep $2 \ 70 | --pl_seeds ${3:--1} \ 71 | 72 | 73 | exit 0 74 | 75 | } -------------------------------------------------------------------------------- /diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #SBATCH --job-name=script-ohi 4 | #SBATCH --output=trash/slurm/train_OG_StglSml_jan3/slurm-%j.out 5 | #SBATCH --nodes=1 6 | #SBATCH --ntasks-per-node=1 7 | #SBATCH --cpus-per-task=6 8 | #SBATCH --exclude="clippy,voltron,alexa" 9 | #SBATCH --mem=100G 10 | 11 | ##SBATCH --gres=gpu:rtx_6000:1 12 | ##SBATCH --gres=gpu:a40:1 13 | #SBATCH --gres=gpu:l40s:1 14 | ## 15 | ##SBATCH --qos="long" 16 | ##SBATCH --qos="debug" 17 | #SBATCH --qos="short" 18 | ##SBATCH --time=100:00:00 19 | #SBATCH --time=48:00:00 20 | 21 | source ~/.bashrc 22 | source activate compdfu_ogb_release 23 | 24 | ## optionally 'cd' to 'comp_diffuser_release' folder 25 | # cd $Your_Folder_of_This_Repo 26 | 27 | config="config/og_antM_Gi_o2d_luotest.py" 28 | # config="config/ogb_ant_maze/og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512_resume.py" 29 | # config="config/ogb_ant_maze/og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512_resume.py" 30 | 31 | ## --------- Training: OGBench AntMaze Stitch, High Dimension Planner ---------- 32 | ## Large 15D 33 | config="config/ogb_ant_maze/og_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit.py" 34 | ## Large 29D 35 | # config="config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py" 36 | 37 | 38 | ## --------- Training: OGBench AntMaze Stitch 2D Planner ---------- 39 | ## Giant 40 | # config="config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 41 | ## Large 42 | # config="config/ogb_ant_maze/og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 43 | ## Medium 44 | # config="config/ogb_ant_maze/og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 45 | 46 | ## --------- Training: OGBench PointMaze Stitch 2D Planner ---------- 47 | ## Giant 48 | # config="config/ogb_pnt_maze/og_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 49 | ## Large 50 | # config="config/ogb_pnt_maze/og_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 51 | ## Medium 52 | # config="config/ogb_pnt_maze/og_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py" 53 | 54 | 55 | { 56 | 57 | echo $(hostname) 58 | 59 | # CUDA_LAUNCH_BLOCKING=1 \ 60 | PYTHONDONTWRITEBYTECODE=1 \ 61 | CUDA_VISIBLE_DEVICES=${1:-0} \ 62 | python diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.py --config $config \ 63 | 64 | 65 | exit 0 66 | 67 | } -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/README.md: -------------------------------------------------------------------------------- 1 | Files inside this folder are used to generate evaluation problems (i.e., start state and goal state pairs) for the datasets in 2 | '*Closing the Gap between TD Learning and Supervised Learning -- A Generalisation Point of View*'. 3 | 4 | Not used for OGBench environments. -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/gen_m2d_our_probs.py: -------------------------------------------------------------------------------- 1 | import sys, pdb 2 | sys.path.insert(0, './') 3 | import gym, gc, os, torch, random, yaml, h5py 4 | import numpy as np 5 | from importlib import reload 6 | from diffuser.utils import utils 7 | from tqdm import tqdm 8 | import warnings 9 | warnings.simplefilter('always', ResourceWarning) # Show all resource warnings 10 | from tap import Tap 11 | from diffuser.pl_eval.gen_ev_probs.m2d_pl_const import m2d_get_bottom_top_rows 12 | from diffuser.pl_eval.gen_ev_probs.gen_m2d_probs_utils import m2d_rand_sample_probs, merge_prob_dicts 13 | 14 | class Parser(Tap): 15 | sub_conf: str = 'config.maze2d' 16 | 17 | def main(): 18 | '''a helper script to generate dataset of random samples in the Libero env''' 19 | 20 | args = Parser().parse_args() 21 | 22 | file_path = 'diffuser/pl_eval/gen_ev_probs/gen_m2d_our_probs_confs.yaml' 23 | # Open the YAML file and load its contents 24 | with open(file_path, 'r') as file: 25 | config = yaml.safe_load(file) 26 | rs_cfg = config[args.sub_conf] 27 | 28 | seed_u = rs_cfg['seed_u'] 29 | random.seed(seed_u) 30 | np.random.seed(seed_u) 31 | torch.manual_seed(seed_u) 32 | 33 | # pdb.set_trace() 34 | ## TODO: Oct 21, 18:53, From Here 35 | 36 | el_name = rs_cfg['el_name'] 37 | assert el_name == 'maze2d-large-v1', 'not implement others yet' 38 | 39 | ## do we actually need to init an env? 40 | # env = gym.make(rs_cfg['el_name'],) # gen_data=True) 41 | utils.print_color(f'el_name: {el_name}') 42 | prob_dicts = [] 43 | if rs_cfg['prob_type'] == 'bottom_top_2way': 44 | ## np2d (n_valid_cell, 2) 45 | bottom_row, top_row = m2d_get_bottom_top_rows(el_name) 46 | ## 1. from bottom to top 47 | st_p_l_1 = bottom_row 48 | gl_p_l_1 = top_row 49 | ### from bottom to top and from top to bottom 50 | tmp_probs = m2d_rand_sample_probs(st_p_l_1, gl_p_l_1, rs_cfg) 51 | prob_dicts.append(tmp_probs) 52 | 53 | # pdb.set_trace() 54 | 55 | ## 2. from top to bottom 56 | st_p_l_2 = top_row 57 | gl_p_l_2 = bottom_row 58 | tmp_probs = m2d_rand_sample_probs(st_p_l_2, gl_p_l_2, rs_cfg) 59 | prob_dicts.append(tmp_probs) 60 | 61 | all_prob_dict = merge_prob_dicts(prob_dicts) 62 | 63 | # pdb.set_trace() 64 | 65 | else: 66 | raise NotImplementedError 67 | 68 | 69 | ## check consistency ?? 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | h5_root = '/coc/flash7/yluo470/robot2024/hi_diffuser/data/m2d/ev_probs' 79 | h5_save_path = f'{h5_root}/{args.sub_conf}.hdf5' 80 | # pdb.set_trace() 81 | num_probs = all_prob_dict['start_state'].shape[0] 82 | 83 | ## ---------------------------------- 84 | ## Finished all, save to hdf5 85 | with h5py.File(h5_save_path, 'w') as file: 86 | file.create_dataset('start_state', data=all_prob_dict['start_state']) 87 | file.create_dataset('goal_pos', data=all_prob_dict['goal_pos']) 88 | 89 | file.attrs['env_seed'] = seed_u 90 | file.attrs['env_name'] = el_name 91 | 92 | ## lock file 93 | if 'luotest' not in args.sub_conf: 94 | os.chmod(h5_save_path, 0o444) 95 | utils.print_color(f'[save to] {h5_save_path=}') 96 | 97 | 98 | if __name__ == '__main__': 99 | main() 100 | 101 | -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/gen_m2d_our_probs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ~/.bashrc 4 | source activate hi_diffuser 5 | 6 | sub_conf='maze2d_lg_ev_prob_luotest' 7 | sub_conf='maze2d_lg_ev_prob_luotest_2' 8 | sub_conf='maze2d_lg_ev_prob_bt2way_nppp3' 9 | sub_conf='maze2d_lg_ev_prob_bt2way_nppp3_rprange02' 10 | 11 | 12 | 13 | { 14 | 15 | PYTHONDONTWRITEBYTECODE=1 \ 16 | CUDA_VISIBLE_DEVICES=${1:-0} \ 17 | python diffuser/pl_eval/gen_ev_probs/gen_m2d_our_probs.py \ 18 | --sub_conf ${sub_conf} 19 | 20 | 21 | exit 0 22 | 23 | } -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/gen_m2d_our_probs_confs.yaml: -------------------------------------------------------------------------------- 1 | 2 | maze2d_lg_ev_prob_bt2way_nppp3: 3 | 4 | seed_u: 0 5 | el_name: 'maze2d-large-v1' 6 | prob_type: bottom_top_2way 7 | n_probs_per_pair: 3 8 | r_pos_range: [-0.3, 0.3] 9 | 10 | maze2d_lg_ev_prob_bt2way_nppp3_rprange02: 11 | 12 | seed_u: 0 13 | el_name: 'maze2d-large-v1' 14 | prob_type: bottom_top_2way 15 | n_probs_per_pair: 3 16 | r_pos_range: [-0.2, 0.2] 17 | 18 | 19 | ## ------- Luotest ------- 20 | maze2d_lg_ev_prob_luotest: 21 | 22 | seed_u: 0 23 | el_name: 'maze2d-large-v1' 24 | prob_type: bottom_top_2way 25 | n_probs_per_pair: 3 26 | r_pos_range: [-0.3, 0.3] 27 | 28 | 29 | maze2d_lg_ev_prob_luotest_2: 30 | 31 | seed_u: 0 32 | el_name: 'maze2d-large-v1' 33 | prob_type: bottom_top_2way 34 | n_probs_per_pair: 3 35 | r_pos_range: [-0.3, 0.3] 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/gen_m2d_probs_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pdb 3 | 4 | def m2d_rand_sample_probs(start_pos_list, gl_pos_list, rs_cfg): 5 | """ 6 | densely loop through all possibe pairs of start / goal, 7 | note that we include the velocity in the start_state 8 | """ 9 | out_data = dict(start_state=[], goal_pos=[]) 10 | for i_st, base_st_pos in enumerate(start_pos_list): 11 | for i_gl, base_gl_pos in enumerate(gl_pos_list): 12 | for i_ep in range(rs_cfg['n_probs_per_pair']): 13 | p_low, p_high = rs_cfg['r_pos_range'] ## -0.3, +0.3 14 | tmp_noise_1 = np.random.uniform(size=base_st_pos.shape, low=p_low, high=p_high) 15 | st_pos = base_st_pos + tmp_noise_1 16 | 17 | tmp_noise_2 = np.random.uniform(size=base_gl_pos.shape, low=p_low, high=p_high) 18 | gl_pos = base_gl_pos + tmp_noise_2 19 | 20 | # pdb.set_trace() 21 | 22 | st_state = np.concatenate([st_pos, [0.,0.]]) 23 | out_data['start_state'].append( st_state ) 24 | out_data['goal_pos'].append( gl_pos ) 25 | 26 | # pdb.set_trace() 27 | return out_data 28 | 29 | 30 | def merge_prob_dicts(prob_dicts: list[dict]): 31 | ''' 32 | prob_dicts: list of dict 33 | ''' 34 | mg_prob_dict = { k: [] for k in prob_dicts[0].keys() } 35 | ## loop through the list of dict 36 | for p_d in prob_dicts: 37 | assert set(p_d.keys()) == {'start_state', 'goal_pos'} 38 | for k in p_d.keys(): 39 | ## list of np2d 40 | mg_prob_dict[k].append(p_d[k]) 41 | for kk in mg_prob_dict.keys(): 42 | mg_prob_dict[kk] = np.concatenate(mg_prob_dict[kk], axis=0) 43 | # pdb.set_trace() 44 | 45 | return mg_prob_dict 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /diffuser/pl_eval/gen_ev_probs/m2d_pl_const.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | ## ours: use the Diffuser default coordinate system 4 | ## LH: Long horizon 5 | Maze2D_Large_Bottom_Row_ours_LH = \ 6 | np.array([ [1,1],[2,1],[3,1], [4,1], [5,1], [7,1] ], dtype=np.float32) 7 | 8 | Maze2D_Large_Top_Row_ours_LH = \ 9 | np.array([ [1,10],[2,10],[3,10], [4,10], [5,10], [7,10] ], dtype=np.float32) 10 | 11 | 12 | def m2d_get_bottom_top_rows(env_name): 13 | '''return two rows''' 14 | if env_name == 'maze2d-large-v1': 15 | return Maze2D_Large_Bottom_Row_ours_LH, Maze2D_Large_Top_Row_ours_LH 16 | elif env_name == 'maze2d-medium-v1': 17 | assert False 18 | elif env_name == 'maze2d-umaze-v1': 19 | assert False 20 | else: 21 | assert False -------------------------------------------------------------------------------- /diffuser/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .serialization import * 2 | from .training import * 3 | from .progress import * 4 | from .setup import * 5 | from .config import * 6 | from .rendering import * 7 | from .arrays import * 8 | from .video import * 9 | 10 | 11 | from .eval_utils import * 12 | 13 | from diffuser.utils.cp_utils.cp_serial import * 14 | from diffuser.utils.cp_utils.cp_luo_utils import * 15 | from diffuser.utils.cp_utils.maze_utils import * 16 | 17 | from diffuser.utils.ogb_utils.ogb_serial import * -------------------------------------------------------------------------------- /diffuser/utils/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | import collections 3 | import importlib 4 | import pickle 5 | import pdb 6 | 7 | def import_class(_class): 8 | if type(_class) is not str: return _class 9 | ## 'diffusion' on standard installs 10 | repo_name = __name__.split('.')[0] 11 | ## eg, 'utils' 12 | module_name = '.'.join(_class.split('.')[:-1]) 13 | ## eg, 'Renderer' 14 | class_name = _class.split('.')[-1] 15 | ## eg, 'diffusion.utils' 16 | module = importlib.import_module(f'{repo_name}.{module_name}') 17 | ## eg, diffusion.utils.Renderer 18 | _class = getattr(module, class_name) 19 | print(f'[ utils/config ] Imported {repo_name}.{module_name}:{class_name}') 20 | return _class 21 | 22 | class Config(collections.abc.Mapping): 23 | 24 | def __init__(self, _class, verbose=True, savepath=None, device=None, **kwargs): 25 | self._class = import_class(_class) 26 | self._device = device 27 | self._dict = {} 28 | 29 | for key, val in kwargs.items(): 30 | self._dict[key] = val 31 | 32 | if verbose: 33 | print(self) 34 | 35 | if savepath is not None: 36 | savepath = os.path.join(*savepath) if type(savepath) is tuple else savepath 37 | self.savepath = savepath 38 | pickle.dump(self, open(savepath, 'wb')) 39 | print(f'[ utils/config ] Saved config to: {savepath}\n') 40 | # pdb.set_trace() 41 | 42 | def __repr__(self): 43 | string = f'\n[utils/config ] Config: {self._class}\n' 44 | for key in sorted(self._dict.keys()): 45 | val = self._dict[key] 46 | 47 | string += f' {key}: {val}\n' 48 | return string 49 | 50 | def __iter__(self): 51 | return iter(self._dict) 52 | 53 | def __getitem__(self, item): 54 | return self._dict[item] 55 | 56 | def __len__(self): 57 | return len(self._dict) 58 | 59 | def __getattr__(self, attr): 60 | if attr == '_dict' and '_dict' not in vars(self): 61 | self._dict = {} 62 | return self._dict 63 | try: 64 | return self._dict[attr] 65 | except KeyError: 66 | raise AttributeError(attr) 67 | 68 | def __call__(self, *args, **kwargs): 69 | instance = self._class(*args, **kwargs, **self._dict) 70 | if self._device: 71 | instance = instance.to(self._device) 72 | # pdb.set_trace() 73 | if getattr(self, 'savepath', None): 74 | if 'model_config.pkl' in self.savepath: 75 | m_path = self.savepath.replace('model_config.pkl', 'model_config.txt') 76 | with open(m_path, 'w') as f: 77 | print(instance, file=f) 78 | return instance 79 | -------------------------------------------------------------------------------- /diffuser/utils/cp_utils/cp_luo_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from diffuser.utils.arrays import to_np 4 | 5 | def extract_ovlp_from_full(x: torch.Tensor, len_ovlp_cd): 6 | """ 7 | x: either np or tensor, a non-self version, that can be called from outside. 8 | """ 9 | st_traj = x[:, :len_ovlp_cd, :] 10 | end_traj = x[:, -len_ovlp_cd:, :] 11 | if torch.is_tensor(st_traj): 12 | assert torch.is_tensor(end_traj) 13 | st_traj = st_traj.detach().clone() 14 | end_traj = end_traj.detach().clone() 15 | else: 16 | assert type(st_traj) == np.ndarray 17 | assert type(end_traj) == np.ndarray 18 | 19 | return st_traj, end_traj 20 | 21 | def compute_ovlp_dist(trajs_list_un, len_ovlp_cd): 22 | ''' 23 | actually if we do not do thresholding, normed trajs also seems fine, since we only do ranking 24 | Args: 25 | - trajs_list_un: a list of len n_comp [ unnorm trajs [B,H,D] ], should be np 26 | ''' 27 | trajs_list = trajs_list_un 28 | num_tj = len(trajs_list) 29 | assert num_tj >= 2 30 | assert trajs_list[0].ndim == 3 31 | 32 | dist_all = [] 33 | for i_tj in range(num_tj-1): 34 | traj_1 = trajs_list[i_tj] 35 | traj_2 = trajs_list[i_tj+1] 36 | assert traj_1.ndim == 3 and traj_2.ndim == 3 37 | ## B,H,C 38 | _, end_traj_1 = extract_ovlp_from_full(traj_1, len_ovlp_cd) 39 | st_traj_2, _ = extract_ovlp_from_full(traj_2, len_ovlp_cd) 40 | 41 | print(f'{end_traj_1.shape=}') 42 | 43 | # tmp_dist = np.linalg.norm( end_traj_1 - st_traj_2 ).item() 44 | mse_dist = (end_traj_1 - st_traj_2) ** 2 45 | ## (B,) 46 | mse_dist = np.mean(mse_dist, axis=(1,2)) 47 | 48 | dist_all.append(mse_dist) 49 | 50 | ## (B, n_comp-1) 51 | dist_all = np.stack(dist_all, axis=1) 52 | print(f'{dist_all.shape=}') 53 | # print(dist_all) 54 | 55 | ## (B,) the avg dist of one sample 56 | dist_per_sam = dist_all.sum(axis=1) 57 | ## print(dist_per_sam) 58 | ## s_idxs[0] is the idx with smallest distance 59 | s_idxs = np.argsort(dist_per_sam) 60 | 61 | return s_idxs, dist_per_sam 62 | 63 | 64 | 65 | def pick_top_n_trajs(trajs_list, s_idxs, top_n, ): 66 | """ 67 | s_idxs: first one is the samllest dist one 68 | return: 69 | same structure as trajs_list, but pick out the smallest top_n 70 | trajs_list_topn: a list of len n_comp, each elem: [B,H,Dim] 71 | """ 72 | ## '# of traj candidate should be equal to # of sort idxs' 73 | assert len(s_idxs) == len(trajs_list[0]) 74 | assert top_n <= len(s_idxs) 75 | n_comp = len(trajs_list) 76 | trajs_list_topn = [] 77 | for i_c in range(n_comp): 78 | ## B, hzn,dim 79 | trajs_list_topn.append(trajs_list[i_c][ s_idxs[:top_n], ]) 80 | return trajs_list_topn 81 | 82 | 83 | def get_np_trajs_list(trajs_list, do_unnorm, normalizer): 84 | num_tj = len(trajs_list) 85 | ## to numpy 86 | trajs_list = [ to_np(trajs) for trajs in trajs_list ] 87 | ## unnormalize 88 | if do_unnorm: 89 | for i_tj in range(num_tj): 90 | trajs_list[i_tj] = normalizer.unnormalize(trajs_list[i_tj], 'observations') 91 | return trajs_list 92 | 93 | def parse_seeds_str(seeds_str: str): 94 | '''return a list of int''' 95 | out = [int(sd) for sd in seeds_str.strip().split(',')] 96 | # print(f'{out=}') 97 | # if len(out) == 1: 98 | # out = out[0] 99 | return out -------------------------------------------------------------------------------- /diffuser/utils/cp_utils/maze_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from typing import List 4 | import imageio, os 5 | 6 | 7 | def pad_traj2d(traj: np.ndarray, req_len, pad_type='last'): 8 | ''' (t, 2) -> (t+res, 2), last pad ''' 9 | residual = req_len - traj.shape[0] 10 | assert residual >= 0 11 | if residual > 0: 12 | pad = traj[-1:, :].repeat(residual, axis=0) # (1, 2) -> (res, 2) 13 | traj = np.append( traj, pad, axis=0 ) # (t+res, 2) 14 | return traj 15 | 16 | def pad_traj2d_list(env_solutions: List[np.ndarray]): 17 | '''given a list of traj with different horizon, pad them to the max horizon''' 18 | # list of np2d 19 | assert env_solutions[0].ndim == 2 20 | max_len = max([ len(s) for s in env_solutions ]) 21 | tmp = [] # new list of np 22 | for i in range(len(env_solutions)): 23 | tmp.append( pad_traj2d(env_solutions[i], max_len) ) 24 | return tmp 25 | 26 | def pad_traj2d_list_v2(env_solutions: List[np.ndarray], req_len): 27 | '''pad them to the given horizon 28 | shape [ (t, 2), ] (given a list of traj with different horizon)''' 29 | # list of np2d 30 | assert env_solutions[0].ndim == 2 31 | tmp = [] # new list of np 32 | for i in range(len(env_solutions)): 33 | tmp.append( pad_traj2d(env_solutions[i], req_len) ) 34 | return tmp 35 | 36 | def pad_traj2d_list_v3(env_solutions: List[np.ndarray], target:List[np.ndarray]): 37 | '''pad them to the given horizon 38 | shape [ (t, 2), ] (given a list of traj with different horizon)''' 39 | # list of np2d 40 | assert env_solutions[0].ndim == 2 41 | assert target[0].ndim == 2 42 | tmp = [] # new list of np 43 | for i in range(len(env_solutions)): 44 | tmp.append( pad_traj2d(env_solutions[i], len(target[i])) ) 45 | return tmp -------------------------------------------------------------------------------- /diffuser/utils/cp_utils/plan_utils.py: -------------------------------------------------------------------------------- 1 | import pdb 2 | 3 | def load_eval_problems_pb(env, pd_config): 4 | ''' 5 | loading the evaluation problems for potential based diffusion 6 | ''' 7 | 8 | if pd_config.get('load_unseen_maze', False): 9 | if pd_config.get('no_check_bit', False): 10 | npi = str(pd_config['npi']) 11 | # load no-checked problems 12 | problems_h5path = env._dataset_url.replace('.hdf5', f'-problems-nochk_{npi}pi.hdf5') 13 | assert False, "'bugfree, but don't do it now" 14 | else: 15 | assert pd_config.get('npi', 0) == 0 16 | # load checked problems 17 | problems_h5path = env._dataset_url.replace('.hdf5', '-problems.hdf5') 18 | 19 | problems_dict = env.get_dataset(h5path=problems_h5path, no_check=True) # a dict 20 | else: 21 | assert False 22 | 23 | return problems_dict 24 | 25 | 26 | 27 | ### -------- 28 | def split_trajs_list_by_prob(trajs_list, n_probs, cond_type='gl'): 29 | ''' 30 | We flatten multiple e.g., 10 problems inside one batch model forward, 31 | In this function, we unflatten the large batch, and return a list, 32 | where each element is one trajs_list of len n_comp corresponding to a problem. 33 | 34 | Args: 35 | each probs lies near: p1,p1,p1,p2,p2,... 36 | trajs_list: list of n_c : (B, h, d) 37 | ''' 38 | out_list = [] ## a list of trajs_list 39 | n_comp = len(trajs_list) 40 | b_s_all, _, _ = trajs_list[0].shape ## b_s*n_p=200,h,d 41 | 42 | ## e.g., 20 = 200 / 10 43 | n_sam_per_prob = round( b_s_all / n_probs) 44 | assert n_sam_per_prob * n_probs == b_s_all 45 | # pdb.set_trace() ## check len of trajs_list = n_comp = 4 46 | 47 | ## e.g., 0...9 --> [0:20], 20:40, ..., 180:200 48 | for i_p in range(n_probs): 49 | tmp_st = i_p * n_sam_per_prob 50 | tmp_end = (i_p+1) * n_sam_per_prob 51 | tmp_tj_l = [] ## tj_list of one prob 52 | for i_c in range(n_comp): 53 | ## append (n_sam_per_prob,h,d) 54 | tmp_tj_l.append( trajs_list[i_c][ tmp_st:tmp_end ] ) 55 | 56 | ## must under the assumption of inpainting 57 | ## ensure st and gl of the first and last traj in the batch is the same 58 | assert (tmp_tj_l[0][0, 0, :] == tmp_tj_l[0][-1, 0, :]).all() 59 | assert cond_type in ['gl', 'ret'] 60 | if cond_type == 'gl': 61 | assert (tmp_tj_l[-1][0, -1, :] == tmp_tj_l[-1][-1, -1, :]).all() 62 | 63 | ## Oct 24, check tmp_tj_l 64 | # pdb.set_trace() 65 | out_list.append( tmp_tj_l ) 66 | 67 | # pdb.set_trace() 68 | return out_list 69 | 70 | 71 | -------------------------------------------------------------------------------- /diffuser/utils/eval_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch, pdb, sys, os 3 | import torch.nn.functional as F 4 | import diffuser.utils as utils 5 | from colorama import Fore 6 | import einops, imageio, json 7 | from datetime import datetime 8 | import os.path as osp 9 | from contextlib import contextmanager 10 | 11 | 12 | 13 | def print_color(s, *args, c='r'): 14 | if c == 'r': 15 | # print(Fore.RED + s + Fore.RESET) 16 | print(Fore.RED, end='') 17 | print(s, *args, Fore.RESET) 18 | elif c == 'b': 19 | # print(Fore.BLUE + s + Fore.RESET) 20 | print(Fore.BLUE, end='') 21 | print(s, *args, Fore.RESET) 22 | elif c == 'y': 23 | # print(Fore.YELLOW + s + Fore.RESET) 24 | print(Fore.YELLOW, end='') 25 | print(s, *args, Fore.RESET) 26 | else: 27 | # print(Fore.CYAN + s + Fore.RESET) 28 | print(Fore.CYAN, end='') 29 | print(s, *args, Fore.RESET) 30 | 31 | 32 | 33 | def get_time(): 34 | return datetime.now().strftime("%y%m%d-%H%M%S") 35 | 36 | import os ## TODO: from here 37 | def get_sample_savedir(logdir, i_s, div_freq): 38 | '''get a subdir under logdir, e.g., {logdir}/0''' 39 | div_freq = 100000 40 | subdir = str( (i_s // div_freq) * div_freq ) 41 | sample_savedir = os.path.join(logdir, subdir) 42 | if not os.path.isdir(sample_savedir): 43 | os.makedirs(sample_savedir) 44 | return sample_savedir 45 | 46 | def save_img(save_path: str, img: np.ndarray): 47 | os.makedirs(osp.dirname(save_path), exist_ok=True) 48 | imageio.imsave(save_path, img) 49 | print(f'[save_img] {save_path}') 50 | 51 | 52 | 53 | def save_json(j_data: dict, full_path): 54 | with open(full_path, "w") as f: 55 | json.dump(j_data, f, indent=2) 56 | print(f'[save_json] {full_path}') 57 | 58 | def rename_fn(src_name, new_name): 59 | os.rename(src=src_name, dst=new_name) 60 | utils.print_color(f'[rename fn to] {new_name}') 61 | 62 | #### ========================= 63 | #### ========== Ben ========== 64 | 65 | 66 | def ben_get_m2d_spec(dset_type): 67 | if dset_type == 'bens_pm_large': 68 | maze_x_map_center = 6.0 69 | maze_y_map_center = 4.5 70 | elif dset_type == 'bens_pm_medium': 71 | maze_x_map_center = 4.0 72 | maze_y_map_center = 4.0 73 | elif dset_type == 'bens_pm_umaze': 74 | maze_x_map_center = 2.5 75 | maze_y_map_center = 2.5 76 | else: 77 | assert False 78 | maze_size_scaling = 1.0 79 | 80 | return maze_x_map_center, maze_y_map_center, maze_size_scaling 81 | 82 | 83 | def ben_xy_to_luo_rowcol(dset_type: str, trajs: np.ndarray): 84 | """ 85 | xy_pos: is the position in mujoco, np 1d or 2d (h,2) or 3d (B,h,2) 86 | """ 87 | 88 | maze_x_map_center, maze_y_map_center, maze_size_scaling = \ 89 | ben_get_m2d_spec(dset_type) 90 | 91 | # if trajs.ndim == 1: 92 | # trajs = trajs[None,None,] 93 | # elif trajs.ndim == 2: 94 | # trajs = trajs[None,] 95 | # pdb.set_trace() 96 | 97 | assert trajs.shape[-1] == 2 98 | 99 | rowcol_pos_1 = (trajs[..., 0:1] + maze_x_map_center) / maze_size_scaling - 0.5 100 | rowcol_pos_0 = (maze_y_map_center - trajs[..., 1:2]) / maze_size_scaling - 0.5 101 | 102 | 103 | return np.concatenate([rowcol_pos_0, rowcol_pos_1, ], axis=-1) 104 | 105 | 106 | def ben_luo_rowcol_to_xy(dset_type: str, trajs: np.ndarray): 107 | """ 108 | Oct 30 109 | xy_pos: is the position in mujoco, np 1d or 2d (h,2) or 3d (B,h,2) 110 | """ 111 | 112 | maze_x_map_center, maze_y_map_center, maze_size_scaling = \ 113 | ben_get_m2d_spec(dset_type) 114 | 115 | assert trajs.shape[-1] == 2 116 | ## dim? 117 | # pdb.set_trace() 118 | # x = (rowcol_pos[1] + 0.5) * self.maze_size_scaling - self.x_map_center 119 | tjs_x = (trajs[..., 1:2] + 0.5) * maze_size_scaling - maze_x_map_center 120 | # y = self.y_map_center - (rowcol_pos[0] + 0.5) * self.maze_size_scaling 121 | tjs_y = maze_y_map_center - (trajs[..., 0:1] + 0.5) * maze_size_scaling 122 | 123 | # pdb.set_trace() ## Check 124 | 125 | return np.concatenate([tjs_x, tjs_y, ], axis=-1) 126 | 127 | 128 | 129 | def seed_env_list(env_list, seed_list): 130 | ## seed the given list of env 131 | for i_e in range( len(env_list) ): 132 | env_list[i_e].seed( seed_list[i_e] ) 133 | return env_list 134 | 135 | 136 | #### ========================= 137 | 138 | 139 | @contextmanager 140 | def suppress_stdout(): 141 | # Save the current stdout 142 | old_stdout = sys.stdout 143 | # Redirect stdout to devnull using 'with open' 144 | with open(os.devnull, 'w') as devnull: 145 | sys.stdout = devnull 146 | try: 147 | yield 148 | finally: 149 | # Restore stdout to its original state 150 | sys.stdout = old_stdout 151 | 152 | import warnings 153 | @contextmanager 154 | def suppress_warnings(category=Warning): 155 | with warnings.catch_warnings(): 156 | warnings.simplefilter("ignore", category) 157 | yield 158 | 159 | 160 | def freeze_model(model): 161 | model.eval() 162 | # Set requires_grad to False for all parameters 163 | for param in model.parameters(): 164 | param.requires_grad = False -------------------------------------------------------------------------------- /diffuser/utils/git_utils.py: -------------------------------------------------------------------------------- 1 | import os 2 | import git 3 | import pdb 4 | 5 | PROJECT_PATH = os.path.dirname( 6 | os.path.realpath(os.path.join(__file__, '..', '..'))) 7 | 8 | def get_repo(path=PROJECT_PATH, search_parent_directories=True): 9 | repo = git.Repo( 10 | path, search_parent_directories=search_parent_directories) 11 | return repo 12 | 13 | def get_git_rev(*args, **kwargs): 14 | try: 15 | repo = get_repo(*args, **kwargs) 16 | if repo.head.is_detached: 17 | git_rev = repo.head.object.name_rev 18 | else: 19 | git_rev = repo.active_branch.commit.name_rev 20 | except: 21 | git_rev = None 22 | 23 | return git_rev 24 | 25 | def git_diff(*args, **kwargs): 26 | repo = get_repo(*args, **kwargs) 27 | diff = repo.git.diff() 28 | return diff 29 | 30 | def save_git_diff(savepath, *args, **kwargs): 31 | diff = git_diff(*args, **kwargs) 32 | with open(savepath, 'w') as f: 33 | f.write(diff) 34 | 35 | if __name__ == '__main__': 36 | 37 | git_rev = get_git_rev() 38 | print(git_rev) 39 | 40 | save_git_diff('diff_test.txt') -------------------------------------------------------------------------------- /diffuser/utils/ogb_paper_vis_utils/README.md: -------------------------------------------------------------------------------- 1 | Files inside this folder are used to create similar OGBench visualization inside the CompDiffuser paper. We put multiple (dozens of) agents (e.g., ants) to the environments to make figures with a movement trajectory of ants. 2 | 3 | -------------------------------------------------------------------------------- /diffuser/utils/ogb_paper_vis_utils/__init__.py: -------------------------------------------------------------------------------- 1 | from diffuser.utils.ogb_paper_vis_utils.ogb_vis_multi_agent_utils import ogb_vis_create_multi_ant_environment 2 | from diffuser.utils.ogb_paper_vis_utils.ogb_vis_multi_agent_env import ogb_make_maze_env_Multi_Agent_Luo -------------------------------------------------------------------------------- /diffuser/utils/ogb_paper_vis_utils/vis_misc_utils.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def ogb_get_Maze_stgl_from_tk_idx(env_name, tk_idx): 4 | """ 5 | Only for Maze Tasks in OGBench 6 | """ 7 | if '-medium' in env_name: 8 | if tk_idx == 1: 9 | st_gl = np.array([[1, 1.], [6, 6.]]) 10 | elif tk_idx == 2: 11 | st_gl = np.array([[ 6., 1 ], [ 1, 6 ]]) 12 | 13 | elif tk_idx == 3: 14 | st_gl = np.array([[ 5, 3. ], [ 4, 2 ]]) 15 | 16 | elif tk_idx == 4: 17 | st_gl = np.array([[ 6, 5. ], [ 6, 1 ]]) 18 | 19 | elif tk_idx == 5: 20 | st_gl = np.array([[ 2., 6 ], [ 1, 1. ]]) 21 | 22 | 23 | elif '-large' in env_name: 24 | if tk_idx == 1: 25 | st_gl = np.array([[1, 1.], [7,10.]]) ## Large Tk 1 26 | elif tk_idx == 2: 27 | st_gl = np.array([ [5, 4.], [7, 1.]]) ## Large TK 2 28 | elif tk_idx == 3: 29 | st_gl = np.array([ [7, 4.], [1, 10.]]) ## Seed 1 30 | elif tk_idx == 4: 31 | st_gl = np.array([ [3, 8.], [5, 4.]]) 32 | elif tk_idx == 5: 33 | st_gl = np.array([ [1, 1.], [5, 4.]]) ## Seed 0, tk 5 34 | 35 | elif '-giant' in env_name: 36 | if tk_idx == 1: 37 | st_gl = np.array([[1, 1.], [10,14.]]) 38 | elif tk_idx == 2: 39 | st_gl = np.array([[1, 14.], [10,1.]]) 40 | elif tk_idx == 3: 41 | st_gl = np.array([[8, 14.], [1.,1.]]) 42 | elif tk_idx == 4: 43 | st_gl = np.array([[8, 3.], [5,12]]) 44 | elif tk_idx == 5: 45 | st_gl = np.array([[5, 9.], [3, 8]]) 46 | else: 47 | raise NotImplementedError 48 | 49 | return st_gl 50 | 51 | 52 | def ogb_get_antSoccer_stgl_from_tk_idx(env_name, tk_idx): 53 | """ 54 | Only for Maze Tasks in OGBench 55 | """ 56 | if '-medium' in env_name: 57 | if tk_idx == 1: 58 | st_gl = np.array([[1, 1., 3., 4.], [6, 6., 6., 6.,]]) 59 | elif tk_idx == 2: 60 | st_gl = np.array([[ 6., 1, 6, 5], [ 1, 1., 1., 1. ]]) 61 | 62 | elif tk_idx == 3: 63 | st_gl = np.array([[ 5, 3., 4, 2. ], [ 6, 5, 6, 5. ]]) 64 | 65 | elif tk_idx == 4: 66 | st_gl = np.array([[ 6, 5., 1., 1. ], [ 5, 3., 5., 3 ]]) 67 | 68 | elif tk_idx == 5: 69 | st_gl = np.array([[ 1., 6, 6, 1. ], [ 1, 6., 1., 6. ]]) 70 | 71 | elif '-arena' in env_name: 72 | if tk_idx == 1: 73 | st_gl = np.array([[1, 6., 2., 3.], [5, 2., 5., 2.,]]) 74 | 75 | elif tk_idx == 2: 76 | st_gl = np.array([[ 1, 1., 5, 5. ], [ 1., 1, 1, 1 ]]) 77 | 78 | elif tk_idx == 3: 79 | st_gl = np.array([[ 6, 1., 2, 3. ], [ 6, 6, 6, 6. ]]) 80 | 81 | elif tk_idx == 4: 82 | st_gl = np.array([[ 6, 6., 1., 1. ], [ 6., 1., 6, 1. ]]) 83 | 84 | elif tk_idx == 5: 85 | st_gl = np.array([[ 4., 6, 6, 2. ], [ 1, 6., 1., 6. ]]) 86 | 87 | return st_gl 88 | 89 | def ogb_ij_to_xy(ij_trajs): 90 | maze_unit = 4 91 | _offset_x, _offset_y = 4, 4 92 | assert ij_trajs.ndim in [2, 3] and ij_trajs.shape[-1] == 2 93 | x = ij_trajs[..., 1:2] * maze_unit - _offset_x 94 | y = ij_trajs[..., 0:1] * maze_unit - _offset_y 95 | 96 | out = np.concatenate([x, y], axis=-1) 97 | return out 98 | 99 | def ogb_ij_to_xy_4d(ij_trajs): 100 | maze_unit = 4 101 | _offset_x, _offset_y = 4, 4 102 | assert ij_trajs.ndim in [2, 3] and ij_trajs.shape[-1] in [2, 4] 103 | x_1 = ij_trajs[..., 1:2] * maze_unit - _offset_x 104 | y_1 = ij_trajs[..., 0:1] * maze_unit - _offset_y 105 | 106 | x_2 = ij_trajs[..., 3:4] * maze_unit - _offset_x 107 | y_2 = ij_trajs[..., 2:3] * maze_unit - _offset_y 108 | 109 | out = np.concatenate([x_1, y_1, x_2, y_2], axis=-1) 110 | return out -------------------------------------------------------------------------------- /diffuser/utils/progress.py: -------------------------------------------------------------------------------- 1 | import time 2 | import math 3 | import pdb 4 | 5 | class Progress: 6 | 7 | def __init__(self, total, name = 'Progress', ncol=3, max_length=20, indent=0, line_width=100, speed_update_freq=100): 8 | self.total = total 9 | self.name = name 10 | self.ncol = ncol 11 | self.max_length = max_length 12 | self.indent = indent 13 | self.line_width = line_width 14 | self._speed_update_freq = speed_update_freq 15 | 16 | self._step = 0 17 | self._prev_line = '\033[F' 18 | self._clear_line = ' ' * self.line_width 19 | 20 | self._pbar_size = self.ncol * self.max_length 21 | self._complete_pbar = '#' * self._pbar_size 22 | self._incomplete_pbar = ' ' * self._pbar_size 23 | 24 | self.lines = [''] 25 | self.fraction = '{} / {}'.format(0, self.total) 26 | 27 | self.resume() 28 | 29 | 30 | def update(self, description, n=1): 31 | self._step += n 32 | if self._step % self._speed_update_freq == 0: 33 | self._time0 = time.time() 34 | self._step0 = self._step 35 | self.set_description(description) 36 | 37 | def resume(self): 38 | self._skip_lines = 1 39 | print('\n', end='') 40 | self._time0 = time.time() 41 | self._step0 = self._step 42 | 43 | def pause(self): 44 | self._clear() 45 | self._skip_lines = 1 46 | 47 | def set_description(self, params=[]): 48 | 49 | if type(params) == dict: 50 | params = sorted([ 51 | (key, val) 52 | for key, val in params.items() 53 | ]) 54 | 55 | ############ 56 | # Position # 57 | ############ 58 | self._clear() 59 | 60 | ########### 61 | # Percent # 62 | ########### 63 | percent, fraction = self._format_percent(self._step, self.total) 64 | self.fraction = fraction 65 | 66 | ######### 67 | # Speed # 68 | ######### 69 | speed = self._format_speed(self._step) 70 | 71 | ########## 72 | # Params # 73 | ########## 74 | num_params = len(params) 75 | nrow = math.ceil(num_params / self.ncol) 76 | params_split = self._chunk(params, self.ncol) 77 | params_string, lines = self._format(params_split) 78 | self.lines = lines 79 | 80 | 81 | description = '{} | {}{}'.format(percent, speed, params_string) 82 | print(description) 83 | self._skip_lines = nrow + 1 84 | 85 | def append_description(self, descr): 86 | self.lines.append(descr) 87 | 88 | def _clear(self): 89 | position = self._prev_line * self._skip_lines 90 | empty = '\n'.join([self._clear_line for _ in range(self._skip_lines)]) 91 | print(position, end='') 92 | print(empty) 93 | print(position, end='') 94 | 95 | def _format_percent(self, n, total): 96 | if total: 97 | percent = n / float(total) 98 | 99 | complete_entries = int(percent * self._pbar_size) 100 | incomplete_entries = self._pbar_size - complete_entries 101 | 102 | pbar = self._complete_pbar[:complete_entries] + self._incomplete_pbar[:incomplete_entries] 103 | fraction = '{} / {}'.format(n, total) 104 | string = '{} [{}] {:3d}%'.format(fraction, pbar, int(percent*100)) 105 | else: 106 | fraction = '{}'.format(n) 107 | string = '{} iterations'.format(n) 108 | return string, fraction 109 | 110 | def _format_speed(self, n): 111 | num_steps = n - self._step0 112 | t = time.time() - self._time0 113 | speed = num_steps / t 114 | string = '{:.1f} Hz'.format(speed) 115 | if num_steps > 0: 116 | self._speed = string 117 | return string 118 | 119 | def _chunk(self, l, n): 120 | return [l[i:i+n] for i in range(0, len(l), n)] 121 | 122 | def _format(self, chunks): 123 | lines = [self._format_chunk(chunk) for chunk in chunks] 124 | lines.insert(0,'') 125 | padding = '\n' + ' '*self.indent 126 | string = padding.join(lines) 127 | return string, lines 128 | 129 | def _format_chunk(self, chunk): 130 | line = ' | '.join([self._format_param(param) for param in chunk]) 131 | return line 132 | 133 | def _format_param(self, param): 134 | k, v = param 135 | return '{} : {}'.format(k, v)[:self.max_length] 136 | 137 | def stamp(self): 138 | if self.lines != ['']: 139 | params = ' | '.join(self.lines) 140 | string = '[ {} ] {}{} | {}'.format(self.name, self.fraction, params, self._speed) 141 | self._clear() 142 | print(string, end='\n') 143 | self._skip_lines = 1 144 | else: 145 | self._clear() 146 | self._skip_lines = 0 147 | 148 | def close(self): 149 | self.pause() 150 | 151 | class Silent: 152 | 153 | def __init__(self, *args, **kwargs): 154 | pass 155 | 156 | def __getattr__(self, attr): 157 | return lambda *args: None 158 | 159 | 160 | if __name__ == '__main__': 161 | silent = Silent() 162 | silent.update() 163 | silent.stamp() 164 | 165 | num_steps = 1000 166 | progress = Progress(num_steps) 167 | for i in range(num_steps): 168 | progress.update() 169 | params = [ 170 | ['A', '{:06d}'.format(i)], 171 | ['B', '{:06d}'.format(i)], 172 | ['C', '{:06d}'.format(i)], 173 | ['D', '{:06d}'.format(i)], 174 | ['E', '{:06d}'.format(i)], 175 | ['F', '{:06d}'.format(i)], 176 | ['G', '{:06d}'.format(i)], 177 | ['H', '{:06d}'.format(i)], 178 | ] 179 | progress.set_description(params) 180 | time.sleep(0.01) 181 | progress.close() 182 | -------------------------------------------------------------------------------- /diffuser/utils/timer.py: -------------------------------------------------------------------------------- 1 | import time 2 | 3 | class Timer: 4 | 5 | def __init__(self): 6 | self._start = time.time() 7 | 8 | def __call__(self, reset=True): 9 | now = time.time() 10 | diff = now - self._start 11 | if reset: 12 | self._start = now 13 | return diff -------------------------------------------------------------------------------- /diffuser/utils/train_utils.py: -------------------------------------------------------------------------------- 1 | import torch 2 | 3 | def get_lr(optimizer: torch.optim.Optimizer): 4 | """Get the learning rate of current optimizer.""" 5 | return optimizer.param_groups[0]['lr'] 6 | -------------------------------------------------------------------------------- /logs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devinluo27/comp_diffuser_release/77fd69c9e6107a008b5cfea12195e3d06ed1aff7/logs/.gitkeep -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | 3 | setup( 4 | name = 'comp_diffuser', 5 | packages = find_packages(), 6 | ) 7 | --------------------------------------------------------------------------------