Reward-Guided Search
A plain request returns whatever the model samples. A request carrying a
search block instead runs a beam search over the generation trajectory: at
fixed points along the trajectory it branches each surviving candidate,
scores the branches, and keeps the best ones to continue.
This is not best-of-N. Best-of-N pays for every sample in full and throws most of them away at the end. A beam search spends its budget on trajectories that are already going somewhere, and abandons the rest partway through, which is why it returns better designs at the same cost.
Everything on this page is optional. Requests without a search block are
unaffected.
How a Search Runs
At each step in step_checkpoints:
- Every surviving candidate is branched into
n_branchcopies. - Each branch is rolled out to a finished structure, purely so it can be scored. These are scoring rollouts, and they are where a search spends its time.
- Each rollout is scored against the reward: the weighted sum of the metric
values named in
weights. - The best
beam_widthcandidates survive and continue from the checkpoint. The rest are discarded.
The first entry of step_checkpoints is the start of the trajectory, where
there is nothing yet to prune, and the last is the end of it. So the number of
branch-and-prune rounds is one less than the number of checkpoints.
Cost is roughly beam_width * n_branch * (len(step_checkpoints) - 1) scoring
rollouts per replicate. Each deployment enforces its own ceiling on this; refer
to Deployment Limits for
NIM_MAX_SEARCH_ROLLOUTS.
The search Block
reward_metrics_tags and metrics.tags are separate on purpose. The first
decides what the search scores against while it runs; the second decides what
is reported on the designs that come back. A metric can be in either, both, or
neither.
clip_values is how a multi-objective search stops one term from dominating.
A hydrogen-bond count with no upper bound will happily trade away everything
else to add one more bond; clipping it at six says “six is enough, now
optimize something else”. Clipping changes only the reward, never the metric
values reported in the response.
Keeping Intermediates
A scoring rollout that loses its branch is still a complete, finished design,
and it has already been paid for. intermediate_save_min_reward returns the
good ones instead of discarding them, which raises the number of usable
designs per GPU-hour at no extra compute cost. A threshold rather than a
boolean, because “all” would bury the beam in near-misses.
Setting it makes the design count exceed sampling.num_replicates. Designs
kept this way carry origin search_intermediate.
Choosing a Reward
Any metric the deployment can run may be weighted, including the refolding oracle’s confidence. Scoring against the oracle during generation, rather than only checking it at the end, is the strongest signal a search can use.
This NIM ships with no oracle built in. Without one, a search is not merely unscored on that axis; it is restricted to the non-oracle metrics, a meaningfully smaller set of signals. Refer to Oracles.
A tag the running deployment cannot satisfy is rejected at request time rather than silently scoring nothing.
What Comes Back
A searched response carries a search report alongside the designs:
completion_rollouts is not the number of designs returned, and it is usually
much larger. Read it when you want to know what the request cost.
Each design carries an origin saying how it was produced. The service sets
it; a request never does.
Branch on origin, not on position in the list. search_final and
search_intermediate always carry a search_reward, and sample never does.
search_candidate carries one too, on every backend: an export scores the
checkpoint it stops at and skips only the pruning, so each branch comes back
with the reward the service would have ranked it by, and with the metrics
metrics.tags asked for. That is what makes a local prune reproduce the
service’s own.
Replicates, One Per Batch
A search block and a batch cannot combine. A beam returns its survivors and
any kept scoring rollouts as one flat list per replicate, and a batch leaves
no way to attribute an entry to the replicate it came from, so the two are
refused together rather than returning designs whose origin and seed are
guesses. Because batch_size defaults to num_replicates, a search with
sampling.num_replicates > 1 must set sampling.batch_size: 1 explicitly.
Several replicates are supported, and each runs as its own batch. That is what shapes the handover below: the service makes one model call per replicate, so the candidates of replicate 0 all arrive before any of replicate 1’s.
Refer to Replicates and Batching.
Handing the Beam Back
The service prunes using the reward you described. Sometimes the model that should decide which candidates survive is one the service has never heard of, such as your own scoring model, a wet-lab constraint or a human looking at structures.
Two fields let you take that decision. The service branches, hands the candidates back, and stops. You rank them on your own time, while the GPU serves other requests. Then you send the survivors back and the trajectory continues from where it paused.
The service never prunes a handover. Every branch comes back and you choose,
which is the entire point of splitting the run. export_candidates and
resume are the two halves of one round trip, so send one per call.
The Returned State
A handover response carries search.state:
The service keeps no copy and holds nothing between calls. The state is yours, and a resume is just another stateless request that happens to carry one.
Choosing Survivors
Designs come back in candidate order: design i is candidate i. So ranking
the returned structures gives you the indices directly, and you never parse
the payload.
Send those indices as resume.selection, one entry per beam slot per input,
in slot order. With several replicates, entry j must name a candidate of
input j % num_replicates. A selection that moves a candidate from one input
to another is refused: every shape would still be valid, and the results would
silently mix.
The entries are interleaved by input; the candidates are not. Each design
reports its own replicate_index; read that rather than deriving an input
from the index.
With beam_width: 2, n_branch: 2 and num_replicates: 2, an export returns
eight candidates: rows 0–3 are input 0 and rows 4–7 are input 1, because each
replicate ran as its own batch. A selection then names one candidate per slot
per input, interleaved by input:
Slot 0 keeps candidate 0 for input 0 and candidate 4 for input 1; slot 1 keeps
1 and 5. [0, 1, 2, 3] is refused, because candidates 1 and 3 belong to input
0 and sit at positions that name input 1. Repeating an index within its own
input is allowed; a beam may keep one branch twice.
A selection is always required. Nothing was pruned before the handover, so the service has no way to know which candidates you kept.
resume.seed seeds the continued branches and is independent of the seed the
first call used, so a resume may continue on a new stream. It names the whole
request, not one replicate: replicate i continues on (resume.seed + i) mod 2**63, the same rule sampling.seed follows under Replicates and
Batching.
Set it equal to the first call’s sampling.seed, and set sampling.seed on
both calls, and the split run returns designs identical to the
uninterrupted one whenever you keep what the service would have kept. Both
conditions are needed: the resume rebuilds the input features, and an input
whose length is a range is drawn again without a seed.
On a resume, step_checkpoints begins at the step the state belongs to rather
than at 0, and still ends at num_steps.
A State Belongs to Its Backend
The backends do not share a trajectory, so a state is refused by any backend other than the one that wrote it. Resume it where it was made. Refer to Execution Backend and Compile Tuning.
Limits and Refusals
- A state is at most 64 MiB of base64 text. It grows with candidates and token count, not with the schedule length.
- A selection names at most 256 candidates.
- A state holds one block per replicate, each at that replicate’s own padded
token count. A resume must featurize each input to the length its block
records, which is what sending the same
sampling.seedguarantees. - A state is rejected, rather than reinterpreted, when it comes from a different release, different checkpoints, a different backend, or an input whose padded token count does not match. Each refusal names what differs.
- The payload is read back with
weights_only=True, so loading a state cannot execute code. - The state is not signed. Nothing in it authenticates its contents, so a payload altered in transit may load with changed tensor values rather than being rejected; and the backends differ on how far they notice. Treat a state as data you are responsible for, keep it on a path you trust, and do not accept one from a third party.
- The rollout ceiling counts one interval for a handover call, not the whole schedule, so a split run is never refused for being more expensive than the single call it replaces.
Round Trip
A small_molecule_binder request that branches at step 30 and stops, with the
candidates to be ranked externally. The input file is elided for readability;
refer to Example Requests for a complete one.
The response returns every branch with origin search_candidate, plus
search.state. Rank those designs however you like, then continue the two you
chose:
The two calls together cost the same completion rollouts as the single uninterrupted call they replace. Splitting the search buys you the choice, not extra compute.