Skip to content

Fix ESM3 bf16 forward - #417

Open
bviggiano wants to merge 4 commits into
Biohub:mainfrom
bviggiano:fix/esm3-bf16
Open

bviggiano wants to merge 4 commits into
Biohub:mainfrom
bviggiano:fix/esm3-bf16

Conversation

@bviggiano

@bviggiano bviggiano commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #178.

Running ESM3 in bf16 (the default for the published weights) fails on the forward pass with the following message: mat1 and mat2 must have the same dtype.

I found two places where this happens and applied patches:

  • EncodeInputs: ESM3.forward fills pLDDT in as fp32, so the RBF features reach the bf16 pLDDT projections in fp32. They are now cast to the projection's dtype.
  • GeometricReasoningOriginalImpl: the frames stay fp32 by design, so applying them to the bf16 vector projections fails. The geometric terms are now computed in fp32 and cast back before out_proj.

I made sure the fp32 behaviour was unchanged. This PR adds tests/models/esm3_test.py and tests/layers/geom_attention_test.py, which both currently fail on main. lint-allandcov-test` pass locally.

Feel free to make any edits!

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.

new pip install; ESM3 bfloat16 / float32 compatibility error

1 participant