HamiFormer: Dual-Expert Diffusion Fields with Affine Symplectic Maps
Organizations: University of Science and Technology of China · Tsinghua University · Chinese Academy of Sciences
Abstract
Predicting smooth dynamics and collisions requires modeling continuous evolution and abrupt state changes. We introduce HamiFormer, a dual-expert diffusion field combining whole-window denoising with residual-corrected Hamiltonian propagation. Their mixed-state feedback attenuates the direct contribution of inherited autoregressive error: each mixed state guides subsequent propagation within the jointly refined window. Parallel Local Affine Scan (PLAS) amortizes iterative refinement across rectified-flow steps and evaluates derivatives in parallel across physical time. PLAS's affine symplectic maps achieve lower solver error and runtime than sequential explicit Euler in our evaluation. A Regime Model Tree specializes residuals and routing to balance typical-state accuracy against large tail errors. Our analysis gives conditions for physically consistent refinement and warm-start tracking, and finite-window error bounds under diffusion feedback. In 192-step evaluations, HamiFormer reduces normalized phase-space MSE by 26.3% against PhysiFormer on HamiBalls-1 and 21.4% against DiT on HamiBalls-2, with comparable model capacities. Disjoint-interval comparisons show the lowest late-horizon position and momentum errors among baselines on both datasets. Project page: https://hamiformer.github.io/.
Figures & tables
| Method | Total | Continuous | Contact | ||||
|---|---|---|---|---|---|---|---|
| HamiBalls-1 | |||||||
| PhysiFormer | 0.34029 | 0.34689 | 0.33369 | 0.34710 | 0.32854 | 0.33378 | 0.65186 |
| HG-DPF | 1.17966 | 1.29854 | 1.06077 | 1.29673 | 1.05897 | 1.41008 | 1.17228 |
| HamiFormer (Ours) | 0.25071 | 0.25596 | 0.24546 | 0.25613 | 0.23985 | 0.24529 | 0.59206 |
| HamiBalls-2 | |||||||
| Method | 1–48 edges | 49–96 edges | 97–192 edges | |||
|---|---|---|---|---|---|---|
| HamiBalls-1 | ||||||
| PhysiFormer | 0.02076 | 0.10887 | 0.23468 | 0.29940 | 0.56606 | 0.46324 |
| HG-DPF | 0.23083 | 0.70319 | 1.29546 | 1.04699 | 1.83393 | 1.24646 |
| HamiFormer (Ours) | 0.01451 | 0.07719 | 0.16078 | 0.21496 | 0.42427 | 0.34484 |
| HamiBalls-2 | ||||||
| Solver | RMSE ( ) | Time (s) | ||
|---|---|---|---|---|
| Explicit Euler | 685.261 | 7.34700 | 484.580 | 0.8875 |
| SymEuler2 | 0.04955 | 0.05661 | 0.05319 | 1.2752 |
| PLAS | 10.6093 | 8.92038 | 9.80127 | 0.7940 |
| PLAS-S | 12.1360 | 9.74284 | 11.0047 | 0.7427 |
| PLAS-DC | 0.05031 | 0.05694 | 0.05373 | 1.0057 |
| Method | HamiBalls-1 | HamiBalls-2 | ||||
|---|---|---|---|---|---|---|
| H+r candidate only | 0.022601 | 0.098554 | 0.060577 | 0.391673 | 1.069561 | 0.730617 |
| Output-only mixing | 0.020802 | 0.084092 | 0.052447 | 0.079374 | 0.426752 | 0.253063 |
| Ours | 0.014472 | 0.077240 | 0.045856 | 0.043307 | 0.378203 | 0.210755 |
| ID | Structure | Objective | Error reduction (%) | Cell win (%) | ||
|---|---|---|---|---|---|---|
| A | Shared | Basic | ||||
| B | Tree | Basic | ||||
| C | Shared | Full | ||||
| D | Tree | Full | ||||
| GL | Global leaf | Full | ||||
Appendix figures & tables20 assets
Supplementary material from the paper’s appendix.
Appendix
| Radius | Positive cost (%) | 95% interval (%) | Maximum MSE increase |
|---|---|---|---|
| 0.0416 | [0.0221, 0.0684] | 0.00770 | |
| 0.2098 | [0.1528, 0.2786] | 0.02501 | |
| 0.9998 | [0.8310, 1.1957] | 0.04176 |
| Theoretical ingredient | Proof or direct check | Complementary empirical evidence |
|---|---|---|
| PLAS-map symplecticity and implicit regularity | Symplecticity proof; measured spectra and affine defects | 6,881,280 deployed edge maps; learned-H local approximation order |
| Regular local refinement | Fixed-point and quadratic-remainder proof; nonlinear mixed control | Multi-start refinement and independently checked point Jacobians |
| Smooth-model and correction budgets | Conditional consistency proof; physical-step refinement control | First-order convergence with exact H, vanishing model error, and quadratic corrections |
| Single-refinement deployment | tracking bound; finite-schedule output decomposition | checks; 512-source, 192-edge refinement comparisons |
| Finite-window feedback and memory | Nonnegative response expansion with a conditional D budget | Physical-coordinate and internal-memory responses; complete RF interventions |
| Regular collision sequences | Finite-event composition bound | 510 contact onsets; matched perturbed targets and event-boundary tails |
| Setting | Budget scaling | Observed order |
|---|---|---|
| Exact Hamiltonian | 0.9956–1.0060 | |
| Vanishing gradient error | 0.9973–1.0065 | |
| Quadratic step correction | 0.9953–1.0066 |
| Sources | Conditions | Warm start | All starts | |
|---|---|---|---|---|
| 8 | 8 | 112 | 108 | 107 |
| 12 | 8 | 112 | 111 | 111 |
| 20 | 512 | 7168 | 7030 | 7015 |
| Median | Maximum | Median | Maximum | |
|---|---|---|---|---|
| 8 | ||||
| 12 | ||||
| 20 |
| Center | Radius | Median gain | Maximum gain | Gain |
|---|---|---|---|---|
| Warm | 0.000221 | 0.2204 | 0/84 | |
| Warm | 0.002228 | 0.00518 | 0/84 | |
| Warm | 0.02429 | 22.0401 | 2/84 | |
| Terminal | 0.000225 | 0.2204 | 0/84 | |
| Terminal | 0.002186 | 0.00446 | 0/84 | |
| Terminal | 0.02293 | 22.0489 | 2/84 |
| Sources | Count | MSE | MSE | PhysiFormer | Positive cost (%) |
|---|---|---|---|---|---|
| All | 512 | 0.250732 | 0.250635 | 0.340289 | 0.1903 |
| Flagged | 97 | 0.322510 | 0.321508 | 0.412714 | 0.4744 |
| Other | 415 | 0.233955 | 0.234069 | 0.323361 | 0.0990 |
| Routing policy | Sup gain (%) | Maximum sup gain | Response energy |
|---|---|---|---|
| Live | 0.590 | 1460 | |
| Fixed live gates | 0.286 | 2604 | |
| All | 2.352 | 8448 |
| Perturbed block | Maximum RMS | Aggregate MSE change (%) | Maximum MSE increase |
|---|---|---|---|
| Recurrent hidden state | 0.000142 | +0.000012 | |
| Previous gate | 0.000143 | +0.000017 | |
| Previous H candidate | 0.000143 | +0.000082 | |
| Contact-provenance context | 0.000142 | +0.000024 | |
| Cumulative reset | 0.023837 | +0.003641 | |
| Momentum reset energy | 0.023837 | +0.003445 |
| Component | Architecture or state | Count |
| Diffusion expert | Width 128; 4 blocks; 4 heads; 2 registers; feed-forward width 256 | 1,159,172 |
| Hamiltonian model | Width 16; 2 object-interaction blocks; 4 heads; scalar readout | 4,464 |
| Shared residual | SiLU MLP, | 6,148 |
| Router | 12-dimensional projection and physical-time GRU; width-16 offset heads; leaf-affine corrections | 7,588 |
| Neural subtotal | All four components | 1,177,372 |
| Ridge readouts | Fitted linear readouts | 1,056 |
| Component | Architecture or state | Count |
| Diffusion expert | Width 168; 12 blocks; 8 heads; 2 registers; feed-forward width 336 | 5,615,598 |
| Hamiltonian model | Width 32; 2 object-interaction blocks; 4 heads; pair-energy readout | 22,252 |
| Shared residual and router | Token-conditioned SiLU residual; physical-time GRU with offset heads and leaf-affine corrections | 32,729 |
| Neural subtotal | All HamiFormer neural components | 5,670,579 |
| Ridge readouts | Fitted linear readouts | 6,960 |
| Combined scalars | Neural parameters plus fitted linear coefficients | 5,677,539 |
| Setting | H1 | H2 |
|---|---|---|
| Base updates; batch size | 50,000; 64 | 50,000; 64 |
| Optimizer; weight decay; grad clip | AdamW; ; 1.0 | AdamW; ; 1.0 |
| Peak learning rate: D / H | / | / |
| Peak LR: residual / scalar / final q/p | / / | / / |
| RF denominator floor | 0.05 | 0.05 |
| Downstream stages | updates | updates |
| Trainable component | Updates | Objective and carrier policy |
|---|---|---|
| Diffusion Hamiltonian base | 50,000 | ; whole-window RF (batch 64) and local relation minibatches |
| Shared residual | 200 | Eq. ( D.8 ); random-gate carriers; refresh every 8 updates |
| First scalar router | 200 | Global sequence projection regret; fixed mixed- pool |
| Second scalar router | 200 | Projection regret plus non-degradation penalty; fixed pool from the preceding scalar router |
| Model tree | — | Fit once after scalar stages outside gradient-based optimization |
| Dual-channel/leaf router | 200 | Eq. ( D.16 ); 25 refreshes of 8 updates; cumulative ridge fitting |
| Integrator | 48-edge -MSE | 192-edge -MSE | Wall-clock (s) |
|---|---|---|---|
| Explicit Euler | 0.045910 | 0.253974 | 0.8875 |
| SymEuler2 | 0.045846 | 0.250647 | 1.2752 |
| PLAS | 0.045850 | 0.250707 | 0.7940 |
| Implementation | MSE | MSE | MSE | Win (%) |
|---|---|---|---|---|
| Ours | 0.04584945 | 0.01450559 | 0.07719332 | 64.4263 |
| Ours (PLAS-S) | 0.04584186 | 0.01450082 | 0.07718289 | 64.4173 |
| Method | RF steps | Seconds / batch | 192-edge MSE |
|---|---|---|---|
| PhysiFormer | 20 | 0.402 | 0.34029 |
| PhysiFormer | 40 | 0.809 | 0.32767 |
| Ours (PLAS) | 20 | 0.786 | 0.25071 |
| Setting | HamiBalls-1 | HamiBalls-2 |
|---|---|---|
| Domain | ||
| Objects | 5 disks | 5–10 spheres |
| Mass; radius | ; | Same ranges |
| Initial speed | ||
| Body restitution | ||
| Boundary restitution |
| PhysiFormer | Ours | |||||
|---|---|---|---|---|---|---|
| Physical seed | ||||||
| 40 | 0.06718 | 0.02263 | 0.11173 | 0.04557 | 0.01520 | 0.07594 |
| 41 | 0.06582 | 0.02046 | 0.11118 | 0.05146 | 0.01686 | 0.08606 |
| 42 | 0.06718 | 0.02420 | 0.11016 | 0.04431 | 0.01550 | 0.07311 |
| 43 | 0.05907 | 0.01574 | 0.10240 | 0.04206 | 0.01045 | 0.07366 |
| PhysiFormer | Ours | |||||
|---|---|---|---|---|---|---|
| Physical edges | ||||||
| 1–48 | 0.06481 | 0.02076 | 0.10887 | 0.04585 | 0.01451 | 0.07719 |
| 49–96 | 0.26704 | 0.23468 | 0.29940 | 0.18787 | 0.16078 | 0.21496 |
| 97–144 | 0.46841 | 0.49981 | 0.43702 | 0.33972 | 0.36346 | 0.31598 |
| 145–192 | 0.56089 | 0.63230 | 0.48947 | 0.42938 | 0.48507 | 0.37370 |
Physics-Informed Diffusion Models
Physics-informed diffusion models use physical laws and measurements to guide generative sampling, reconstruction, and forecasting.
See all 50 papers