Skip to content

fix: try fix dpa4 compile#5483

Draft
anyangml wants to merge 4 commits into
deepmodeling:masterfrom
anyangml:fix/dpa4-multitask-compile
Draft

fix: try fix dpa4 compile#5483
anyangml wants to merge 4 commits into
deepmodeling:masterfrom
anyangml:fix/dpa4-multitask-compile

Conversation

@anyangml
Copy link
Copy Markdown
Collaborator

@anyangml anyangml commented Jun 1, 2026

No description provided.

Copilot AI review requested due to automatic review settings June 1, 2026 08:43
@anyangml anyangml marked this pull request as draft June 1, 2026 08:43
@dosubot dosubot Bot added the bug label Jun 1, 2026
@github-actions github-actions Bot added the Python label Jun 1, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

Caution

Review failed

The head commit changed during the review from 4602960 to c0565b8.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

val = getattr(fitting, aname, None)
if val is not None and torch.is_tensor(val):
names.append(_FIT_ATTR_PREFIX + aname)
except AttributeError:
names.append(_FIT_ATTR_PREFIX + aname)
except AttributeError:
pass
except AttributeError:
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to improve/repair the PyTorch-compiled execution path for the SeZM/DPA4 model, primarily by reducing recompiles/OOM in multi-task setups and addressing symbolic-shape tracing issues in make_fx.

Changes:

  • Add module-level compile sharing and promote selected per-task buffers (e.g., out_bias, bias_atom_e, case_embd) as FX inputs to enable compiled-graph reuse across shared-parameter tasks.
  • Add additional symbolic-shape anti-aliasing logic for trace inputs and temporarily disable ShapeEnv duck sizing during tracing.
  • Change edge-list construction to append a single masked dummy edge (instead of two) and adjust related documentation/behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread deepmd/pt/model/model/sezm_model.py
Comment on lines 2181 to 2184
aparam: torch.Tensor | None = None,
charge_spin: torch.Tensor | None = None,
*,
do_atomic_virial: bool = False,
charge_spin: torch.Tensor | None = None,
) -> torch.nn.Module:
Comment on lines +1974 to +1997
_ss_mod = None
_orig_se_init = None
try:
import torch.fx.experimental.symbolic_shapes as _ss_mod # type: ignore[no-redef]
except Exception:
_ss_mod = None
if _ss_mod is not None and hasattr(_ss_mod, "ShapeEnv"):
_orig_se_init = _ss_mod.ShapeEnv.__init__

def _no_duck_shapeenv_init(self, *args, **kwargs): # type: ignore[no-untyped-def]
kwargs.setdefault("duck_shape", False)
return _orig_se_init(self, *args, **kwargs)

_ss_mod.ShapeEnv.__init__ = _no_duck_shapeenv_init
try:
traced = make_fx(
compute_fn,
tracing_mode="symbolic",
_allow_non_fake_inputs=True,
decomposition_table=decomp_table,
)(*trace_args)
finally:
if _orig_se_init is not None:
_ss_mod.ShapeEnv.__init__ = _orig_se_init
Comment on lines +2390 to 2394
# === Step 3. Compact edges + append one masked dummy ===
# NOTE: Always append exactly one masked dummy edge.
# ``torch.nonzero(edge_mask_actual)`` produces a data-dependent
# number of valid edges, which can be zero on sparse or
# single-type systems. make_fx cannot trace an
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 72.15190% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.19%. Comparing base (967e525) to head (89a6397).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
deepmd/pt/model/model/sezm_model.py 72.15% 44 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5483      +/-   ##
==========================================
- Coverage   81.34%   80.19%   -1.16%     
==========================================
  Files         868      868              
  Lines       96373    96522     +149     
  Branches     4233     4235       +2     
==========================================
- Hits        78399    77410     -989     
- Misses      16675    17809    +1134     
- Partials     1299     1303       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants