fix: use bin centers, not left edges, for pLDDT/PAE/PDE classificatio… - #355
Open
Pana-TsK wants to merge 1 commit into
Open
fix: use bin centers, not left edges, for pLDDT/PAE/PDE classificatio…#355Pana-TsK wants to merge 1 commit into
Pana-TsK wants to merge 1 commit into
Conversation
…n targets all_atom_plddt_loss, pae_loss, and pde_loss each discretize a continuous error value into classification bins via binned_one_hot(x, v_bins), which assigns x to whichever entry of v_bins is nearest. All three built v_bins as bin_min + arange(no_bins) * bin_size -- the left edge of each bin -- instead of the bin center. get_bin_centers (core/metrics/confidence.py), which decodes predicted bin probabilities back into pLDDT/PAE/PDE scores at inference time, and all_atom_distogram_loss's target-binning both correctly use bin_min + bin_size/2 + arange(no_bins) * bin_size. The mismatch meant these three losses were trained against a grid shifted half a bin width from the grid their own output is decoded against, on essentially every training step (confidence losses are enabled by default) -- a systematic, silent miscalibration of every reported pLDDT/PAE/PDE score. Fix mirrors distogram.py's existing correct pattern. Added a regression test per loss that patches binned_one_hot to capture the v_bins it's actually called with and asserts it matches get_bin_centers's output; confirmed each test fails against the pre-fix code and passes after.
Collaborator
|
Looping in @gnikolenyi – @Pana-TsK you're absolutely on a roll here, well done! |
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
all_atom_plddt_loss,pae_loss, andpde_losseach discretize a continuous error value into classification bins viabinned_one_hot(x, v_bins), which assignsxto whichever entry ofv_binsis nearest. All three builtv_binsasbin_min + arange(no_bins) * bin_size— the left edge of each bin — instead of the bin center.get_bin_centers(core/metrics/confidence.py), which decodes predicted bin probabilities back into pLDDT/PAE/PDE scores at inference time, andall_atom_distogram_loss's target-binning both correctly usebin_min + bin_size/2 + arange(no_bins) * bin_size.Impact
The mismatch meant these three losses were trained against a grid shifted half a bin width from the grid their own output is decoded against, on essentially every training step (confidence losses are enabled by default). This is a systematic, silent miscalibration of every reported pLDDT/PAE/PDE score — it doesn't affect predicted coordinates (distogram/diffusion/FAPE
losses are unaffected), only the confidence heads' training signal and the scores derived from them.
Changes
openfold3/core/loss/confidence.py: add thebin_size / 2offset inall_atom_plddt_loss,pae_loss, andpde_loss, mirroring the patterndistogram.pyalready uses correctly.Testing
Added one regression test per loss in
openfold3/tests/test_confidence_loss.pythat patchesbinned_one_hotto capture thev_binsit's actually called with and asserts it matchesget_bin_centers's output for the samebin_min/bin_max/no_bins. Confirmed each new test fails against the pre-fix code and passes after. Full existing test suite for these losses (test_confidence_loss.py,test_distogram_loss.py,test_diffusion_loss.py,test_loss_weights.py) passes with no regressions.ruff format --checkandruff checkclean.