Cache template features per query in TemplateHitFeaturizer - #22
Open
ssiddhantsharma wants to merge 1 commit into
Open
Cache template features per query in TemplateHitFeaturizer#22ssiddhantsharma wants to merge 1 commit into
ssiddhantsharma wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TemplateHitFeaturizer.get_templatesruns 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=Truea single step can block for tens of minutes when PDBe is slow (up to ~20 candidaterequests.get(..., timeout=30)+ kalign, re-run each step). Observed in a run as a 34-minute gap between two consecutive featurization steps of the same trajectory:Fix
Memoize
get_templateson(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:
Notes
make_template_featurecallsget_templateswithmax_template_date=None; a caller that variesmax_template_dateper call for the same sequence should add it to the key.