Skip to content

refactor: share session setup and prediction between the two adapters - #666

Merged
DimaMolod merged 1 commit into
mainfrom
refactor/prediction-adapters
Oct 14, 2026
Merged

DimaMolod merged 1 commit into
mainfrom
refactor/prediction-adapters

Conversation

@DimaMolod

Copy link
Copy Markdown
Collaborator

Plan item 2 of 3: share the prediction execution code between the two adapters.

Problem

PreparedPredictionAdapter (the single-fold command) and AlphaPulldownPredictionAdapter (the batch command) each had their own copy of:

  • configuration validation;
  • backend selection and setup;
  • seed choice;
  • the predict and post-process loop.

A fix had to reach both copies.

Change

Two private helpers in prediction_batch.py, used by both adapters:

  • _setup_session validates the configuration, selects the backend, sets it up and returns the existing session object.
  • _predict_and_postprocess chooses the seed with the existing policy, predicts, and post-processes each yielded fold.

Parsing, feature loading, output-directory resolution and fold composition stay in the adapters. The classes, method signatures, session object and backend result dictionaries are all unchanged.

Behaviour kept

  • One setup per resident batch.
  • The seed is chosen once per command or batch job, as before.
  • A complex's AF3 inputs stay one prediction; independent manifest jobs stay separate.
  • AF2 monomer and multimer grouping is unchanged.
  • A resumed fold that yields nothing still counts as done.
  • Setup errors propagate; a job's own failure leaves later jobs running.

Tests

  • Parity: both adapters, given the same prepared AF3 complex, with the seed unset and set. Every backend call is compared: backend selection, setup, prediction and each post-processing call.
  • Failures: a job failing in prediction, and one failing in post-processing. The next job still completes, and setup ran once.
  • Existing tests: setup reuse, the AF3 seed policy for both adapters, resumed folds that yield nothing, CLI exit codes and naming. All pass unchanged.
  • Unit + integration, both release images: identical to main, plus the new tests. AF2 image: 978 passed. AF3 image: 1049 passed.
  • GPU: the full AF2 and AF3 prediction and resume checks run on main after this round is merged.

🤖 Generated with Claude Code

PreparedPredictionAdapter (the single-fold command) and
AlphaPulldownPredictionAdapter (the batch command) each validated the
configuration, selected and set up the backend, picked the seed, predicted and
post-processed every yielded fold, in two copies a fix had to reach twice. Two
private helpers now do it, and both adapters delegate to them; parsing, feature
loading, output directories and fold composition stay in the adapters.

Behaviour is unchanged: one setup per resident batch, the seed chosen once per
command or batch job as before, a resumed fold that yields nothing still counts
as done, and setup errors propagate while a job's own failure leaves the others
running. New tests drive both adapters with the same prepared fold and compare
every backend call, and fail a job in prediction or in post-processing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@DimaMolod
DimaMolod merged commit 43c0eef into main Oct 14, 2026
6 checks passed
@DimaMolod
DimaMolod deleted the refactor/prediction-adapters branch October 14, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant