Skip to content

Cache template features per query in TemplateHitFeaturizer - #4

Closed
ssiddhantsharma wants to merge 1 commit into
escalante-bio:mainfrom
ssiddhantsharma:cache-template-features
Closed

Cache template features per query in TemplateHitFeaturizer#4
ssiddhantsharma wants to merge 1 commit into
escalante-bio:mainfrom
ssiddhantsharma:cache-template-features

Conversation

@ssiddhantsharma

@ssiddhantsharma ssiddhantsharma commented Aug 13, 2026

Copy link
Copy Markdown

TemplateHitFeaturizer.get_templates (vendored under OpenDDE/) runs the full template pipeline — prefilter, dedup, remote mmCIF fetch (PDBe), and kalign on every call. In iterative / optimization-in-the-loop inference (e.g. hallucination), the same fixed target chain is featurized on every optimization step, so this identical work (including the network fetch) repeats hundreds of times per trajectory.

With fetch_remote=True a single step can block for tens of minutes when PDBe is slow. Observed as a 34-minute gap between two consecutive featurization steps of the same trajectory:

[11:47:45] opendde.data.inference.infer_dataloader: Featurizing design...
[12:21:27] opendde.data.inference.infer_dataloader: Featurizing design...

Fix

Memoize get_templates on (sequence_uid, query_sequence) — computed once per unique query, reused thereafter. Single-shot inference is unaffected (each sequence is featurized once, so the cache never hits). After the change, featurization steps run in seconds:

[19:22:55] infer_dataloader: Featurizing design...
[19:23:19] infer_dataloader: Featurizing design...

Same change proposed upstream at aurekaresearch/OpenDDE#22.

Notes

  • The cache lives on the featurizer instance and is bounded by the number of unique query sequences it sees.
  • make_template_feature calls get_templates with max_template_date=None; a caller that varies it per call for the same sequence should add it to the key.

get_templates re-runs the full template search (remote mmCIF fetch + kalign)
on every call. In iterative inference (e.g. hallucination) the same fixed
target chain is featurized every optimization step, repeating identical
remote fetches and stalling the loop. Memoize by (sequence_uid, query_sequence)
so templates are computed once per unique query.
@ssiddhantsharma ssiddhantsharma closed this by deleting the head repository Sep 2, 2026
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