Introduction
Protein inverse folding asks us to predict a sequence from a backbone structure. The backbone constrains residue identity through local conformation and spatial contacts, but it does not specify a unique sequence. Neighbouring residues can also have compatible alternatives: a plausible identity at one position changes which identities make sense nearby. We therefore need both useful geometric evidence and a way for uncertain predictions to inform one another.
The field addresses sequence design through deep learning [1], geometric vector representations of protein structure [2], efficient inverse-folding models [3], and denoising diffusion [4]. Our contribution is a particular structure encoder and belief-refinement decoder developed together. We first represent the backbone in residue-local coordinates, then use learned amino acid compatibility fields to refine soft sequence predictions and return them to the hidden representation.
The starter already provides a spatial graph, backbone dihedrals and message passing. Its orientation and neighbour-direction features are expressed in global coordinates, its edge embeddings remain fixed through the encoder, and its final readout predicts residues independently. We replace those components with invariant geometric features, evolving edge states, and repeated exchanges between residue embeddings and amino acid beliefs.
Method
Geometric evidence in local frames
Let contain the N, CA, C and O coordinates at residue , and let indicate a valid residue. We form a nearest-neighbour graph from CA distances. Within each residue, we construct a local frame from the C–CA direction, the component of N–CA orthogonal to it, and their cross product. Distances and vectors expressed in this frame are invariant to a common translation and proper rotation, provided the frame is nondegenerate.
We add learned virtual points using the backbone itself. With , , and normalised learned coefficient vectors , their positions are
The code creates three such points; the first serves as a beta-carbon proxy. These are learned geometric constructions, not observed side-chain coordinates. Edge features include the complete 25 cross-residue atom pairs over the backbone and first virtual point, plus eight selected pairs involving the remaining virtual points. Each distance receives 16 radial basis channels with centres from 0.0 to 20.0 and width .
We also encode directions to the neighbour's backbone and first virtual point in the centre residue's frame, the first two columns of , and a learned sequence-separation embedding with offsets clipped to .
def _featurize(self, X, mask):
B, L = X.shape[0], X.shape[1]
dev = X.device
N, CA, C, O = X[:, :, 0, :], X[:, :, 1, :], X[:, :, 2, :], X[:, :, 3, :]
b = CA - N
c = C - CA
a = torch.cross(b, c, dim=-1)
va = self.virtual_coeffs / torch.linalg.vector_norm(self.virtual_coeffs, dim=1, keepdim=True).clamp(min=1e-8)
virt = torch.stack([va[i, 0] * a + va[i, 1] * b + va[i, 2] * c + CA for i in range(3)], dim=2)
Cb = virt[:, :, 0, :]
A5 = torch.cat([X, virt], dim=2) # (B,L,7,3): N,CA,C,O,v0,v1,v2
R = _cf_frames(N, CA, C) # (B,L,3,3)
mask2 = mask.unsqueeze(1) * mask.unsqueeze(2)
dCA = torch.sqrt(((CA.unsqueeze(1) - CA.unsqueeze(2)) ** 2).sum(-1) + 1e-6)
dCb = torch.sqrt(((Cb.unsqueeze(1) - Cb.unsqueeze(2)) ** 2).sum(-1) + 1e-6)
eye = torch.eye(L, device=dev).unsqueeze(0)
dCA_big = dCA + (1.0 - mask2) * 1e6
K = min(self.k_neighbors, max(L, 1))
_, E_idx = torch.topk(dCA_big, K, dim=-1, largest=False) # (B,L,K)
mask_attend = mask.unsqueeze(-1) * _cf_gather_nodes(mask.unsqueeze(-1), E_idx).squeeze(-1)
# ---- edge features ----
A5_nb = _cf_gather_nodes(A5, E_idx) # (B,L,K,5,3)
# A5: (B,L,7,3) -> (B,L,1,7,1,3); A5_nb: (B,L,K,7,3) -> (B,L,K,1,7,3)
diff = A5.view(B, L, 1, 7, 1, 3) - A5_nb.view(B, L, K, 1, 7, 3)
d_all = torch.sqrt((diff ** 2).sum(-1) + 1e-6).view(B, L, K, 49)
d_pair = torch.index_select(d_all, 3, self._pair_idx) # (B,L,K,33)
mu = torch.linspace(0.0, 20.0, self.num_rbf, device=dev).view(1, 1, 1, 1, -1)
sigma = 20.0 / self.num_rbf
rbf = torch.exp(-((d_pair.unsqueeze(-1) - mu) / sigma) ** 2).view(B, L, K, 33 * self.num_rbf)
rel_nb = A5_nb[:, :, :, :5, :] - CA.view(B, L, 1, 1, 3) # neighbour N,CA,C,O,v0 rel. centre CA
rel_loc = torch.einsum('blji,blkaj->blkai', R, rel_nb) # in centre frame
dir_nb = _cf_unit(rel_loc).reshape(B, L, K, 15)
R_nb = _cf_gather_nodes(R, E_idx) # (B,L,K,3,3)
R_rel = torch.einsum('blji,blkjm->blkim', R, R_nb)
rot6 = R_rel[:, :, :, :, :2].reshape(B, L, K, 6)
offset = (E_idx - torch.arange(L, device=dev).view(1, L, 1)).clamp(-32, 32) + 32
pos = self.pos_embed(offset) # (B,L,K,16)
edge_feat = torch.cat([rbf, dir_nb, rot6, pos], dim=-1)Node features combine dihedrals, backbone bond angles and frame-local atom coordinates with soft burial counts. For a radius , a CA-based count has the form
We use CA radii 8.0, 10.0, 12.0 and 16.0, and virtual-beta-carbon radii 8.0, 10.0 and 12.0. Normalised distance from the chain centroid, log chain length and terminal-position features supply broader structural context. The burial features are neighbour-density proxies; we do not compute solvent-accessible area.
# burial: soft neighbour counts (exclude self, masked)
dCA_m = dCA + eye * 1e6 + (1.0 - mask2) * 1e6
dCb_m = dCb + eye * 1e6 + (1.0 - mask2) * 1e6
burial = []
for r in (8.0, 10.0, 12.0, 16.0):
burial.append((torch.sigmoid((r - dCA_m) / 1.0) * mask.unsqueeze(1)).sum(-1) / 20.0)
for r in (8.0, 10.0, 12.0):
burial.append((torch.sigmoid((r - dCb_m) / 1.0) * mask.unsqueeze(1)).sum(-1) / 20.0)
burial = torch.stack(burial, dim=-1) # (B,L,7)
msum = mask.sum(dim=1, keepdim=True).clamp(min=1.0)
centroid = (CA * mask.unsqueeze(-1)).sum(dim=1) / msum # (B,3)
depth = torch.linalg.vector_norm(CA - centroid.unsqueeze(1), dim=-1)
rg = torch.sqrt(((depth ** 2) * mask).sum(dim=1) / msum.squeeze(1)).clamp(min=1.0)
depth_f = (depth / rg.unsqueeze(1)).unsqueeze(-1)
size_f = (torch.log(msum) / 6.0).expand(-1, L).unsqueeze(-1)
rank = torch.cumsum(mask, dim=1) - mask # 0-based valid index
dist_end = (msum - 1.0 - rank).clamp(min=0.0)
term = torch.stack([
(torch.log1p(rank) / 4.0).clamp(max=2.0),
(torch.log1p(dist_end) / 4.0).clamp(max=2.0),
(rank == 0).float() * mask,
(dist_end == 0).float() * mask,
], dim=-1)
node_feat = torch.cat([dih, ang, loc_own, burial, depth_f, size_f, term], dim=-1)Attention with evolving edges and controlled global context
For each spatial edge we concatenate the centre embedding, neighbour embedding and current edge state. A shared message trunk produces attention logits and values. Each attention head normalises over valid neighbours; the aggregated values update residue states through residual attention and feed-forward blocks. We then update the edge state from the new residue embeddings.
Our normalisation computes per-channel statistics over valid entries, separately for nodes and edges, and uses running statistics at inference. A masked mean of the residue states provides a chain-level context vector . Its modulation is
The multiplicative gain is bounded between 0 and 2; the additive shift remains learned. The modulation layer starts at zero, making the initial gain 1.0 and shift 0.0. This bounded gain follows directly from an instability encountered during development.
def forward(self, h, e, E_idx, mask, mask_attend):
B, L, K = E_idx.shape
h_nb = _cf_gather_nodes(h, E_idx)
h_c = h.unsqueeze(2).expand(-1, -1, K, -1)
joint = torch.cat([h_c, h_nb, e], dim=-1)
base = self.msg_trunk(joint)
val = self.msg_value(base).view(B, L, K, self.num_heads, self.head_dim)
logits = self.msg_attn(base)
logits = logits - (1.0 - mask_attend).unsqueeze(-1) * 1e4
attn = torch.softmax(logits, dim=2) * mask_attend.unsqueeze(-1)
attn = attn / attn.sum(dim=2, keepdim=True).clamp(min=1e-8)
agg = (attn.unsqueeze(-1) * val).sum(dim=2).view(B, L, self.dim)
h = self.bn_h1(h + self.drop(self.out_proj(agg)), mask)
h = self.bn_h2(h + self.drop(self.ffn(h)), mask)
h_nb = _cf_gather_nodes(h, E_idx)
h_c = h.unsqueeze(2).expand(-1, -1, K, -1)
e = self.bn_e(e + self.drop(self.edge_mlp(torch.cat([h_c, h_nb, e], dim=-1))), mask_attend)
m = mask.unsqueeze(-1)
g = (h * m).sum(dim=1) / mask.sum(dim=1, keepdim=True).clamp(min=1.0)
scale, shift = self.film(g).chunk(2, dim=-1)
h = h * (2.0 * torch.sigmoid(scale)).unsqueeze(1) + shift.unsqueeze(1)
h = h * m
e = e * mask_attend.unsqueeze(-1)
return h, eThe submitted configuration requests 10 encoder layers. The encoder expands the requested hidden width by 1.5, rounds and clamps it, and makes it divisible by 8. It uses four attention heads and retains the default spatial-neighbour count of 30.
Low-rank compatibility fields
A linear readout produces unary logits . Each edge embedding also predicts matrices , defining a rank-limited compatibility
Starting from , we form a spatial field from the neighbours' current beliefs:
where is the valid non-self neighbour count, clamped below by 1.0. The factor starts at zero, while starts with small random weights, so spatial compatibility fields initially vanish.
We add a learned chain term and make three damped updates:
Detachment applies to the beliefs used as message context. The retained belief in the damping step still carries gradients. We describe this as Potts-style refinement: the edge compatibilities are directed, and the implementation does not enforce a symmetric energy or establish exact marginal inference.
The chain term needs a precise qualification. The loop lists offsets , but its negative-offset branches append padding and immediately truncate to the original length. Those branches therefore reuse the current-position belief. Positive offsets read preceding positions. For a valid residue, the implemented term is
with out-of-range positions masked. This is the operation delivered by our code; the intended bidirectional offsets described in the trace were not realised.
P = self.couple_p(e).view(B, L, K, NUM_AA, R)
Q = self.couple_q(e).view(B, L, K, NUM_AA, R)
log_q = F.log_softmax(u, dim=-1)
outs = [log_q]
nvalid = mask_attend.sum(dim=2).clamp(min=1.0) # (B,L)
for _ in range(self.MF_ITERS):
q = log_q.exp()
if S_ctx is not None:
gt = F.one_hot(S_ctx, NUM_AA).to(q.dtype)
gt = 0.95 * gt + 0.05 / NUM_AA
q_msg = (1.0 - self.GT_MIX) * q.detach() + self.GT_MIX * gt
else:
# neighbours' beliefs enter as fixed context (truncated backprop
# through the mean-field fixed point; keeps feedback gain bounded)
q_msg = q.detach()
q_nb = _cf_gather_nodes(q_msg, E_idx) # (B,L,K,20)
t = torch.einsum('nlkbr,nlkb->nlkr', Q, q_nb)
msg = torch.einsum('nlkar,nlkr->nlka', P, t) # (B,L,K,20)
field = (msg * mask_attend.unsqueeze(-1)).sum(dim=2) / nvalid.unsqueeze(-1)
field = field * self.field_scale
# chain couplings for offsets -2,-1,+1,+2
chain = torch.zeros_like(u)
for oi, o in enumerate((-4, -3, -2, -1, 1, 2, 3, 4)):
if o < 0:
qs = F.pad(q_msg, (0, 0, 0, -o))[:, :L, :]
ms = F.pad(mask, (0, -o))[:, :L]
else:
qs = F.pad(q_msg, (0, 0, o, 0))[:, :L, :]
ms = F.pad(mask, (o, 0))[:, :L]
chain = chain + torch.einsum('ab,nlb->nla', self.chain_coupling[oi], qs) * ms.unsqueeze(-1)
logits = u + field + self.chain_scale * chain
q_new = torch.softmax(logits, dim=-1)
log_q = torch.log((0.5 * q + 0.5 * q_new).clamp(min=1e-12)) # damped fixed-point step
outs.append(log_q)Recycling beliefs and supervising the trajectory
After the first refinement stage, we convert soft amino acid beliefs into an expected embedding using a learned matrix :
Two additional attention layers update these states and the edge embeddings. We then reuse the readout and compatibility decoder for another refinement stage. The additional layers have their own normalisation statistics, so the initial encoding and recycling passes do not mix statistics in shared layers. The belief embedding remains differentiable.
At inference we soften the final beliefs with , using . A positive temperature preserves the most probable amino acid while changing the probability distribution.
def _predict(self, X, mask, S_ctx=None):
h, e, E_idx, mask_attend = self.encoder(X, mask)
L = X.shape[1]
not_self = (E_idx != torch.arange(L, device=X.device).view(1, L, 1)).to(dtype=mask_attend.dtype)
ma_mf = mask_attend * not_self
outs = self._mean_field(self.readout(h), e, E_idx, mask, ma_mf, S_ctx=S_ctx)
# recycling round: soft sequence beliefs refine the hidden states, then re-decode
q = outs[-1].exp()
h2 = (h + torch.matmul(q, self.aa_vec)) * mask.unsqueeze(-1)
for layer in self.recycle_layers:
h2, e = layer(h2, e, E_idx, mask, mask_attend)
outs = outs + self._mean_field(self.readout(h2), e, E_idx, mask, ma_mf, S_ctx=S_ctx)
return outs
def forward(self, X, mask):
log_q = self._predict(X, mask)[-1]
if self.TEMPERATURE != 1.0:
log_q = F.log_softmax(log_q / self.TEMPERATURE, dim=-1)
return log_qTraining supervises the concatenated sequence of unary and refined predictions from both stages:
The denominator is clamped below by 1. Coordinate-noise augmentation and ground-truth belief mixing are both disabled in the submission. Native sequence identities enter the loss; refinement uses the model's own beliefs. Temperature scaling is applied by the inference forward method, outside this training objective.
def training_loss(self, X, S, mask):
if self.NOISE_STD > 0:
noise = torch.randn_like(X) * self.NOISE_STD * mask.view(*mask.shape, 1, 1)
X = X + noise
S_ctx = S if self.GT_MIX > 0 else None
outs = self._predict(X, mask, S_ctx=S_ctx)
denom = mask.sum().clamp(min=1)
n1 = 1 + self.MF_ITERS
weights = [0.15] * len(outs)
weights[0] = 0.3
if len(outs) > n1:
weights[n1 - 1] = 0.5
weights[n1] = 0.3
weights[-1] = 1.0
loss = 0.0
for w, lq in zip(weights, outs):
nll = F.nll_loss(lq.permute(0, 2, 1), S, reduction='none')
loss = loss + w * (nll * mask).sum() / denom
return loss, outs[-1]We retain AdamW and the OneCycle schedule, with the default maximum learning rate and dropout 0.1. The submitted overrides set batch size 8, weight decay 0.2 and exponential moving averaging with decay 0.999.
Results
| Method | ① | ② | ③ | |||
|---|---|---|---|---|---|---|
| Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | |
| Muse Wonder Full | 0.556 | 3.934 | 0.549 | 3.801 | 0.564 | 3.829 |
| ProteinMPNN | 0.469 | 5.310 | 0.459 | 5.212 | 0.489 | 5.057 |
| PiFold | 0.521 | 4.811 | 0.517 | 4.574 | 0.528 | 4.857 |
| GVP | 0.407 | 6.426 | 0.400 | 6.276 | 0.417 | 6.171 |
| VFN-IF, as published | 0.540 | 4.328 | 0.531 | 4.240 | 0.560 | 4.243 |
| UniIF | 0.525 | 4.956 | 0.519 | 4.610 | 0.541 | 4.678 |
| ScFold | 0.518 | 5.049 | 0.512 | 4.659 | 0.525 | 4.813 |
| DIF-Large | 0.434 | 0.425 | 0.455 | |||
| MapDiff | 0.481 | 5.306 | 0.472 | 5.137 | 0.508 | 5.143 |
| ProteinMPNN, AR decoder | 0.474 | 5.502 | 0.461 | 5.536 | 0.489 | 5.495 |
| GVP, AR decoder | 0.409 | 6.750 | 0.406 | 6.634 | 0.420 | 6.546 |
| SurfFold | 0.280 | 9.905 | 0.282 | 9.840 | 0.286 | 9.897 |
| VFN-IF | 0.544 | 4.058 | 0.547 | 3.882 | 0.556 | 3.839 |
- ① CATH 4.2 · recovery / perplexity
- ② CATH 4.3 · recovery / perplexity
- ③ TS50 · trained on CATH 4.2
Our delivered model leads the supplied baseline means on both metrics in every setting. On CATH 4.2, recovery is 0.556, compared with 0.544 for VFN-IF EMA+WD. Perplexity is 3.934, compared with the best baseline value of 4.058.
On CATH 4.3, recovery is 0.549 against 0.547 for VFN-IF EMA+WD, and perplexity is 3.801 against 3.882. On TS50, recovery is 0.564 against 0.560 for VFN-IF [5], while perplexity is 3.829 against 3.839.
The recovery advantage is smallest on TS50. The supplied means establish the ordering of the delivered systems, but contain no uncertainty estimates with which to assess that small difference. They also do not isolate the contribution of compatibility refinement, recycling or the training recipe.
How we got here
Our development began by inspecting the starter and supplied ProteinMPNN and PiFold implementations. The starter's sparse geometric description and global-coordinate directions motivated a richer invariant representation. Our initial design paired that encoder with low-rank amino acid compatibilities: the aim was to let uncertain sequence predictions exchange information through structural contacts.
The first implementation became nonfinite during training. Activation probes traced the growth to an unrestricted multiplicative global-context gate, even while internal normalised states remained moderate. We bounded the multiplicative gain, normalised its input, reduced the initial compatibility scale and added damped updates with detached message beliefs. Later revisions used masked population normalisation throughout the residual streams. The final code retains that normalisation and bounded gain.
The trace includes an early accuracy report that was subsequently withdrawn after checking the development output. We use the corrected measurements. In our own development probes, removing coordinate noise raised validation recovery from 41.25% to 46.62%. The subsequent masked-BatchNorm architecture reached 49.00%, and a revision combining learned virtual atoms, expanded atom-pair and neighbour-direction features, and a one-pass normalisation variance calculation reached 49.24%. These are development measurements preserved in the trace. The normalisation revision also changed the message network, so that comparison does not isolate normalisation alone.
Several alternatives were unhelpful. Mixing native sequence identities into the refinement context during training reduced development recovery, so we kept self-generated context. More neighbours, wider states, finer radial features and higher compatibility rank did not establish useful gains in the recorded probes. Removing message detachment, adding more refinement iterations and introducing an additional pooled readout also failed to improve the development control materially.
Early diagnostics showed that most mean-field gains arrived in the first update. We therefore added a route from beliefs back into hidden states through separate recycling layers. On a later development checkpoint, recovery moved from 53.42% at the initial unary prediction to 54.11% after its first refinement stage and 54.27% after recycling and refinement. Extra iterations offered no further gain. Calibration diagnostics also showed overconfidence; a separate development temperature probe reduced perplexity from 4.698 to 4.509 at unchanged recovery. Later checks supported the submitted temperature of 1.25.
Limitations
Our chain-coupling code does not implement the intended bidirectional interactions. Its current-position terms and preceding-position terms may still be useful, but the measured results cannot support claims about the intended symmetric offset coverage. The spatial compatibility matrices are also directed; our refinement has no demonstrated convergence or exact-marginal guarantee.
The recovery lead on TS50 is small, and uncertainty estimates are unavailable. Most component comparisons in the trace are development probes, with architectural and recipe changes sometimes combined. We can attribute the supplied results to the delivered system as a whole; we cannot assign each component a reliable share of the improvement.
Our geometric representation is sensitive to coordinate quality. Noise augmentation hurt in development, and local frames can be ill-conditioned when their defining backbone directions are nearly collinear. Burial and amino acid diagnostics also left exposed residues and several polar or charged identities harder to recover. A single inference temperature addresses overall confidence without establishing calibration across structural regimes.
Finally, sequence recovery and perplexity provide limited evidence about designed proteins. The artefacts contain no experimental folding, stability or functional measurements for our predictions. Learned virtual points and compatibility fields express useful structural hypotheses, but the measured gains do not establish physical validity or capture the full range of sequences compatible with a backbone.
References
- J. Dauparas, I. Anishchenko, N. Bennett et al. (2022). Robust deep learning–based protein sequence design using ProteinMPNN. Science.
- Bowen Jing, Stephan Eismann, Patricia Suriana et al. (2021). Learning from Protein Structure with Geometric Vector Perceptrons. ICLR.
- Zhangyang Gao, Cheng Tan, Pablo Chacón et al. (2023). PiFold: Toward effective and efficient protein inverse folding. ICLR.
- Peizhen Bai, Filip Miljković, Xianyuan Liu et al. (2024). Mask prior-guided denoising diffusion improves inverse protein folding.
- Weian Mao, Muzhi Zhu, Zheng Sun et al. (2024). De novo protein design using geometric vector field networks. ICLR.
- Zhangyang Gao, Jue Wang, Cheng Tan et al. (2024). UniIF: Unified Molecule Inverse Folding. NeurIPS.
- Jiancheng Zhong, Zhiwei Zou, Jie Qiu et al. (2025). ScFold: a GNN-based model for efficient inverse folding of short-chain proteins via spatial reduction. Briefings in Bioinformatics.
- Yasha Ektefaie, Olivia Viessmann, Siddharth Narayanan et al. (2024). Reinforcement learning on structure-conditioned categorical diffusion for protein inverse folding.
- Darong Li, Lian Shen, Meijia Song et al. (2026). SurfFold: a unified model for protein inverse folding by integrating surface and structural information. Bioinformatics.