Designing Sequences for Target Folds on the Exact 2D HP Lattice: Conditional Autoregressive Generation versus Simulated Annealing at Equal Oracle Budget Garnet-26N Stemma seed corpus https://github.com/mihir-chauhan/research-harness-papers/tree/main/papers/lattice-protein-design-toy Abstract—We study inverse design on the exactly solvable Index Terms—HP lattice model, inverse folding, protein two-dimensional HP lattice model with chains of 16 residues: design, autoregressive models, simulated annealing given a target conformation, return a hydrophobic/polar se- quence whose unique minimum-energy conformation is the I. Introduction target. We enumerate all 802075 self-avoiding conformations (modulo lattice symmetry), score every sequence exactly, and Inverse folding—finding sequences that adopt a pre- compare a conditional encoder–decoder autoregressive (AR) scribed structure—is now dominated by conditional au- designer, trained on pairs of conformations and uniquely toregressive networks such as ProteinMPNN [1] and ESM- folding sequences, with reimplemented simulated annealing IF1 [2], whose designs are usually judged by refolding (SA), random search, a one-line contact heuristic, a per-residue conditional model and AR–annealing hybrids. All systems get them with a structure predictor such as AlphaFold [3]. the same budget K of ground-state-oracle calls per design That evaluation is approximate (the predictor can be and the same held-out targets, split by chain-reversal class wrong), expensive, and conflates two questions: whether to avoid a symmetry leak; we use five seeds. The strongest the generator proposes good sequences, and how many search baseline we found is annealing with a graded degeneracy verified candidates it needs. The classical alternative is penalty, started from the contact-heuristic sequence and tuned on a DEV partition separately for each budget (a post-hoc, stochastic search against an energy-like objective, for exploratory baseline). Against it the AR designer is ahead at example simulated annealing [4]. Which of the two is K = 10 (0.822 against 0.725; uncorrected paired p = 0.010), not preferable depends on the cost of the oracle that decides distinguishable at K = 100 (0.865 against 0.847; p = 0.327) and whether a candidate really folds to the target. behind at K = 1000 (0.900 against 0.971; p = 0.001); at K = 1 The two-dimensional hydrophobic–polar (HP) lattice the contact heuristic, which needs no oracle call, is at least as good (0.685 against 0.622). A per-residue conditional model model [5] offers a setting where this question can be that sees only each residue’s contacts and free neighbours is not asked with an exact oracle. Chains of N = 16 residues distinguishable from the AR designer at K = 100 (0.873, p = have only 802075 distinct conformations modulo rotation 0.689), and AR samples refined by graded annealing at equal and reflection, so the ground state and its degeneracy total K reach 0.913 at K = 100 and 0.978 at K = 1000, above can be computed for every one of the 216 sequences. the AR designer alone. The gap to the registered annealing baseline (0.865 against 0.086 at K = 100) is a property of that Folding in the HP model is NP-complete in general [6], baseline’s binary degeneracy objective, an effect known from and designability on lattice chains is known to be very lattice-design work with energy-gap and Z-score objectives, uneven across structures [7], but at N = 16 everything is and is not a result about the AR designer. Conditioning on enumerable and the success criterion—the ground state is the target is essential. Reversal augmentation is a no-op at unique and equals the target—is unambiguous. full data and, against controls matched on optimizer updates, helps only at small data fractions. At this scale a lookup in We use this toy to compare, at an equal and explicit the fully scored table designs every target, so the equal-budget budget K of oracle calls per design, a conditional au- comparison measures per-target oracle calls only; we report toregressive designer with simulated annealing and with the total oracle cost separately. All post-hoc comparisons are simple baselines, evaluated on target conformations never exploratory and uncorrected for multiple testing. This is a seen in training. Our questions are: (i) does the learned toy-scale CPU study; nothing here transfers to real proteins without further evidence. designer generalise to unseen conformations, (ii) does it beat search at equal oracle budget, (iii) is the conditioning Garnet-26N is the codename of an autonomous study, not a person. on the target responsible, (iv) how much do simple design Produced by the Stemma autonomous AI research pipeline; the topic choices of the baseline (objective, initialisation, tuning) was chosen to cover the field. Every reported result is traced to logged runs in the linked repository and every reference was checked against change the answer, and (v) what does the transformer arXiv, Crossref, DataCite or OpenAlex. add beyond a simple conditional rule and beyond a hybrid with search. Our contributions are modest and specific: an Lattice sequence design, negative design and energy- exact-oracle protocol with a leakage-aware split, a five- gap or Z-score objectives. Designing sequences for a given seed comparison with ablations and a data-size sweep, lattice structure is a classical problem: Yue and Dill [13] and a report of where the learned model wins and where posed inverse folding for lattice polymers, Shakhnovich it does not. Against the strongest search baseline we and Gutin [14] designed sequences for a target structure found (graded-penalty annealing started from the contact- by Monte Carlo search in sequence space, and later design heuristic sequence and tuned per budget on DEV; a post- procedures score a sequence not only by the energy hoc, exploratory baseline) the learned model is ahead only of the target but by how it compares with competing at K = 10, is not distinguishable at K = 100 and is behind conformations: through the energy gap to alternative at K = 1000; at K = 1 a trivial heuristic is at least as states [15], through algorithms that account for competing good. The large gap to the registered annealing baseline conformations (negative design) [16], or through Z-score- reflects that baseline’s binary degeneracy objective, which type criteria [17]. That a design objective must penalise the lattice-design literature on energy-gap and Z-score competing and degenerate ground states, rather than only objectives (Section II) leads one to expect, and we do reward the target’s energy, is therefore established in not present it as a finding about the learned designer. All this literature. Our observation that a graded degeneracy numbers come from a CPU-scale study of a single chain penalty changes the annealing baseline (Section V) is length, in which a lookup in the fully scored table designs consistent with that effect and should not be read as a every target, and should not be read as a statement about new finding; our contribution is only to measure it at equal real protein design. oracle budget against a learned designer, and the Z-score baseline we add follows the same idea in a simplified form II. Related Work (the Z-score of the target’s energy over all enumerated conformations). HP model and designability. The HP model of Lau and Dill [5] reduces proteins to H/P chains on a lattice III. Method with an energy that rewards H–H contacts; finding the A. HP lattice, oracle and success criterion minimum-energy conformation is NP-complete on the A conformation c of N residues is a self-avoiding walk 3D cubic lattice [6] and on the 2D square lattice [8]. on Z2 ; conformations that differ by a rotation or reflection Exact enumeration of HP sequences and their designability are identified. Two residues i, j are in contact in c, written (for 2D square and diamond lattices) has been studied (i, j) ∈ C(c), if they occupy neighbouring lattice sites and before [9], so the counts we compute are not new; what |i − j| ≥ 3. A sequence s ∈ {0, 1}N (1 = hydrophobic H) we add is a learned conditional designer and a comparison has energy on c with search at equal budget. Li et al. [7] studied how many ∑ sequences fold to each structure in a simple lattice model E(s, c) = − si sj . (1) and found highly uneven designability; our setting is the (i,j)∈C(c) inverse of structure prediction on the same model, with The oracle returns, for any sequence, Emin (s) = exhaustive enumeration playing the role of the oracle. minc E(s, c) and the degeneracy g(s) = |{c : E(s, c) = Learned HP folding. Recent work addresses the forward Emin (s)}|. We precompute both for all 2N sequences by problem of finding the optimal conformation of a given HP matrix multiplication of the contact matrix of all confor- sequence with a deep Q-network [10] or with dilated recur- mations with the pair-product vectors of the sequences. A rent networks combined with variational annealing [11]. sequence folds uniquely to a target t if E(s, t) = Emin (s) Neither designs sequences for a target. The variational- and g(s) = 1. All systems use the same objective for annealing work [11] combines autoregressive neural models selecting among candidates, with an annealing schedule and reports competitive folding ( ) on the lattice, which motivates our use of simulated f (s; t) = E(s, t) − Emin (s) + 21 ⊮[g(s) > 1], (2) annealing as the search baseline. so f = 0 if and only if s folds uniquely to t. A method with Neural inverse folding. ProteinMPNN [1] and ESM- budget K may evaluate f on K candidates and returns IF1 [2] generate sequences autoregressively conditioned on the one with the lowest f ; the design succeeds if that backbone structure, and are validated by refolding with f is 0. succ_kK is the fraction of test targets with a predictors such as AlphaFold [3]. Our designer follows the successful design. We also use a graded variant flog = same pattern at toy scale (a conditional autoregressive (E(s, t) − Emin (s)) + 21 log2 g(s) (zero iff unique) for an model on top of a transformer [12]), while replacing the extra annealing baseline; success is always judged by the refolding oracle with an exact one. same unique-ground-state criterion. Search-based design. Simulated annealing [4] is the standard stochastic-search baseline; we reimplement it and B. Conditional autoregressive designer ∏N show that its performance in this problem depends heavily The designer models pθ (s | t) = i=1 pθ (si | sHP ) Model is NP- (0.900 against 0.971); at K = 1 the hand-made contact Complete,” Journal of Computational Biology, 1998. [Online]. Available: https://doi.org/10.1089/cmb.1998.5.27 heuristic (0.685) is at least as good as the designer (0.622) [7] H. Li, R. Helling, C. Tang, and N. Wingreen, “Emergence of with no learning and no oracle call. The large gap to the Preferred Structures in a Simple Model of Protein Folding,” registered annealing baseline (0.086 at K = 100) comes Science, 1996. [Online]. Available: https://doi.org/10.1126/ from its binary degeneracy objective, an effect that the science.273.5275.666 [8] P. CRESCENZI, D. GOLDMAN, C. PAPADIMITRIOU, classical lattice-design literature on energy-gap, negative- A. PICCOLBONI, and M. YANNAKAKIS, “On the Complexity design and Z-score objectives leads one to expect; it is of Protein Folding,” Journal of Computational Biology, 1998. not evidence about the learned designer. A per-residue [Online]. Available: https://doi.org/10.1089/cmb.1998.5.423 [9] S. L. Narasimhan, A. K. Rajarajan, and L. Vardharaj, “HP- conditional model is not distinguishable from the designer sequence design for lattice proteins - an exact enumeration at K ≥ 100 in our five seeds, so the transformer’s measured study on diamond as well as square lattice,” arXiv preprint arXiv:1204.3438, 2012. [Online]. Available: https: //arxiv.org/abs/1204.3438 [10] K. Yang, H. Huang, O. Vandans, A. Murali, F. Tian, R. H. C. Yap, and L. Dai, “Applying Deep Reinforcement Learning to the HP Model for Protein Structure Prediction,” arXiv preprint arXiv:2211.14939, 2022. [Online]. Available: https://arxiv.org/abs/2211.14939 [11] S. A. Khandoker, E. M. Inack, and M. Hibat-Allah, “Lattice Protein Folding with Variational Annealing,” arXiv preprint arXiv:2502.20632, 2025. [Online]. Available: https: //arxiv.org/abs/2502.20632 [12] A. Vaswani, N. Shazeer, N. Parmar, J. Uszkoreit, L. Jones, A. N. Gomez, L. Kaiser, and I. Polosukhin, “Attention Is All You Need,” arXiv preprint arXiv:1706.03762, 2017. [Online]. Available: https://arxiv.org/abs/1706.03762 [13] K. Yue and K. A. Dill, “Inverse protein folding problem: designing polymer sequences.” Proceedings of the National Academy of Sciences, 1992. [Online]. Available: https://doi. org/10.1073/pnas.89.9.4163 [14] E. I. Shakhnovich and A. M. Gutin, “Engineering of stable and fast-folding sequences of model proteins.” Proceedings of the National Academy of Sciences, 1993. [Online]. Available: https://doi.org/10.1073/pnas.90.15.7195 [15] A. S˘ali, E. Shakhnovich, and M. Karplus, “How does a protein fold?” Nature, 1994. [Online]. Available: https: //doi.org/10.1038/369248a0 [16] J. M. Deutsch and T. Kurosky, “New Algorithm for Protein Design,” Physical Review Letters, 1996. [Online]. Available: https://doi.org/10.1103/PhysRevLett.76.323 [17] F. Seno, M. Vendruscolo, A. Maritan, and J. R. Banavar, “Optimal Protein Design Procedure,” Physical Review Letters, 1996. [Online]. Available: https://doi.org/10.1103/ PhysRevLett.77.1901