Repository navigation
esmfold2: accept lm_hidden_states in fold() - #415
Open
daylight-00 wants to merge 2 commits into
Open
daylight-00 wants to merge 2 commits into
daylight-00 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Three unresolved moderate findings remain in the reviewed implementation.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds reusable precomputed ESMC hidden-state support to ESMFold2 folding, public standalone LM-state computation, and expanded API tests.
Changes:
- Validates and forwards
lm_hidden_statesthroughfold(). - Adds
compute_lm_hidden_states()to both model variants. - Extends tests for validation, offloading, masking, and reuse.
| File | Summary | Review findings |
|---|---|---|
tests/models/esmfold2_api_test.py |
Adds coverage for new LM-state workflows. | None |
esm/models/esmfold2/processor.py |
Validates and forwards supplied LM states. | Moderate findings: adapter-aware shim lookup (1 vote); floating-dtype contract validation (3 votes). |
esm/models/esmfold2/model.py |
Adds standalone LM-state computation. | None |
esm/models/esmfold2/experimental.py |
Adds the experimental model helper. | Moderate autocast precision discrepancy (1 vote). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
daylight-00
force-pushed
the
draft/lm-hidden-states
branch
from
September 27, 2026 11:01
6fbfb87 to
7370b7b
Compare
- ESMFold2InputBuilder.fold() takes precomputed lm_hidden_states, checked against the input and the LM shim and cast to the shim's dtype; lm_mask_pct alongside them raises. - fold() refuses to run without ESMC or supplied states instead of silently dropping the LM pathway; raw forward() is unchanged. - Add a public compute_lm_hidden_states() to both ESMFold2 models; a standalone call returns an offloaded ESMC to CPU.
daylight-00
force-pushed
the
draft/lm-hidden-states
branch
from
September 27, 2026 11:13
7370b7b to
9e383fc
Compare
daylight-00
marked this pull request as ready for review
September 27, 2026 11:15
Brings the PR onto current main and narrows it to the hidden-states API. - the conflict was only in tests/models/esmfold2_api_test.py: main's file plus the state tests, on main's fixtures (`ccd_subset`, `tiny_esmfold2_experimental`) - `fold()` no longer refuses a model without ESMC; the docstring states that matching supplied states to the input is the caller's responsibility - the fp8 context/padding mock test is dropped with the seam it patched, which main no longer has
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.

Summary
ESMFold2InputBuilder.fold()accepts precomputedlm_hidden_states(e.g. to reuse one ESMC pass across seeds or sampler settings).lm_mask_pctalongside them raises (the mask only acts inside the ESMC pass).compute_lm_hidden_states()onEsmFold2ModelandEsmFold2ExperimentalModel: wraps the existing private helper and resolveslm_mask_pct=Nonefrom config. OnEsmFold2Model, a standalone call returns the ESMC backbone to CPU when_offload_esmc=True; the experimental model does not implement ESMC offloading.fold()without ESMC and without states behaves as before.Tests
forward()'s own LM pass (release and experimental), the backbone requirement, and offload /lm_mask_pctdefaults through a mock seam.tests/modelson CPU againstmain(90d6497): 308 passed / 7 xfailed onmain, 329 passed / 7 xfailed here; the 21 new tests pass and no existing test changes status.gpusmoke test (tiny model, CUDA): a standalone call leaves ESMC on CPU and its states fold. Passed on an RTX 6000 Ada.ruff0.15.16 passes;ty0.0.49 reports the same 82 diagnostics onmainand on this branch, none new.Notes
mainat 90d6497 by a merge commit; the tests use its fixtures (ccd_subset,tiny_esmfold2_experimental).fold()refuse a model without ESMC. That is left out, to keep this PR to the hidden-states API.