Introduction
Inverse folding asks for the amino-acid sequence that folds into a given backbone. A model reads the coordinates of the backbone atoms of every residue, builds a graph over the residues, and emits for each position a distribution over the twenty amino acids. The field has moved from message-passing encoders with an autoregressive or one-shot readout [1, 2] to richer geometric features and attention [3, 4, 5], and to generative decoders [6, 7]. Much of this work is about the architecture of the model. We looked instead at what the model is given.
Backbones from the PDB are partially observed. A large share of chains contain residues whose backbone atoms were never resolved, typically expression tags and disordered termini or loops. The submission's own comments put the share of training chains with at least one such residue at 77%, and the share of training residues at 6.4%. The reference models in the scaffold delete them from the graph and from the loss. That has two consequences, and both are ours to exploit.
- The deleted residues are still part of the native sequence and are still scored, and a model that deleted them emits a uniform distribution there. In the agent's development measurements the reference arm scored 7.4% recovery and a perplexity of 20.0 on these positions, which is exactly the uniform value.
- Deleting them splices the chain. The featuriser computes dihedral angles, bond angles and sequence separations between two residues that are neighbours in the packed tensor but not in the protein. In the agent's measurement on the PiFold arm, recovery on resolved residues fell from 48.2% far from any unresolved residue to 25.3% directly next to one. Part of that drop is intrinsic, since disordered regions border the unresolved ones, and part is corrupted input.
The task asks for a better structure encoder. Our submission leaves the encoder's architecture where it is and changes what surrounds it.
Method
Our method, POIF (partial-observability inverse folding), has two parts, which the submission calls A and B. Its governing constraint is that the resolved residues must be predicted by the same encoder, trained under the same objective, as in the reference, so that nothing can be lost there.
The encoder and the chain-break correction
The encoder is a port of PiFold [3]: virtual atoms, RBF distance features over
atom pairs, a 10-layer neighbour-attention graph network with a global context gate, hidden size 128, and
a single linear readout. The graph is flattened over resolved residues exactly as in the reference,
and the submission sets num_encoder_layers to 10 to match it.
Its two changes are corrections of the features that reach across a gap. Residues are packed so that
resolved ones are contiguous, and the packing order order carries each residue's true index
res_idx. Two residues are bonded only when their true indices differ by one. Every dihedral and
bond angle that needs a previous or a next residue is multiplied by that indicator and two flags are
appended:
where is the resolved mask and zeroes the columns that need the missing neighbour.
# A gap splices two residues that are NOT peptide bonded. The dihedrals and
# bond angles that reach across such a splice are meaningless, so they are
# zeroed and flagged instead of being fed in as real geometry.
dihe = _pf_dihedrals(X)
if True:
step = res_idx[:, 1:] - res_idx[:, :-1]
bonded = (step == 1).to(X.dtype)
has_prev = F.pad(bonded, (1, 0)) * mask * F.pad(mask, (1, 0))[:, :N]
has_next = F.pad(bonded, (0, 1)) * mask * F.pad(mask, (0, 1))[:, 1:]
w = torch.ones_like(dihe)
w[:, :, _PF_NEED_PREV] = has_prev.unsqueeze(-1)
w[:, :, _PF_NEED_NEXT] = has_next.unsqueeze(-1)
dihe = torch.cat([dihe * w, has_prev.unsqueeze(-1), has_next.unsqueeze(-1)], -1)The second correction is the sequence-separation embedding of each edge. The reference computes it from packed indices, which says two residues are adjacent when a whole loop sits between them. We compute it from true indices:
if True:
# TRUE sequence separation. The reference packs the resolved residues
# together first, so its packed-index difference under-counts every pair
# that spans a gap -- it tells the model two residues are adjacent when
# a whole unresolved loop sits between them.
true_idx = torch.masked_select(res_idx.unsqueeze(-1).expand_as(E_idx), mask_attend)
true_src = torch.masked_select(torch.gather(res_idx, 1, E_idx.reshape(B, -1))
.view_as(E_idx), mask_attend)
pos = _pf_sin_embed(true_idx - true_src, 16)
chain = _pf_sin_embed(torch.ones_like(edge_idx[0]), 16) # single chain: same-chain flag = 1
h_E = torch.cat([h_E, pos, chain], dim=-1)Chain context from the mask alone
The head for unresolved residues needs to know where a residue lies in the chain. The only
information available at test time is , and there is a trap in it: trailing padding
and a C-terminal unresolved stretch are identical in that pair, both having zero coordinates and mask 0.
Any feature that touches the padded length therefore makes a chain's prediction depend on which
other chains share its batch. The submission measures every quantity from residue 0 or from the
first or last resolved residue, and where a side has no resolved residue it uses a constant,
_PO_UNK = 400, never . For each residue it computes the distance to the nearest
resolved residue on the left, , and on the right, , the length of the stretch it lies
in, its offset from the start, its offset past the last resolved residue and its distance to the
first.
def _po_chain_context(mask):
B, L = mask.shape
dev = mask.device
m = mask > 0.5
idx = torch.arange(L, device=dev).unsqueeze(0).expand(B, L)
big = L + 1
prev_r = torch.cummax(torch.where(m, idx, torch.full_like(idx, -1)), dim=1).values
rev = torch.where(m, -idx, torch.full_like(idx, -big))
nxt_r = -torch.flip(torch.cummax(torch.flip(rev, [1]), dim=1).values, [1])
any_r = m.any(1)
zero = torch.zeros_like(idx[:, 0])
first_r = torch.where(any_r, nxt_r[:, 0], zero)
last_r = torch.where(any_r, prev_r[:, -1], zero)
before, after = prev_r < 0, nxt_r > L
# "no resolved residue on this side" must be a CONSTANT, not L + 1: the padded
# length is not a property of the protein, and a C-terminal unresolved stretch
# is indistinguishable from padding. Using L here would make a chain's own
# predictions depend on which other chains share its batch.
unk = torch.full_like(idx, _PO_UNK)
d_left = torch.where(before, unk, (idx - prev_r).clamp(min=0))
d_right = torch.where(after, unk, (nxt_r - idx).clamp(min=0))
gap_len = torch.where(before | after, unk, (d_left + d_right - 1).clamp(min=0))
gap_len = torch.where(before, first_r.unsqueeze(1).expand(B, L), gap_len)
feats = {'from_start': idx,
'past_last': (idx - last_r.unsqueeze(1)).clamp(min=0),
'to_first': (first_r.unsqueeze(1) - idx).clamp(min=0),
'd_left': d_left, 'd_right': d_right, 'gap_len': gap_len}
return (feats, m, prev_r.clamp(min=0), nxt_r.clamp(max=L - 1),
(~before).to(mask.dtype), (~after).to(mask.dtype))A decoupled head
Let be the encoder state of residue (zero where unresolved), and let and be the nearest resolved residues on either side. The head reads the detached states of those two flanks, an embedding of the chain context, and a span feature. With the number of residue steps between the two flanks (the number of missing residues plus one), the distance between the flanks' atoms and \AA{} the - distance of a peptide bond,
which is near 1 for a taut extended linker and near 0 for a compact loop. The logits are
with a stop-gradient. The output is the encoder's log-probability at resolved residues and at unresolved ones.
def forward(self, X, mask):
out, h = self._encode(X, mask)
feats, m, prev_r, nxt_r, has_l, has_r = _po_chain_context(mask)
D = h.shape[-1]
hl = torch.gather(h, 1, prev_r.unsqueeze(-1).expand(-1, -1, D))
hr = torch.gather(h, 1, nxt_r.unsqueeze(-1).expand(-1, -1, D))
CA = X[:, :, 1, :]
cal = torch.gather(CA, 1, prev_r.unsqueeze(-1).expand(-1, -1, 3))
car = torch.gather(CA, 1, nxt_r.unsqueeze(-1).expand(-1, -1, 3))
both_fl = has_l * has_r
dfl = (cal - car).norm(dim=-1) * both_fl
n_miss = (feats['d_left'] + feats['d_right']).clamp(1, 400).to(X.dtype)
span = dfl / (n_miss * 3.80)
spanf = torch.stack([dfl / 20.0, span.clamp(max=2.0), both_fl, has_l, has_r,
torch.log1p(n_miss) / 6.0], -1)
g = self.gap_mlp(torch.cat([hl.detach(), hr.detach(),
self.gap_span(spanf.detach()),
self.gap_embed(feats, m)], dim=-1))
gl = F.log_softmax(g, dim=-1)
mf = (mask > 0.5).unsqueeze(-1)
return torch.where(mf, out, gl)Training without disturbing the encoder
The loss has a resolved term and a gap term, each normalised by its own count. The gap term is weighted by its natural share of the chain, , held fixed in the backward pass:
The coefficient on is then exactly 1, and the encoder sees the reference objective. The reason is that the scaffold clips the global gradient norm: a full-strength second term would shrink the encoder's step and break the guarantee. Adam is invariant to per-parameter scale, so the head still trains normally. Because the states it reads are detached, no gradient from these high-entropy targets reaches the encoder either.
def training_loss(self, X, S, mask):
"""Two independent terms. The resolved term is exactly the reference
objective (same per-residue normalisation), so the encoder trains as it
would without this head; the gap term reaches only the gap head."""
log_probs = self(X, mask)
B, L = mask.shape
idx = torch.arange(L, device=mask.device).unsqueeze(0).expand(B, L)
occupied = (mask > 0.5) | (S != 0)
last = (occupied.long() * (idx + 1)).max(dim=1).values
in_chain = (idx < last.unsqueeze(1)).float()
gap = in_chain * (1.0 - mask)
nll = F.nll_loss(log_probs.permute(0, 2, 1), S, reduction='none')
n_res = mask.sum().clamp(min=1.0)
n_gap = gap.sum().clamp(min=1.0)
loss_res = (nll * mask).sum() / n_res
loss_gap = (nll * gap).sum() / n_gap
# Weight the gap term by its natural share of the chain. The coefficient on
# loss_res is then exactly 1, so the encoder sees the reference objective
# unchanged -- which matters because the scaffold clips the GLOBAL gradient
# norm: a full-strength second term would shrink the encoder's step. Adam is
# per-parameter scale invariant, so the gap head still trains normally.
w = (n_gap / n_res).detach()
return loss_res + w * loss_gap, log_probsResults
| Method | ① | ② | ③ | |||
|---|---|---|---|---|---|---|
| Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | Sequence recovery ↑ | Perplexity ↓ | |
| Claude Opus 5 | 0.520 | 4.671 | 0.515 | 4.672 | 0.526 | 4.603 |
| 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 recovery is 0.520 on CATH 4.2, 0.515 on CATH 4.3 and 0.526 on TS50, against 0.521, 0.517 and 0.528 for the PiFold reference that shares our encoder. In perplexity we are better than that reference on CATH 4.2 (4.671 against 4.811) and slightly worse on CATH 4.3 (4.672 against 4.574); on TS50 it is 4.603 against 4.857. Both measures are clearly ahead of ProteinMPNN (0.469 recovery and 5.310 perplexity on CATH 4.2).
We are not the best entry. The strongest published recovery on CATH 4.2 is 0.544 (VFN-IF EMA+WD), and the lowest perplexity is 4.058 (VFN-IF EMA+WD). The pattern is the one the design predicts: a method that keeps the encoder fixed gains only what the unresolved positions and their boundaries can contribute, which in the agent's medium-scale runs was about one point of micro recovery, and cannot close the distance to a stronger encoder or a longer training recipe.
The agent's own development measurements, from medium-scale runs, point the same way. At medium scale the final configuration reached a micro recovery of 45.33% and a perplexity of 5.84 against PiFold's 44.34% and 6.03 in the same protocol, with recovery on resolved residues also higher (47.23% against 46.97%). On unresolved residues the final configuration lifted N-terminal stretches from 6.8% to 22.6% recovery and C-terminal ones from 7.8% to 19.5%, but internal loops only from 10.5% to 11.7%. In a length breakdown of the earlier head-only variant, before the span features and chain-break correction were added, the gain was largest on short chains (a gain of 2.25 points for chains of at most 100 residues, 0.7 to 0.8 above that), where the agent attributed it to tags making up a larger share. These figures are the agent's claims from its trace, not outputs we could check.
How we got here
Our starting point was not a model but a measurement. While reading how the reference arms treat the
data, we noticed that residues without coordinates are masked out of both the graph and the loss, and
that their log-probabilities are still written for every position. A probe confirmed that those
positions are scored as pure uniform guesses. A position-only tabular estimator on the training split
then reconstructed the common expression tag MGSSHHHHHHSSGLVPRGSH and reached about 19%
recovery and a perplexity of 14 on unresolved residues, which told us that the positions
are far from random. That became part A.
- A single unified graph over the whole chain was our first design: keep unresolved residues as nodes, add a spatial neighbourhood over resolved residues plus a sequence ladder over all residues, and let the observation pattern enter as coordinates. Its gap gains were real, but its encoder was about a point behind PiFold on resolved residues at medium scale, so the net effect was a tie.
- Isolating the unresolved residues inside that encoder (no messages in or out, stop-gradient on their head) was meant to make the contribution strictly additive. It made the resolved residues worse, not better, which showed us that the deficit was intrinsic to our own architecture and not caused by the coupling. A one-way variant, in which unresolved residues receive context but never send it, was built as well, so that resolved outputs are provably unperturbed.
- Feature additions to the new encoder did not help. A side-chain pocket-occupancy descriptor and a global composition bias were slightly worse than the plain version, and pre-norm hurt. We also tried an explicit Ramachandran basis: a probe showed a linear readout on it beats the raw cosine and sine features, which motivated it for our own encoder before we dropped that encoder.
- We kept PiFold's encoder and attached the head with detached states. That is the hybrid we submitted. It was first built as a contingency, while the isolation test was still running, and was adopted once that test showed the deficit was intrinsic. The global gradient-clipping argument came while building it, since a full-strength second loss would have changed the encoder's effective step.
- Padding invariance took one correction late. We had a sentinel for "no resolved residue on this side" equal to , which depends on how a batch is padded, and replaced it by a constant. In the earlier whole-chain encoder, a per-protein constant given to every residue had been removed, because it invites memorising the protein.
- Chain-break features (B) came from a measurement of resolved residues near gaps, where recovery falls to 25.3% beside a gap. It entered the final variant together with the span features, and that variant raised resolved recovery from 47.08% to 47.23% and internal-stretch recovery from 9.6% to 11.7% in the agent's medium-scale runs; the gain is not attributable to either change alone. A variant that added node-context features for adjacent disorder made things worse and was dropped.
- Capacity was kept at 10 layers on purpose, equal to the PiFold arm, so that any gain is attributable to the algorithm and not to size. A 16-layer test that an earlier worker had started on a free GPU was killed.
The agent's development comparisons were noisy at small scale (the agent put run-to-run variation at a half point or more), so we trusted only the medium and full-scale comparisons.
Limitations
- We do not beat the strongest published entries. The result is at the level of the PiFold reference on recovery. The encoder is unchanged, so the contribution cannot raise what the encoder can read from the resolved structure.
- The gain is bounded by the unresolved share. Only a few percent of residues are unresolved, and the head recovers a modest fraction of them. Internal loops, where the observation pattern carries the least, improved the least.
- Much of the head's signal is composition and position. Tags are predictable from position alone, and in the agent's measurement on the earlier whole-chain encoder a position-only bound was close to its predictions for terminal stretches, while internal stretches beat it by about four points. We did not repeat that breakdown for the submitted head.
- The claim that the reference models delete these residues is the agent's reading of the scaffold's reference arms, not a survey of the literature.
- Optimiser recipe and training length were not changed. We used the reference protocol with only the layer count and batch size set, so the training recipe, which the strongest published variant exploits, was left unused.
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.
- Zhangyang Gao, Jue Wang, Cheng Tan et al. (2024). UniIF: Unified Molecule Inverse Folding. NeurIPS.
- Weian Mao, Muzhi Zhu, Zheng Sun et al. (2024). De novo protein design using geometric vector field networks. ICLR.
- Peizhen Bai, Filip Miljković, Xianyuan Liu et al. (2024). Mask prior-guided denoising diffusion improves inverse protein folding.
- Yasha Ektefaie, Olivia Viessmann, Siddharth Narayanan et al. (2024). Reinforcement learning on structure-conditioned categorical diffusion for protein inverse folding.
- 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.
- Darong Li, Lian Shen, Meijia Song et al. (2026). SurfFold: a unified model for protein inverse folding by integrating surface and structural information. Bioinformatics.