Fix atom backward mask for attributed edge removal#152
Merged
bengioe merged 1 commit intoMay 21, 2026
Merged
Conversation
bengioe
approved these changes
May 21, 2026
bengioe
left a comment
Collaborator
There was a problem hiding this comment.
Good catch!
Thank you for the contribution.
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
This PR fixes a mismatch between the atom-level molecular environment's backward
action mask and the parent-counting logic used by the graph-building
environment.
Previously,
MolBuildingEnvContext.graph_to_DataallowedRemoveEdgefor anynon-bridge edge. This included edges with bond attributes such as
type=BondType.DOUBLE. However,GraphBuildingEnv.parents()andcount_backward_transitions()only allow direct edge removal when the edge hasno attributes; attributed edges should first remove the edge attribute and only
then remove the plain edge.
Why this matters
When sampling uniform backward trajectories from QM9 molecules, the old mask
could sample
RemoveEdgedirectly on a typed bond. The reverse forward action isthen only
AddEdge, which does not recreate the original bond attribute. Thiscan produce inconsistent trajectories where applying the stored forward action
does not recover the stored child graph.
This mainly affects training with uniform backward and results in unstable training.
Change
RemoveEdgeto be both non-bridge and attribute-free.removing the bond attribute remains allowed, and that the backward mask count
agrees with
count_backward_transitions.Validation
Locally verified the regression logic with an RDKit-enabled environment:
Also verified on a QM9 backward-sampling diagnostic that the fix removes the
inconsistent attributed-edge transitions: