Repository navigation
Conversation
The frame generators wrote the translation as np.array([0, 0, 0]), which numpy makes int64, while the rotation comes out float from np.cos and np.sin. Four literals in frames.py now build it as np.zeros(3, dtype=np.float32). The translation is zero in all four, so the coordinates are unchanged. symmetry_maps writes the translation into a float tensor by index, which requires matching dtypes, so symmetric designs failed in collate_examples before the first diffusion step. Everywhere else the translation is only added to coordinates, where an integer promotes, so nothing caught it earlier. Adds a regression test over C2, C3 and D2 that builds its frames with the real generators, so the dtype is covered where it is set. Fixes #418
This branch has not been deployed
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.
Fixes #418
Problem
Symmetric designs fail in
collate_exampleswith a dtype mismatch ontranslation[row, target] = t, before the first diffusion step. Traceback and repro in#418.
get_cyclic_framesandget_dihedral_framesbuild a frame's translation asnp.array([0, 0, 0]), which isint64.framecoords_to_RTsdivides the rotation by anorm, so
Rcomes out float, butT = Oripasses the integer dtype through.AddSymmetryFeats.make_transforms_dictcarries it intofeats["sym_transform"].symmetry_mapsthen writes it by index intotranslation = torch.zeros(b, l, 3), whichis float, and an indexed write requires the dtypes to match.
batching.pyarrived with #401 (2026-10-14), so this path is only reached since then.test_rfd3_batch_symmetry.pydoes not cover it, and could not: it buildssym_transformby hand because it needs a non-zero translation and a different frame per example to tell
a per-example mapping from a shared one. That leaves the dtype the generators produce
untested, which is what the new test pins.
Fix
Give the translation a float dtype where it is created, at the four literals in
frames.py:This changes no value. The translation is exactly zero in every generator, and consumers
already add it to float coordinates:
atom_array.py:161doesatom_array.coord += T,with a comment that T should be 0. The rotations were always float, since they come from
np.cosandnp.sin; only the translation was integer.I changed the generators rather than casting in
framecoords_to_RTsor atbatching.py:190, because that is where a translation in angstroms is being stored as aninteger, and a cast further down leaves the next reader of it to trip over the same thing.
Verification
test_frame_translation_keeps_the_rotation_dtypeinmodels/rfd3/tests/test_symmetry_frames.py, parametrized over C2, C3 and D2. It goesthrough
get_symmetry_frames_from_symmetry_idanddecompose_symmetry_frame, thepath a real design takes. It fails on
productionfor all three groups and passeswith the fix; the file goes from 23 to 26 passing tests.
rfd3 designwith{"length": 200, "symmetry": {"id": "C2"}}on thedefault settings. On
productionit raises insymmetry_maps; with the fix itcompletes and writes a two-chain C2 assembly (200 residues per chain, 0.03 A RMSD
between one chain and the other rotated 180 degrees about z).
models/rfd3/testspasses: 98 tests, nofailures. (
test_symmetry.pyerrors during collection on missing json test data, bothwith and without this change.)
over thirteen jobs. Geometry checked on one C6 assembly of six 500-residue chains: each
chain superimposes on the first at one of the six multiples of 60 degrees, every angle
used once, worst CA RMSD 0.086 A, assembly centred on the origin to within 0.02 A.
Disclosure
This change was prepared with AI assistance. The test and the end-to-end run above were
both executed.