Dancing Diffusion: Learning Continuous Programs for Image Generation and Editing
Organizations: Renmin University of China · Institute of Automation, Chinese Academy of Sciences
Abstract
Diffusion models generate samples through a multi-step denoising trajectory, yet condition every step on the same instruction, so the trajectory cannot be addressed at the level of individual operations. We introduce Dancing Diffusion, which assigns each span of timesteps a dedicated continuous condition block and thereby turns conditioning into a latent program. A compiler maps text features into this program, and a fixed pretrained generator executes its blocks over successive sampling intervals. The trajectory can then dance, keeping its executed history while its continuation is redirected. A shared prefix is executed once and reused, and a later operation is rewritten while content fixed by earlier operations is preserved. The compiler is trained through the images it produces, with visual feedback on both the requested change and the retained content. On SANA, reusing an executed prefix preserves markedly more of the scene than regenerating from noise at a similar strength of edit, learned conditions preserve more background than native prompt switching from the same saved state, and the learned program improves generation quality over native SANA. Later branches weaken the edit, which leaves semantic control over individual operations limited. By converting a single-instruction trajectory into a program of addressable operations, Dancing Diffusion lays a foundation for structured intermediate computation in diffusion models.
Figures & tables
| Method | 3/9/18 | 6/12/12 | 9/12/9 |
|---|---|---|---|
| Full regeneration | 0.383 / 13 / 27 | 0.334 / 11 / 29 | 0.307 / 14 / 29 |
| Learned suffix | 0.254 / 14 / 29 | 0.247 / 15 / 27 | 0.242 / 14 / 25 |
| Native suffix | 0.269 / 14 / 28 | 0.274 / 14 / 26 | 0.269 / 17 / 27 |
| SDEdit–SANA | 0.284 / 16 / 28 | 0.288 / 16 / 27 | 0.293 / 12 / 27 |
| FlowEdit–SANA | 0.143 / 13 / 27 | 0.138 / 12 / 25 | 0.142 / 12 / 24 |
| Method / schedule | Initialization | Update 600 | Final 1423 | vs. native |
|---|---|---|---|---|
| Native SANA | 7.349 (no adaptation) | — | ||
| 3/9/18 | 7.248 | 7.203 | 7.315 | -0.034 |
| 6/12/12 | 7.268 | 7.247 | 7.145 | -0.204 |
| 9/12/9 | 7.411 | 7.466 | 7.375 | +0.026 |
Appendix figures & tables35 assets
Supplementary material from the paper’s appendix.
Appendix
| Method | Source access | Question |
|---|---|---|
| Full regeneration | Same initial noise | Value of retaining source history |
| Native suffix | Same saved state | Value of learned future conditions |
| Initialized compiler | Same saved state | Effect of adaptation |
| SDEdit–SANA adaptation | Source PNG, re-noising | Image-input denoising control |
| FlowEdit–SANA adaptation | Source PNG, source/target velocities | Image-input flow editing control |
| Detector | Threshold | Audit precision | Audit recall |
|---|---|---|---|
| Grounding DINO tiny | 0.40 | 0.886 | 0.819 |
| OWLv2 base ensemble | 0.31 | 0.900 | 0.861 |
| Method | Start | BG LPIPS | Coverage | DINO T/R | OWLv2 T/R |
|---|---|---|---|---|---|
| Full regeneration | 0 | 0.383 | 32/36 | 35/13 | 36/27 |
| Learned suffix | 9 | 0.254 | 32/36 | 36/14 | 36/29 |
| Learned suffix | 15 | 0.125 | 32/36 | 34/12 | 35/25 |
| Learned suffix | 21 | 0.037 | 32/36 | 30/0 | 17/8 |
| Native suffix | 9 | 0.269 | 32/36 | 36/14 | 36/28 |
| Native suffix | 15 | 0.122 | 32/36 | 34/13 | 35/23 |
| Method | Start | BG LPIPS | Coverage | DINO T/R | OWLv2 T/R |
|---|---|---|---|---|---|
| Full regeneration | 0 | 0.334 | 33/36 | 34/11 | 35/29 |
| Learned suffix | 9 | 0.247 | 33/36 | 35/15 | 36/27 |
| Learned suffix | 15 | 0.129 | 33/36 | 34/13 | 33/26 |
| Learned suffix | 21 | 0.038 | 33/36 | 31/1 | 23/11 |
| Native suffix | 9 | 0.274 | 33/36 | 35/14 | 36/26 |
| Native suffix | 15 | 0.131 | 33/36 | 35/13 | 33/24 |
| Method | Start | BG LPIPS | Coverage | DINO T/R | OWLv2 T/R |
|---|---|---|---|---|---|
| Full regeneration | 0 | 0.307 | 33/36 | 35/14 | 35/29 |
| Learned suffix | 9 | 0.242 | 33/36 | 35/14 | 34/25 |
| Learned suffix | 15 | 0.121 | 33/36 | 35/13 | 34/25 |
| Learned suffix | 21 | 0.043 | 33/36 | 30/2 | 21/6 |
| Native suffix | 9 | 0.269 | 33/36 | 36/17 | 36/27 |
| Native suffix | 15 | 0.126 | 33/36 | 36/11 | 34/23 |
| Schedule | Method | Start 9 | Start 15 | Start 21 | Coverage |
|---|---|---|---|---|---|
| 3/9/18 | SDEdit–SANA | 0.265 | 0.288 | 0.269 | 63/72 |
| 3/9/18 | FlowEdit–SANA | 0.122 | 0.066 | 0.041 | 63/72 |
| 6/12/12 | SDEdit–SANA | 0.273 | 0.291 | 0.273 | 61/72 |
| 6/12/12 | FlowEdit–SANA | 0.122 | 0.067 | 0.042 | 61/72 |
| 9/12/9 | SDEdit–SANA | 0.282 | 0.296 | 0.282 | 60/72 |
| 9/12/9 | FlowEdit–SANA | 0.127 | 0.066 | 0.042 | 60/72 |
| Schedule; branch | CLIP | BG LPIPS | BG PSNR | BG SSIM |
|---|---|---|---|---|
| 3/9/18; 0 | 0.097 (72/72) | 0.352 (63/72) | 15.652 (63/72) | 0.572 (63/72) |
| 3/9/18; 9 | 0.092 (72/72) | 0.225 (63/72) | 19.073 (63/72) | 0.701 (63/72) |
| 3/9/18; 15 | 0.076 (72/72) | 0.108 (63/72) | 24.316 (63/72) | 0.837 (63/72) |
| 3/9/18; 21 | 0.028 (72/72) | 0.030 (63/72) | 31.710 (63/72) | 0.946 (63/72) |
| 6/12/12; 0 | 0.092 (72/72) | 0.321 (61/72) | 16.500 (61/72) | 0.599 (61/72) |
| 6/12/12; 9 | 0.088 (72/72) | 0.227 (61/72) | 19.096 (61/72) | 0.697 (61/72) |
| Schedule; branch | CLIP | BG LPIPS | BG PSNR | BG SSIM |
|---|---|---|---|---|
| 3/9/18; 0 | 0.049 (72/72) | 0.415 (10/72) | 15.553 (10/72) | 0.561 (10/72) |
| 3/9/18; 9 | 0.042 (72/72) | 0.198 (10/72) | 21.826 (10/72) | 0.780 (10/72) |
| 6/12/12; 0 | 0.048 (72/72) | 0.451 (11/72) | 15.372 (11/72) | 0.538 (11/72) |
| 6/12/12; 9 | 0.041 (72/72) | 0.244 (11/72) | 20.267 (11/72) | 0.729 (11/72) |
| 9/12/9; 0 | 0.047 (72/72) | 0.425 (12/72) | 16.233 (12/72) | 0.598 (12/72) |
| 9/12/9; 9 | 0.042 (72/72) | 0.252 (12/72) | 20.327 (12/72) | 0.745 (12/72) |
| Schedule; branch | Whole LPIPS | PNG MSE | Latent MSE |
|---|---|---|---|
| 3/9/18; 9 | 0.050 (24/24) | 0.003 (24/24) | 0.020 (24/24) |
| 3/9/18; 15 | 0.018 (24/24) | 0.001 (24/24) | 0.004 (24/24) |
| 3/9/18; 21 | 0.005 (24/24) | 0.000 (24/24) | 0.000 (24/24) |
| 6/12/12; 9 | 0.057 (24/24) | 0.003 (24/24) | 0.019 (24/24) |
| 6/12/12; 15 | 0.031 (24/24) | 0.001 (24/24) | 0.006 (24/24) |
| 6/12/12; 21 | 0.012 (24/24) | 0.000 (24/24) | 0.001 (24/24) |
| Branch | Control | IF | VC | VQ |
|---|---|---|---|---|
| 9 | Initial | 11.1/6.9/22.2/59.7/0.0 | 9.7/12.5/34.7/43.1/0.0 | 9.7/22.2/41.7/26.4/0.0 |
| 9 | Update 600 | 9.7/9.7/11.1/69.4/0.0 | 8.3/8.3/25.0/58.3/0.0 | 11.1/12.5/44.4/31.9/0.0 |
| 15 | Initial | 0.0/5.6/13.9/80.6/0.0 | 2.8/12.5/19.4/65.3/0.0 | 4.2/9.7/20.8/65.3/0.0 |
| 15 | Update 600 | 0.0/5.6/9.7/84.7/0.0 | 0.0/5.6/18.1/76.4/0.0 | 2.8/8.3/18.1/70.8/0.0 |
| 21 | Initial | 0.0/0.0/0.0/100.0/0.0 | 0.0/0.0/0.0/100.0/0.0 | 0.0/0.0/0.0/100.0/0.0 |
| 21 | Update 600 | 0.0/0.0/0.0/100.0/0.0 | 0.0/0.0/1.4/98.6/0.0 | 0.0/0.0/0.0/100.0/0.0 |
| Branch | Control | IF | VC | VQ |
|---|---|---|---|---|
| 9 | Initial | 11.1/4.2/22.2/62.5/0.0 | 12.5/6.9/38.9/41.7/0.0 | 11.1/27.8/48.6/12.5/0.0 |
| 9 | Update 600 | 6.9/2.8/23.6/66.7/0.0 | 6.9/9.7/27.8/55.6/0.0 | 16.7/11.1/40.3/31.9/0.0 |
| 15 | Initial | 6.9/4.2/16.7/72.2/0.0 | 5.6/11.1/27.8/55.6/0.0 | 5.6/16.7/19.4/58.3/0.0 |
| 15 | Update 600 | 4.2/2.8/6.9/86.1/0.0 | 2.8/5.6/20.8/70.8/0.0 | 2.8/15.3/13.9/68.1/0.0 |
| 21 | Initial | 0.0/0.0/5.6/94.4/0.0 | 1.4/2.8/18.1/77.8/0.0 | 0.0/0.0/11.1/88.9/0.0 |
| 21 | Update 600 | 0.0/0.0/1.4/98.6/0.0 | 1.4/0.0/9.7/88.9/0.0 | 0.0/1.4/2.8/95.8/0.0 |
| Branch | Control | IF | VC | VQ |
|---|---|---|---|---|
| 9 | Initial | 5.6/22.2/26.4/45.8/0.0 | 11.1/26.4/36.1/26.4/0.0 | 16.7/36.1/40.3/6.9/0.0 |
| 9 | Update 600 | 6.9/9.7/23.6/59.7/0.0 | 11.1/22.2/25.0/41.7/0.0 | 8.3/23.6/51.4/16.7/0.0 |
| 9 | Native suffix | 25.0/33.3/22.2/19.4/0.0 | 33.3/29.2/31.9/5.6/0.0 | 22.2/37.5/40.3/0.0/0.0 |
| 15 | Initial | 2.8/12.5/15.3/69.4/0.0 | 4.2/22.2/31.9/41.7/0.0 | 4.2/19.4/41.7/34.7/0.0 |
| 15 | Update 600 | 4.2/6.9/18.1/70.8/0.0 | 4.2/18.1/30.6/47.2/0.0 | 5.6/16.7/34.7/43.1/0.0 |
| 15 | Native suffix | 6.9/23.6/29.2/40.3/0.0 | 18.1/22.2/43.1/16.7/0.0 | 18.1/37.5/31.9/12.5/0.0 |
| Schedule | Valid masks | BG LPIPS [95% CI] | semantic proxy [95% CI] |
|---|---|---|---|
| 3/9/18 | 63/72 | -0.1248 [-0.1588, -0.0936] | -0.0046 [-0.0086, -0.0010] |
| 6/12/12 | 61/72 | -0.0924 [-0.1115, -0.0740] | -0.0037 [-0.0070, -0.0005] |
| 9/12/9 | 60/72 | -0.0696 [-0.0948, -0.0458] | -0.0007 [-0.0039, 0.0029] |
| Branch | Native | Trained | Lower in | [descriptive 95% interval] |
|---|---|---|---|---|
| 9 | 0.2528 | 0.2296 | 41/60 | [ , ] |
| 15 | 0.1134 | 0.1134 | 28/60 | [ , ] |
| 21 | 0.0305 | 0.0398 | 8/60 | [ , ] |
| Schedule | pad | Regen. | FlowEdit | SDEdit | Native | |
|---|---|---|---|---|---|---|
| 3-9-18 | 0% | 68/72 | ||||
| 3-9-18 | 5% | 65/72 | ||||
| 3-9-18 | 10% | 62/72 | ||||
| 6-12-12 | 0% | 66/72 | ||||
| 6-12-12 | 5% | 62/72 | ||||
| 6-12-12 | 10% | 60/72 |
| Schedule | pad | Regen. | FlowEdit | SDEdit | Native | |
|---|---|---|---|---|---|---|
| 3-9-18 | 0% | 33/36 | ||||
| 3-9-18 | 5% | 30/36 | ||||
| 3-9-18 | 10% | 30/36 | ||||
| 6-12-12 | 0% | 33/36 | ||||
| 6-12-12 | 5% | 30/36 | ||||
| 6-12-12 | 10% | 30/36 |
| Comparator | Schedule | pad | [95% interval] | |
| Regeneration | 3-9-18 | 0% | 68/72 | |
| Regeneration | 3-9-18 | 5% | 65/72 | |
| Regeneration | 3-9-18 | 10% | 62/72 | |
| Regeneration | 6-12-12 | 0% | 66/72 | |
| Regeneration | 6-12-12 | 5% | 62/72 | |
| Regeneration | 6-12-12 | 10% | 60/72 |
| Schedule | Branch | pad 0% | pad 5% | pad 10% |
|---|---|---|---|---|
| 3-9-18 | 9 | (68/72) | (65/72) | (62/72) |
| 3-9-18 | 15 | (68/72) | (65/72) | (62/72) |
| 3-9-18 | 21 | (68/72) | (65/72) | (62/72) |
| 6-12-12 | 9 | (66/72) | (62/72) | (60/72) |
| 6-12-12 | 15 | (66/72) | (62/72) | (60/72) |
| 6-12-12 | 21 | (66/72) | (62/72) | (60/72) |
| Schedule | Branch | pad 0% | pad 5% | pad 10% |
|---|---|---|---|---|
| 3-9-18 | 9 | (33/36) | (30/36) | (30/36) |
| 3-9-18 | 15 | (33/36) | (30/36) | (30/36) |
| 3-9-18 | 21 | (33/36) | (30/36) | (30/36) |
| 6-12-12 | 9 | (33/36) | (30/36) | (30/36) |
| 6-12-12 | 15 | (33/36) | (30/36) | (30/36) |
| 6-12-12 | 21 | (33/36) | (30/36) | (30/36) |
| Schedule | Recomputed (s) | Cached (s) | Speedup | Time saved |
|---|---|---|---|---|
| 3/9/18 | 9.28 | 7.19 | 1.29 | 22.6% |
| 6/12/12 | 9.20 | 7.18 | 1.28 | 22.0% |
| 9/12/9 | 9.39 | 7.19 | 1.31 | 23.4% |
| Training schedule | 3/9/18 | 6/12/12 | 9/12/9 |
|---|---|---|---|
| 3/9/18 | 0.074 (24) / 0.129 (24) | 0.070 (24) / 0.133 (23) | 0.075 (24) / 0.139 (22) |
| 6/12/12 | 0.076 (24) / 0.138 (24) | 0.073 (24) / 0.138 (23) | 0.078 (24) / 0.144 (22) |
| 9/12/9 | 0.077 (24) / 0.160 (24) | 0.070 (24) / 0.144 (23) | 0.074 (24) / 0.143 (22) |
| Initialization | 0.072 (24) / 0.126 (24) | 0.073 (24) / 0.134 (23) | 0.076 (24) / 0.143 (22) |
| Schedule; branch | Matched source | Own source |
|---|---|---|
| 3/9/18; 0 | 0.101 (24) / 0.399 (24) | 0.101 (24) / 0.390 (22) |
| 3/9/18; 9 | 0.091 (24) / 0.266 (24) | 0.092 (24) / 0.254 (22) |
| 3/9/18; 15 | 0.074 (24) / 0.129 (24) | 0.074 (24) / 0.126 (22) |
| 3/9/18; 21 | 0.019 (24) / 0.036 (24) | 0.022 (24) / 0.038 (22) |
| 6/12/12; 0 | 0.095 (24) / 0.375 (23) | 0.095 (24) / 0.369 (22) |
| 6/12/12; 9 | 0.089 (24) / 0.272 (23) | 0.088 (24) / 0.260 (22) |
| Compiler | B0 | B1 | B2 | all | nochange |
|---|---|---|---|---|---|
| Trained 3/9/18 | 0.001 (24) 0.179 (24) | 0.015 (24) 0.306 (24) | 0.090 (24) 0.237 (24) | 0.101 (24) 0.399 (24) | -0.000 (24) 0.147 (24) |
| Trained 6/12/12 | 0.001 (24) 0.204 (23) | 0.040 (24) 0.301 (23) | 0.048 (24) 0.114 (23) | 0.095 (24) 0.375 (23) | 0.000 (24) 0.070 (23) |
| Trained 9/12/9 | 0.004 (24) 0.221 (22) | 0.059 (24) 0.245 (22) | 0.027 (24) 0.094 (22) | 0.093 (24) 0.336 (22) | 0.000 (24) 0.078 (22) |
| Init. 3/9/18 | 0.000 (24) 0.088 (24) | 0.012 (24) 0.319 (24) | 0.087 (24) 0.191 (24) | 0.099 (24) 0.411 (24) | 0.000 (24) 0.000 (24) |
| Init. 6/12/12 | -0.000 (24) 0.190 (23) | 0.039 (24) 0.312 (23) | 0.047 (24) 0.078 (23) | 0.093 (24) 0.382 (23) | 0.000 (24) 0.000 (23) |
| Init. 9/12/9 | 0.006 (24) 0.208 (22) | 0.060 (24) 0.256 (22) | 0.026 (24) 0.039 (22) | 0.094 (24) 0.343 (22) | 0.000 (24) 0.000 (22) |
| Start | Method | DINO | OWLv2 | Both | BG LPIPS ( ) |
|---|---|---|---|---|---|
| 0 | B0-isolated learned | 19 | 48 | 19 | 0.173 (48) |
| 0 | Native shared state | 9 | 48 | 9 | 0.451 (48) |
| 0 | FlowEdit PNG, CFG4 | 9 | 48 | 9 | 0.297 (48) |
| 0 | FlowEdit PNG, CFG6 | 11 | 48 | 11 | 0.355 (48) |
| 0 | FlowEdit PNG, CFG8 | 13 | 48 | 13 | 0.397 (48) |
| 0 | FlowEdit latent, CFG4 | 8 | 48 | 8 | 0.293 (48) |
| Start | Method | DINO | OWLv2 | CLIP | FG LPIPS ( ) |
|---|---|---|---|---|---|
| 0 | B0-isolated learned | 48 | 48 | 0.103 | 0.657 (48) |
| 0 | Native shared state | 48 | 48 | 0.101 | 0.664 (48) |
| 0 | FlowEdit PNG, CFG4 | 48 | 48 | 0.089 | 0.572 (48) |
| 0 | FlowEdit PNG, CFG6 | 48 | 48 | 0.092 | 0.605 (48) |
| 0 | FlowEdit PNG, CFG8 | 48 | 48 | 0.094 | 0.642 (48) |
| 0 | FlowEdit latent, CFG4 | 48 | 48 | 0.088 | 0.577 (48) |
| Direction | Start | Both/retained (pp) | 95% interval | Region LPIPS |
|---|---|---|---|---|
| subject | 0 | +20.8 | [+4.2, +45.8] | -0.277 |
| subject | 6 | +6.2 | [+0.0, +18.8] | -0.007 |
| subject | 9 | +8.3 | [+2.1, +14.6] | -0.001 |
| subject | 15 | +8.3 | [+2.1, +16.7] | -0.001 |
| subject | 21 | +4.2 | [+0.0, +10.4] | -0.001 |
| background | 0 | +0.0 | [+0.0, +0.0] | -0.007 |
| Branch | Method | D/O/B | BG | FG | Scene |
|---|---|---|---|---|---|
| 9 | Learned suffix | 13/48/13 | 0.1195 | 0.2953 | 0.0844 |
| 9 | Native shared-state | 8/48/8 | 0.1210 | 0.3095 | 0.0826 |
| 9 | FlowEdit PNG, CFG 4 | 10/48/10 | 0.0762 | 0.1890 | 0.0597 |
| 9 | FlowEdit PNG, CFG 6 | 14/48/14 | 0.1059 | 0.2424 | 0.0816 |
| 9 | FlowEdit PNG, CFG 8 | 12/48/12 | 0.1407 | 0.3065 | 0.0869 |
| 9 | FlowEdit latent, CFG 4 | 10/48/10 | 0.0697 | 0.2002 | 0.0637 |
Diffusion-Based Image Generation
Diffusion-based image generation creates images by progressively denoising noise, with controls for content, style, and structure.
See all 328 papers