arXiv:2611.00875cs.LGOct 2026

Manuscript Offprint

arXiv:2611.00875

HamFormer: A Hamiltonian Flow-based SE(3)-Transformer for Conformation Optimization

Minjie Cheng, Zhenghao Liu, Yitian Wang, Fanmeng Wang, Anqi Dong, Hongteng Xu

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

The Transformer architecture plays a central role in modern deep learning, and its SE(3)-equivariant variants have been widely applied to molecular conformation modeling and optimization. Given its importance, many methods attempt to interpret and improve the Transformer through the lens of dynamics. However, they mainly focus on a single attention head rather than the full Transformer architecture and seldom consider SE(3)-equivariance in their proposed models. In this study, we propose an improved SE(3)-Transformer architecture, called HamFormer, which revisits the design of SE(3)-Transformer through the lens of Hamiltonian flow. In particular, we define a parametrized Hamiltonian flow in the phase space of position and velocity, corresponding to optimizing an energy functional that combines an optimal transport-based potential with a damped momentum. The Lie-Trotter splitting framework of the Hamiltonian flow leads to the proposed HamFormer architecture, whose feedforward computation achieves the optimization step of the proposed energy functional. Furthermore, we combine HamFormer with Equivariant Graph Neural Network (EGNN), build a new model for molecular conformation optimization. Extensive experiments on molecular ground-state conformation prediction show that HamFormer provides a strong and physically interpretable surrogate for classic SE(3)-Transformer and generally outperforms state-of-the-art competitors.

1 Introduction

Transformers (Vaswani et al., 2017) have become the dominant architecture for modeling interacting elements, from tokens in language to atoms in molecules and materials. For the elements in three-dimensional space, whose underlying physics is invariant under rotations and translations, SE(3)-Transformers (Thomas et al., 2018; Fuchs et al., 2020) build this symmetry into attention itself, coupling invariant scalar features with equivariant coordinates so that predictions transform consistently with their inputs. This geometric inductive bias underpins a series of practical successes across the molecular sciences, including protein structure prediction in AlphaFold (Jumper et al., 2021; Abramson et al., 2024), molecular representation learning in Uni-Mol (Zhou et al., 2023), equivariant force fields and materials modeling (Satorras et al., 2021; Liao and Smidt, 2023), and ground-state conformation prediction (Wang et al., 2025). As the Transformer and its SE(3)-equivariant variants are entrusted with physically consequential predictions, understanding and improving what their layers compute has become a question of practical rather than merely theoretical significance.

Considerable efforts have gone into understanding the mechanism behind the Transformer, such as interpreting its self-attention layer through interacting particle dynamics (Geshkovski et al., 2023; Sander et al., 2022; Wang et al., 2025) and revisiting its residual architecture as ODE flows (Chen et al., 2018). Building on these

∗^{*}Corresponding authors. Email: anqidonggranet@gmail.com, hongtengxu@ruc.edu.cn

Figure

Figure 1. An illustration of the proposed molecule model based on HamFormer.

interpretations, some recent methods improve the Transformer architecture through the lens of dynamics. For example, Sinkformer (Sander et al., 2021) applies doubly stochastic attention maps based on the Sinkhorn-scaling algorithm (Cuturi, 2013) and, accordingly, interprets the improved Transformer as Wasserstein gradient flows. Recent YurriFormer (Zimin et al., 2026) and SympFormer (Stein et al., 2026) introduce high-order dynamical information into the Transformer and design their models as the Nesterov-accelerated gradient descent algorithm. However, extending these dynamical interpretations to molecular refinement requires considering both feature evolution and molecular geometry. Beyond the attention operator, the architecture combines multiple attention heads, tokenwise FFNs, and pair relations that inform equivariant coordinate updates. The challenge is to connect these components within a common dynamical framework that guides their interaction while preserving SE(3)-equivariance.

In this paper, we propose HamFormer, which revisits the SE(3)-Transformer from the viewpoint of parametric Hamiltonian flows and improves the architecture accordingly. In principle, HamFormer is built based on coupled interacting particle dynamics, which capture the evolution of a distribution in the phase space of position and momentum. To model the dynamics, we define a Hamiltonian flow in phase space generated by an energy functional consisting of an optimal transport-based potential and a learned kinetic term. We parameterize the energy functional and discretize the resulting dynamics in the Lie–Trotter splitting framework (Hairer et al., 2006), with momentum retention applied before the interaction update. Given a set of particles (e.g., atomic embeddings of a molecule) and their initial momentum and pairwise relations, the discrete implementation of splitting leads to the proposed HamFormer architecture, whose feedforward computation updates the positions, momentum, and relations of the particles following the reference kick–drift structure.

Notably, HamFormer augments the atom features and pair relations used in SE(3)-equivariant molecular architectures (Fuchs et al., 2020; Zhou et al., 2023; Wang et al., 2025) with an explicit latent momentum state, allowing interactions from earlier layers to influence subsequent feature updates. In addition, compared with existing accelerated and momentum-based Transformer architectures (Zimin et al., 2026; Stein et al., 2026; Gai et al., 2026), HamFormer combines an optimal transport-based potential with multi-head feature updates and SE(3)-equivariant coordinate refinement.

As shown in Figure 1, combining HamFormer with Equivariant Graph Neural Network (EGNN) leads to a new model for molecular conformation optimization. We evaluate the proposed model on the task of ground-state conformation prediction. Experimental results demonstrate that HamFormer provides a strong and physically interpretable surrogate for classic SE(3)-Transformer, whose feature updates follow a Hamiltonian reference structure and coordinate refinement preserves SE(3)-equivariance. Accordingly, the HamFormer-based model outperforms state-of-the-art ground-state conformation predictors in both accuracy and efficiency.

References (31)