Harden lazy border_op registration and comm-artifact gating in pt_expt export#5452
Closed
Copilot wants to merge 4 commits into
Closed
Harden lazy border_op registration and comm-artifact gating in pt_expt export#5452Copilot wants to merge 4 commits into
border_op registration and comm-artifact gating in pt_expt export#5452Copilot wants to merge 4 commits into
Conversation
Co-authored-by: anyangml <137014849+anyangml@users.noreply.github.com>
for more information, see https://pre-commit.ci Co-authored-by: anyangml <137014849+anyangml@users.noreply.github.com>
Agent-Logs-Url: https://github.com/deepmodeling/deepmd-kit/sessions/a1f22436-2187-4856-9b1e-62eeaddba6bf Co-authored-by: anyangml <137014849+anyangml@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix code based on review comments
Harden lazy May 22, 2026
border_op registration and comm-artifact gating in pt_expt export
| except RuntimeError as e: | ||
| if "already has" not in str(e) and "already registered" not in str(e): | ||
| raise | ||
| _registered = True |
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.
This addresses review feedback on PR #5451 around
pt_exptlazy comm-op initialization. The fixes make registration atomic/idempotent, prevent premature op-library loading for non-comm models, and align non-serialization comm call paths with explicit initialization.Thread-safe, idempotent comm registration
deepmd/pt_expt/utils/comm.py.ensure_comm_registered()now double-checks_registeredinside the lock.torch.library.register_autograd(...)runtime “already registered/has” cases.Correct ordering in with-comm export path
deepmd/pt_expt/utils/serialization.py,_needs_with_comm_artifact(model)is evaluated before importing/callingensure_comm_registered().ValueErrorinstead of triggering unrelated op-load failures.Explicit initialization for non-serialization comm paths
ensure_comm_registered()calls at descriptor comm_dict call sites:deepmd/pt_expt/descriptor/repflows.pydeepmd/pt_expt/descriptor/repformers.pydeepmd/pt_expt/utils/__init__.pyand pt_expt test comments to reflect required lazy-init behavior.Focused regression coverage
source/tests/pt_expt/utils/test_comm_registration.pysource/tests/pt_expt/utils/test_serialization_with_comm_guard.pyWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
download-r2.pytorch.org/opt/hostedtoolcache/uv/0.11.16/x86_64/uv uv pip install torch --index-url REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either: