-
Notifications
You must be signed in to change notification settings - Fork 158
fix(system): isolate sliced system metadata #1014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
njzjz-bot
wants to merge
3
commits into
deepmodeling:master
Choose a base branch
from
njzjz-bot:fix/issue-985
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−3
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix verified --
test_sub_system_does_not_alias_metadatafails at the merge base (AssertionError: ['X'] != ['H']) and passes here, and I confirmedatom_names,atom_types,coordsandcellsall leaked pre-fix. Thanks for closing this properly.One tradeoff worth reconsidering. The comment above is right that advanced indexing already produces a copy -- which means for those selectors this
deepcopyis a second full memcpy of the frame data. Measured on a 20k-frame x 100-atom system, merge base vs this head:sub_system(permutation)sub_system(list)sub_system(slice)shuffle()System.shuffle(),to("list")(which slices per frame), and mixed-format train/test splitting all sit on this path. The CodSpeed suite only coverstest_import/test_cli, so it will not flag this.Copying only when the result actually aliases the source keeps the fix and drops the redundancy:
Note that swapping
deepcopyfor.copy()on its own buys nothing -- I measured 632 us vs 638 us on a(1000,50,3)array. The cost is the redundant copy, notdeepcopy. The frame-independent branch below should keep its unconditionaldeepcopy; that one is the actual #985 fix.Minor, for the record:
test_first_append_does_not_alias_sourcepasses at the merge base, because the first-appenddeepcopylanded on master via #1015 (2cd82ee) before this branch's merge base -- so it arrived here through the master merge rather than from527e2d4. Harmless redundant coverage, buttest_sub_system_does_not_alias_metadatais the test actually guarding this change.