Designing a drug candidate is a search through an exponentially large space of possible molecules, one small edit at a time. A language model can propose these edits, but it faces two hard walls. First, the tree of possible edit sequences explodes combinatorially, and most branches are redundant: many different edit orders and substitution sites produce the same molecule, just as shuffling symmetry-equivalent bits of a Boolean function leaves the function unchanged. Second, every intermediate structure, code script, and execution log the model has seen accumulates in its context window, and long contexts measurably degrade reasoning even when they technically fit. This proposal argues these two problems are the same problem, and that one mechanism solves both: search over molecular isomorphism classes rather than edit sequences, storing only one canonical representative per class, so that the context grows with the number of chemically distinct states explored rather than the number of raw search steps.
The idea imports a proven trick from cryptographic Boolean-function search, where restricting the search to symmetry classes shrinks a $2^{512}$ space to $2^{60}$ Carlet et al., into LLM-driven molecular optimization, where nobody currently uses it. Chemical validity is handled by a second import: the model never writes molecule strings directly, but writes executable RDKit code whose deterministic execution guarantees valid chemistry, following Coder as Editor. The result is a search agent whose context stays small because its search space has been quotiented, attacking combinatorial explosion and context saturation with a single mechanism.
Core Claim
Let $\mathcal{S}$ be the set of molecules reachable from a seed by edit sequences of length at most $d$. A naive tree search over edit sequences enumerates a state space that grows as $b^d$ for branching factor $b$, and its memory of visited states grows with the number of sequences tried. But the quotient set
$$ \mathcal{Q} \;=\; \mathcal{S}/{\cong}, \qquad |\mathcal{Q}| \;\le\; |\mathcal{S}|, $$
where $\cong$ is molecular graph isomorphism, is what actually matters for optimization: two isomorphic products have identical properties, so every duplicate visit is a wasted oracle call and wasted context tokens. The claim is that maintaining the search frontier and the in-context memory over $\mathcal{Q}$ — via graph canonicalization, so each visited molecule is hashed to one isomorphism-invariant string — simultaneously reduces oracle-call waste (fewer duplicate evaluations) and keeps the LLM's prompt within a budget that avoids documented long-context degradation. This is the direct analogue of rotation symmetry collapsing the space of 9-variable Boolean functions from $2^{512}$ to $2^{60}$ Carlet et al., and of the sensitivity-signature pruning that cut symmetry collisions from 124,000 to under 2,000 in Boolean matching Enhanced Fast Boolean Matching.
Two supporting mechanisms complete the system. Memoization caches the best substituent plan per recurring scaffold, mirroring how LEGO caches kernel plans for recurring Transformer-layer subgraphs and thereby cuts token consumption by up to 7x LEGO. And the per-branch context is built on demand as a partial fragment dependency graph — only the local chemical environment relevant to the property being optimized — mirroring DyCoder's select-visit-expand traversal, which ran 7.4x faster than static global indexing while improving Pass@1 by 59.73% on DevEval DyCoder.
Research Program
We will build QES (Quotient Edit Search), a tree-search agent with three components, each isolating one input direction as a mechanism rather than a topic.
The search layer is a best-first or Monte Carlo tree search over molecular states, where each node stores a canonical-form molecule (an isomorphism-invariant hashing string), the RDKit script that produced it, and its evaluated properties. Before any expansion, a proposed child is canonicalized; if its canonical form is already in the visited table, the branch is pruned as a duplicate regardless of which edit sequence produced it. Because ring symmetries and equivalent substitution sites make such duplicates extremely common in fragment editing, we expect the visited table to grow far more slowly than the raw node count — this is the orbit-compression effect, and measuring the ratio $|\text{sequences tried}|/|\mathcal{Q}|$ (the "orbit factor") is itself a first-class experimental question. A scaffold-keyed memo table stores, for each recurring fragment scaffold, the substituent choices already explored and their outcomes, so re-encountering a scaffold does not re-explore its subtree.
The validity layer follows Coder as Editor: a reasoning LLM proposes a natural-language edit rationale ("replace this electron-withdrawing group with a bioisostere that improves solubility"), and a coder model writes an RDKit script that performs the graph operation deterministically. Since the molecule is never serialized by the LLM itself, valency errors cannot enter through token hallucination; MECo showed this decomposition exceeds 90% intention-execution consistency where direct string editing fails Coder as Editor. We extend MECo from single-step edits to multi-step search, which its authors explicitly leave open.
The context layer assembles each expansion prompt from three compact ingredients: the current canonical molecule, an on-demand partial dependency graph of the fragments plausibly implicated in the objective (built by an LLM-driven walk over the molecular graph, DyCoder-style, then discarded), and a quotient summary of the search so far — orbit representatives with properties, plus memo hits — rather than full edit histories or execution logs. The hypothesis this layer tests is that the quotient summary is the context compression mechanism: it is what keeps prompts short without discarding information the planner needs.
The analysis program has two parts. Empirically, we measure oracle-call efficiency, property scores, diversity of discovered scaffolds, prompt token counts, and the orbit factor. Theoretically-informed, we relate the orbit factor to the automorphism structure of the seed scaffolds: molecules with large symmetry groups (multiply-substituted rings, symmetric cores) should show larger reductions, in the same way rotation-symmetric Boolean functions compress by grouping truth-table rows into orbits Maitra. This gives a predictable, testable relationship rather than an empirical accident.
Baselines
The naive reference point is random fragment editing with a validity filter: sample an editable bond or fragment on the seed, apply a random replacement from a fragment vocabulary, execute it in RDKit, and evaluate if valid. This gives the floor for both property improvement and oracle-call efficiency, and it isolates how much of QES's gain comes from search rather than from merely having a large fragment vocabulary.
The strongest existing competitor on this exact question — sample-efficient LLM-driven molecular optimization under a hard oracle budget — is FORGE, a 0.6B fragment-ranking-and-replacement model with a replay buffer of past successful edits as in-context demonstrations FORGE. FORGE reports an aggregate score of 12.42 on PMO-1k (1,000 oracle calls across 22 tasks), beating the prior best LICO at 11.71, and 2.882 on Prompt-MolOpt at Tanimoto similarity ≥ 0.6 versus a previous best of 0.824. It is the strongest because it is the only prior system that already combines LLM editing, chemical-fragment awareness, and a context mechanism (its replay buffer) under a sample-efficiency constraint. To make the comparison fair, we run QES with the same backbone model scale as FORGE, the same 1,000-call oracle budget on PMO-1k, the same fragment vocabulary, and the same tuning budget for hyperparameters; FORGE's authors' settings are reproduced from their paper. Beating FORGE means a higher PMO-1k aggregate score at equal budget, and at least matching its Prompt-MolOpt score under the similarity constraint, since a higher score achieved by abandoning similarity is not an optimization win.
Two further baselines calibrate the search-space story. On the SynthonBench surrogate suites, we run Typed GA, which achieved a mean top-1000 Docking-Call Reduction Factor of 21.5x at a 10,000-call budget, and SALSA Thompson Sampling, which achieved 39.6x under 1,000 calls SynthonBench; these are non-LLM optimizers over the same combinatorial libraries, run at identical docking budgets. Finally, the key ablation removes exactly the proposal's core ingredient: QES without canonical-form deduplication and quotient summaries, i.e., the same code-executed tree search keeping raw edit histories and all visited structures in context. If the deduplicated and raw versions score equally at equal oracle budget, the canonicalization claim is dead; if the raw version's prompts blow past the token budget or its accuracy degrades with history length, the claim is confirmed. A second ablation swaps the code-execution layer for direct SMILES generation to isolate the validity mechanism's contribution.
Why not just…?
Why not just use a bigger context window? The evidence says capacity is not the binding constraint — semantics is. RepoDebug documents monotonic accuracy degradation as codebase context grows, even well within hardware limits Jingjing Liu et al., and work on compiler intermediate representations shows verbose low-level traces cause models to lose track of global state Can Large Language Models Understand Intermediate Representations in Compilers?. Most directly, LEGO found that feeding flat graphs into monolithic prompts multiplied token consumption by up to 7x and exploration time by 2.47x while increasing hallucination, versus structured decomposition LEGO. Our raw-history ablation is designed to settle this empirically within QES itself: if long-context variants match the quotient version, we will report it and the proposal's context claim fails.
Why not just run a genetic algorithm? This is the most serious alternative, and we treat it as a real threat rather than argue it away. Typed GA already dominates above 2,500 docking calls on SynthonBench with a 21.5x DCRF SynthonBench, and graph GAs were the best performers on GuacaMol's goal-directed benchmarks GuacaMol. Two honest responses. First, SynthonBench itself reports that top GAs collapse into narrow chemical families — a diversity failure — while our orbit-quotient frontier explicitly maintains representatives across distinct scaffolds, and we will report scaffold diversity alongside scores. Second, GAs cannot consume qualitative design instructions ("keep the hinge binder, fix the solubility"), which is where the LLM layer earns its cost Coder as Editor. Still, we will run Typed GA and SALSA at matched budgets on the SynthonBench suites, and if QES loses there, the honest conclusion is that LLM search pays off only in instruction-driven settings, which our PMO-1k and Prompt-MolOpt runs are positioned to show.
Why not just fix validity with SELFIES or better tokenization? Robust encodings prevent parse failures but not the modality mismatch between what the model intends and what the string means. MECo showed that consistency between editing intention and the resulting structure improves by 38 to 86 percentage points specifically when the LLM writes executable RDKit code instead of strings, exceeding 90% consistency Coder as Editor, and FORGE found that a fragment's effect depends non-linearly on its chemical environment, which no tokenizer fixes FORGE. Our direct-generation ablation (QES without the code layer) quantifies this gap in our own setting.
Why not just pre-build a static global index of the chemical space? DyCoder's comparison is decisive here: static global dependency indexing (RepoScope) required hours of pre-indexing and ran 7.4x slower than on-demand partial-graph construction, while the dynamic approach improved accuracy by 25.63% Pass@1 on CoderEval and 59.73% on DevEval DyCoder. Combinatorial libraries of $10^9$–$10^{12}$ products make static indexing even less tenable, and SynthonBench's tabular lookup approach is exactly the ceiling we are trying to move past SynthonBench.
Proposed Experiments
The primary evaluation runs PMO-1k and Prompt-MolOpt, since these directly measure sample-efficient optimization under a 1,000-oracle-call budget and a similarity constraint, with FORGE's reported 12.42 and 2.882 as the numbers to beat FORGE. We report aggregate scores, per-task breakdowns, chemical validity rate (target: 100%, matching SoftMol's demonstration that validity need not cost performance SoftMol), and scaffold diversity of the top candidates, since diversity collapse is the known failure mode of guided search SynthonBench.
The second experiment runs the ChemCoTBench tasks (logP, solubility, QED, and the DRD2/JNK3/GSK3β bioactivity targets), the setting where MECo's editing consistency was established, letting us compare intention-execution consistency directly against MECo's >90% consistency rate in the multi-step regime MECo never tested Coder as Editor.
The third experiment attacks the combinatorial-scaling claim on SynthonBench's surrogate suites at 1M, 10M, and 100M scale, where efficiency has been shown to grow with library size (SpaceHASTEN reached 17x DCRF at 1M and 163x at 100M) SynthonBench. QES searches this space by editing synthons rather than looking them up; the decisive check is whether DCRF scales similarly, and whether the orbit factor — measured throughout as duplicate sequences caught per distinct molecule — grows with scaffold symmetry as predicted.
The fourth experiment is the context study: sweep the prompt budget and plot score against token count for QES, the raw-history ablation, and FORGE's replay buffer. The predicted signature is that quotient summaries hold score constant as search depth grows while raw histories degrade, reproducing in a molecular setting the degradation documented for long code contexts Jingjing Liu et al.. If raw histories do not degrade at the depths tested, the compression mechanism is unnecessary at this scale and the proposal should be judged only on its oracle-efficiency results — we state this falsification condition up front because it is the outcome a skeptic should most expect.
References
- A Systematic Evaluation of Evolving Highly Nonlinear Boolean Functions in Odd Sizes
- Coder as Editor: Code-driven Interpretable Molecular Editing
- Enhanced Fast Boolean Matching based on Sensitivity Signatures Pruning
- LEGO: An LLM-Enabled Hierarchical Optimizer for Tensor Computation Graphs with Structure-Aware Search and Compositional Synthesis
- Effective and Efficient Context Retrieval via Partial Dependency Graph for Repository-Level Code Generation
- Results on Rotation Symmetric Bent Functions
- FORGE: Fragment-Oriented Ranking and Generation for Context-Aware Molecular Optimization
- SynthonBench: Benchmarking Sample-Efficient Optimization in Combinatorial Chemical Spaces
- RepoDebug: Repository-Level Multi-Task and Multi-Language Debugging Evaluation of Large Language Models
- Can Large Language Models Understand Intermediate Representations in Compilers?
- GuacaMol: Benchmarking Models for de Novo Molecular Design
- From Tokens to Blocks: A Block-Diffusion Perspective on Molecular Generation