Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generative Trajectory Stitching through Diffusion Composition

[Project page][Paper][ArXiv]

Yunhao Luo1, Utkarsh A. Mishra1, Yilun Du2,†, Danfei Xu1,†

1Georgia Tech, 2Harvard, Equal Advising

This is the official implementation for "Generative Trajectory Stitching through Diffusion Composition".

potential composition illustration.

Compositional Trajectory Planning: Parallel Sampling and Autoregressive Sampling. We present an illustrative example of sampling three trajectories $\tau_{1:3}$ with the proposed compositional sampling methods. Dashed lines represent cross trajectory information exchange between adjacent trajectories and black lines represent the denoising flow of each trajectory. In parallel sampling, $\tau_{1:3}$ can be denoised concurrently; while in autoregressive sampling, denoising $\tau_k$ depends on the previous trajectory $\tau_{k-1}$, e.g., the denoising of $\tau_2$ depends on $\tau_1$ (as shown in the blue horizontal dashed arrows). Additionally, start state $q_s$ and goal state $q_g$ conditioning are applied to the trajectories in the two ends, $\tau_1$ and $\tau_3$, which enables goal-conditioned planning. Trajectories $\tau_{1:3}$ will be merged to form a longer plan $\tau_{\text{comp}}$ after the full diffusion denoising process.


potential composition illustration.

Denoising Process of CompDiffuser.

🛠️ Installation

The following procedure should work well for a GPU machine with cuda 12.1. Our machine is installed with Ubuntu 20.04.6 LTS.

Please follow the steps below to create a conda environment to reproduce our simulation benchmark results on OGBench environments.

  1. Create a python env.
conda create -n compdfu_ogb_release python=3.9.20

Please keep the conda env name as above, since it is used as an identifier in the python code.

  1. Install packages in requirements.txt (this might take several minutes).
pip install -r conda_env/requirements.txt
  1. Install gymnasium, gymnasium-robotics, and torch 2.5.0.
./conda_env/install_pre.sh 
  1. Clone the CompDiffuser customized OGBench codebase ogbench_cpdfu_release and install it to conda env compdfu_ogb_release. (Our major revision is adding some rendering code to the official OGBench.)
## Please set the OGBench path in the script before running this line./conda_env/install_ogb.sh

After these steps, you can use conda env compdfu_ogb_release to launch experiments.

🗃️ Prepare Data

  1. Download the official OGBench datasets for model training.
    We provide a jupyter notebook file at conda_env/ogb_dset_download.ipynb to download the official OGBench datasets. The datasets will be downloaded to ~/.ogbench/data/ by default and you only need to download the corresponding datasets that you want to use, such as antmaze-giant-stitch-v0 and pointmaze-large-stitch-v0. Please see the OGBench paper for a full list of available environments.

  2. Evaluation problem sets.
    We provide an evaluation problem set for each OGBench environment we use at data/ogb_maze/ev_probs, which are already stored in this repo. Each of those .hdf5 files stores 100 pairs of start state and goal state (5 evaluation tasks with 20 evaluation problems per task).

🕹️ Train CompDiffuser Planner

Please download the official OGBench datasets first before starting to train models. To launch the training for CompDiffuser, run

sh ./diffuser/ogb_task/ogb_maze_v1/train_ogb_stgl_sml.sh

You can change the $config variable inside the script above to launch different experiments.

We provide a config config/og_antM_Gi_o2d_luotest.py for debugging purposes. Note that for this file, we set the train dataset to a very small subset of the official dataset for faster data loading. The dataset switching is done by dset_h5path in this config file; otherwise, it will load the full official datasets if this varibale is not set. Hence, please comment out or remove this variable after debugging (e.g., if you want to reproduce our results).

We also provide configs to train CompDiffuser in each OGBench environment. For example, for antmaze-large-stitch-v0, we can set the config file to

## planning in 2D (x-y) state spaceconfig=config/ogb_ant_maze/og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py## planning in full 29D state spaceconfig=config/ogb_ant_maze/og_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512.py

More provided config files are inside the config/ folder.

🕹️ Train Inverse Dynamics Model

The diffusion planner generates a trajectory of agent states (e.g., x-y position, joint states). We then use an inverse dynamic model to predict actions for the agent to execute in the environment (except for pointmaze where we use a PD controller).
Specifically, the inverse dynamic model is an MLP that takes the current agent state and a synthesized goal state as input and will output an action.

We provide code to train such models, run (similarly, check the $config in the script first)

sh ./diffuser/ogb_task/og_inv_dyn/train_og_invdyn.sh

Note that we provide config file to train the inverse dynamics models for multiple environments. Please set the $config inside the script to the path you need before starting the training. For example, if you want to train a model for antmaze-large-stitch-v0 and the diffusion planner generates the full 29D trajectory (hence the synthesied goal is 29D), $config should be set to

config=config/ogb_invdyn/og_inv_ant/og_antM_Lg_o29d_g29d_invdyn_h12.py

📊 Using Pretrained Models

Downloading weights

We provide links to pre-trained CompDiffuser planner and inverse dynamics models below, along with their corresponding config files. All models are hosted under this OneDrive folder.

For pointmaze env (config files are in folder config/ogb_pnt_maze):

EnvLinkConfig
pointmaze-giant-stitch-v0Linkog_pntM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-large-stitch-v0Linkog_pntM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py
pointmaze-medium-stitch-v0Linkog_pntM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512.py

For antmaze env (config files are in folder config/ogb_ant_maze, please also download the weights of the pre-trained inverse dynamics models):

EnvLinkConfig
antmaze-giant-stitch-v0Link / Link(inv dyn)og_antM_Gi_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-large-stitch-v0Link / Link(inv dyn)og_antM_Lg_o2d_Cd_Stgl_PadBuf_Ft64_ts512
antmaze-medium-stitch-v0Link / Link(inv dyn)og_antM_Me_o2d_Cd_Stgl_PadBuf_Ft64_ts512

Additionally, we also provide checkpoints for high-dimenstional planner in OGBench antmaze-large-stitch-v0 environment inside this oneDrive folder (also see Table 4 of our paper).

EnvDimConfig
antmaze-large-stitch-v015Dog_antM_Lg_o15d_PadBuf_Ft64_ts512_DiTd768dp16_fs4_h160_ovlp56Mdit
antmaze-large-stitch-v029Dog_antM_Lg_o29d_DiTd1024dp12_PadBuf_Ft64_fs4_h160_ovlp56MditD512

Unzip Downloaded Files

You need to put the downloaded zip files in the root directory of this repo and unzip them, so that the created files can be in proper relative locations. The files will be automatically put under the logs folder, which is organized roughly according to the following structure (some additional prefix and postfix might be added):

└── logs
├── ${environment_1}
│ ├── diffusion
│ │ └── ${experiment_name}
│ │ ├── model-${iter}.pt
│ │ └── {dataset, trainer}_config.pkl
│ └── plans
│ └── ${experiment_name}
│ ├── 0
│ ├── {experiment_time:%y%m%d-%H%M%S}
│ ├── ...
│
├── ${environment_2}
│ └── ...

The state_${iter}.pt files contain the network weights and the {}_config.pkl files contain the instantation arguments for the relevant classes.

Policy Rollout

After downloading and unzipping the model weights, you can launch planner rollout using the script provided below. The results will be saved in .mp4 and .json files. To evaluate different models, you can change the $config varibale inside the script, which should be the relative path to a config file.

For OGBench environments, run:

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

Please replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

➕ Add an Experiment

We create a new config file under the config folder for a new experiment. Each experiment will create a new folder under logs. You can refer to existing config files as examples.

📔 Baselines

Decision Diffuser

We provide implementation of Decision Diffuser (DD) in diffuser/baselines.

To train a DD planner, run

./diffuser/baselines/dd_ogb/train_dd_ogb.sh

To evaluate a DD planner, run

./diffuser/baselines/dd_ogb/plan_dd_ogb.sh

Generative Skill Chaining (GSC)

We also provide implementation of GSC. Note that since our task setup is different with the tasks in the GSC paper, our implementation also slightly differs (See Appendix F of our CompDiffuser paper for details).

You can directly perform GSC style inference, by setting

args.ev_cp_infer_t_type='gsc'

in diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.py, then run

sh ./diffuser/ogb_task/ogb_maze_v1/plan_ogb_stgl_sml.sh $1 $2 $3

replace $1 by a GPU index (e.g., 0), $2 by how many episodes to evaluate on (e.g., some number between 1 and 100), and $3 by a seed (i.e., an integer 0).

CompDiffuser Variants

Two variants of CompDiffuser are available Parallel Denosing (as shown in the figure above) and backward autoregessive (See Appendix B.4 of the paper). Similarly, set

args.ev_cp_infer_t_type='same_t_p'# for parallel## orargs.ev_cp_infer_t_type='ar_back'# for backward autoregressive

🎨 Visualization

See diffuser/utils/ogb_paper_vis_utils/ for the modified mujoco env to create multi-agent (e.g., multi-ants) env, which is used to render the figures in our paper. We might add more instructions later.

🏷️ License

This repository is released under the MIT license. See LICENSE for additional details.

🙏 Acknowledgement

Contact Yunhao Luo if you have any questions or suggestions. We may update and add more code implementation upon request.

📝 Citations

If you find our work useful, please consider citing:

@article{luo2025generative,
title={Generative Trajectory Stitching through Diffusion Composition},
author={Luo, Yunhao and Mishra, Utkarsh A and Du, Yilun and Xu, Danfei},
journal={arXiv preprint arXiv:2503.05153},
year={2025}
}

About

[NeurIPS 2025 Spotlight] Generative Trajectory Stitching through Diffusion Composition

Resources

Stars

77 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages