Fix batched supervised chi periodicity loss#573
Open
taivu1998 wants to merge 1 commit into
Open
Conversation
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
Fixes #381.
This PR fixes batched chi-periodicity handling in
supervised_chi_loss(). The previous einsum used to constructchi_pi_periodicomitted the ellipsis from the output equation:"...ij,jk->ik"For batched
aatypetensors, that reduces leading batch dimensions and produces a[N, 4]periodicity mask instead of[*batch_dims, N, 4]. As a result, side-chain chi periodicity could be shared across different examples at the same residue index.Changes
chi_pi_periodic = table[aatype, ...]angles_sin_cos.new_tensor(...).supervised_chi_loss()docstring for chi-only ground-truth tensors.Validation
PYTHONPATH=/private/tmp/openfold-issue-381-test-stubs:$PYTHONPATH /private/tmp/openfold-issue-381-venv/bin/python -m pytest tests/test_loss.py -k "supervised_chi_loss" -q1 passed, 1 skipped, 21 deselectedpython -m py_compile openfold/utils/loss.py tests/test_loss.pygit diff --check(1, 4), old loss:0.0(2, 1, 4), fixed loss:1.9997999668121338Note: the local macOS environment does not have OpenFold's compiled
attn_core_inplace_cudaextension. For the focused pytest selection, I used a temporary import stub outside the repository so the loss test module could collect; the stub was not executed by the supervised-chi tests.