Skip to content

test(universal): replace Cartesian product with curated matrices for descriptor test#5459

Open
iProzd wants to merge 4 commits into
deepmodeling:masterfrom
iProzd:0526_slim_ut
Open

test(universal): replace Cartesian product with curated matrices for descriptor test#5459
iProzd wants to merge 4 commits into
deepmodeling:masterfrom
iProzd:0526_slim_ut

Conversation

@iProzd
Copy link
Copy Markdown
Member

@iProzd iProzd commented May 26, 2026

Summary by CodeRabbit

  • Tests
    • Centralized descriptor parameter combinations into shared, reusable constants used across atomic and model test suites to reduce repetition.
    • Added curated energy-model-specific parameter variants and a small helper to produce fixed-argument variants for integration tests.
    • Removed an outdated descriptor helper and updated parameterized tests to consume the new centralized parameter collections.

Review Change Stack

Copilot AI review requested due to automatic review settings May 26, 2026 14:37
@iProzd iProzd marked this pull request as draft May 26, 2026 14:37
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 reduces the combinatorial explosion in universal model/atomic-model descriptor integration tests by replacing broad Cartesian-product parameter grids with curated descriptor variant matrices aimed at representative/high-risk coverage.

Changes:

  • Introduces curated “EnergyModel” descriptor variant lists (plus a small helper to generate variants) in the universal dpmodel descriptor test module.
  • Refactors universal PT/DP model and atomic-model tests to consume these curated descriptor matrices and shared default descriptor sets instead of importing the full parameter grids.
  • Adds per-test-module constants grouping descriptor/fitting parameterizations (e.g., default vs. hybrid-inclusive sets) to simplify parameterized test definitions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
source/tests/universal/pt/model/test_model.py Switches model tests to curated descriptor matrices and introduces shared descriptor parameter group constants.
source/tests/universal/pt/atomc_model/test_atomic_model.py Switches atomic-model tests to curated descriptor matrices and shared descriptor parameter group constants.
source/tests/universal/dpmodel/model/test_model.py Switches dpmodel model tests to curated descriptor matrices and adds shared descriptor parameter group constants.
source/tests/universal/dpmodel/descriptor/test_descriptor.py Adds helper + curated descriptor variant lists for model/atomic-model integration tests.
source/tests/universal/dpmodel/atomc_model/test_atomic_model.py Switches dpmodel atomic-model tests to curated descriptor matrices and shared descriptor parameter group constants.

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

Comment thread source/tests/universal/dpmodel/descriptor/test_descriptor.py Outdated
Comment thread source/tests/universal/pt/model/test_model.py
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d817bdb5-869e-400c-aa18-b9dcdebf910f

📥 Commits

Reviewing files that changed from the base of the PR and between 4dfcccd and 1d94aa8.

📒 Files selected for processing (2)
  • source/tests/universal/dpmodel/descriptor/test_descriptor.py
  • source/tests/universal/pt/model/test_model.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • source/tests/universal/dpmodel/descriptor/test_descriptor.py
  • source/tests/universal/pt/model/test_model.py

📝 Walkthrough

Walkthrough

This PR consolidates descriptor parameterization logic across test modules by introducing energy-model-specific descriptor parameter lists and shared module-level constants. Tests import curated parameter variants and use precomputed descriptor-parameter tuples instead of inline expansions, reducing repetition across DP and PT test classes.

Changes

Test parameterization refactoring for descriptor model tests

Layer / File(s) Summary
Descriptor parameter lists foundation
source/tests/universal/dpmodel/descriptor/test_descriptor.py
Adds _descriptor_param_variant helper function and defines seven energy-model-specific descriptor parameter lists with baseline and toggled configurations (e.g., resnet_dt, exclude_types, env_protection, tebd switches).
DP model atomic tests with centralized descriptor constants
source/tests/universal/dpmodel/atomc_model/test_atomic_model.py
Updates descriptor imports to energy-model variants and introduces seven shared descriptor-parameter constants defining descriptor-class pairings for energy, default, vector, and DPA12 cases with and without hybrid support. Refactors six test classes' @parameterized decorators to use these constants.
DP model tests with descriptor and spin constants
source/tests/universal/dpmodel/model/test_model.py
Updates imports to energy-model descriptor lists and introduces descriptor-parameter constants for energy and spin tests. Refactors @parameterized decorators to use ENERGY_DESCRIPTOR_PARAMS, DEFAULT_DESCRIPTOR_PARAMS, and SPIN_DESCRIPTOR_PARAMS instead of inline tuple construction.
PT model atomic tests with centralized descriptor constants
source/tests/universal/pt/atomc_model/test_atomic_model.py
Updates imports to energy-model descriptor lists and introduces seven descriptor-parameter constants matching the DP atomic test pattern. Refactors six test classes' @parameterized decorators to reference these constants.
PT model tests with comprehensive descriptor constants
source/tests/universal/pt/model/test_model.py
Updates imports to energy-model variants and introduces multiple descriptor-parameter constants including energy, default, vector, DPA12, and spin options with hybrid variants. Refactors eight test classes' @parameterized decorators to use these consolidated constants.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

enhancement

Suggested reviewers

  • njzjz
  • wanghan-iapcm
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main refactoring: replacing Cartesian product combinations with curated descriptor test matrices.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
source/tests/universal/pt/model/test_model.py (1)

631-636: ⚡ Quick win

Avoid positional slicing for spin fit descriptor selection.

DEFAULT_SPIN_DESCRIPTOR_PARAMS[:6] is order-coupled and can silently change test coverage if the tuple is reordered. Define an explicit spin-fit constant and reference it directly.

Suggested refactor
 DEFAULT_SPIN_DESCRIPTOR_PARAMS = (
     (DescriptorParamSeA, DescrptSeA),
     (DescriptorParamSeR, DescrptSeR),
     (DescriptorParamSeT, DescrptSeT),
     (DescriptorParamSeTTebd, DescrptSeTTebd),
     (DescriptorParamDPA1, DescrptDPA1),
     (DescriptorParamDPA2, DescrptDPA2),
     # unsupported for SpinModel to hybrid both mixed_types and no-mixed_types descriptor
     (DescriptorParamHybridMixed, DescrptHybrid),
     (DescriptorParamHybridMixedTTebd, DescrptHybrid),
 )
+
+DEFAULT_SPIN_FIT_DESCRIPTOR_PARAMS = (
+    (DescriptorParamSeA, DescrptSeA),
+    (DescriptorParamSeR, DescrptSeR),
+    (DescriptorParamSeT, DescrptSeT),
+    (DescriptorParamSeTTebd, DescrptSeTTebd),
+    (DescriptorParamDPA1, DescrptDPA1),
+    (DescriptorParamDPA2, DescrptDPA2),
+)
@@
     fit_parameterized=(
-        DEFAULT_SPIN_DESCRIPTOR_PARAMS[:6],  # descrpt_class_param & class
+        DEFAULT_SPIN_FIT_DESCRIPTOR_PARAMS,  # descrpt_class_param & class
         (
             *[(param_func, EnergyFittingNet) for param_func in FittingParamEnergyList],
         ),  # fitting_class_param & class
     ),
 )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@source/tests/universal/pt/model/test_model.py` around lines 631 - 636,
Replace the positional slice DEFAULT_SPIN_DESCRIPTOR_PARAMS[:6] with an explicit
constant to avoid order coupling: introduce a named tuple/constant like
SPIN_FIT_DESCRIPTOR_PARAMS (or DEFAULT_SPIN_DESCRIPTOR_PARAMS_SPIN_FIT) defined
next to DEFAULT_SPIN_DESCRIPTOR_PARAMS and use that constant in the
fit_parameterized case instead of slicing; update any references in the test
(e.g., fit_parameterized) to use the new constant so test coverage remains
stable even if DEFAULT_SPIN_DESCRIPTOR_PARAMS is reordered.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@source/tests/universal/pt/model/test_model.py`:
- Around line 631-636: Replace the positional slice
DEFAULT_SPIN_DESCRIPTOR_PARAMS[:6] with an explicit constant to avoid order
coupling: introduce a named tuple/constant like SPIN_FIT_DESCRIPTOR_PARAMS (or
DEFAULT_SPIN_DESCRIPTOR_PARAMS_SPIN_FIT) defined next to
DEFAULT_SPIN_DESCRIPTOR_PARAMS and use that constant in the fit_parameterized
case instead of slicing; update any references in the test (e.g.,
fit_parameterized) to use the new constant so test coverage remains stable even
if DEFAULT_SPIN_DESCRIPTOR_PARAMS is reordered.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4b441538-8372-4b9d-b23b-981980feb384

📥 Commits

Reviewing files that changed from the base of the PR and between f39a081 and 4dfcccd.

📒 Files selected for processing (5)
  • source/tests/universal/dpmodel/atomc_model/test_atomic_model.py
  • source/tests/universal/dpmodel/descriptor/test_descriptor.py
  • source/tests/universal/dpmodel/model/test_model.py
  • source/tests/universal/pt/atomc_model/test_atomic_model.py
  • source/tests/universal/pt/model/test_model.py

@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.46%. Comparing base (4e64f8b) to head (1d94aa8).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5459   +/-   ##
=======================================
  Coverage   82.46%   82.46%           
=======================================
  Files         829      829           
  Lines       88763    88762    -1     
  Branches     4225     4227    +2     
=======================================
  Hits        73197    73197           
+ Misses      14274    14273    -1     
  Partials     1292     1292           

☔ 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.

@iProzd iProzd marked this pull request as ready for review May 27, 2026 14:24
@iProzd iProzd requested review from njzjz and wanghan-iapcm May 27, 2026 14:24
Copy link
Copy Markdown
Contributor

@njzjz-bot njzjz-bot left a comment

Choose a reason for hiding this comment

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

I reviewed this PR. It only trims and deduplicates the test parameter matrices, and the overall direction looks sound. I did not find any issue that should block merging.

Checked:

  • Diff across the 5 changed files (+541/-377)
  • The kwargs override order for descriptor curated variants: fixed kwargs now override the kwargs passed by the test framework, which matches the intended semantics for fixed variants
  • The DPA3 chg / spin special cases have been folded into the curated lists, with no remaining stale references
  • The ordering-coupled DEFAULT_SPIN_DESCRIPTOR_PARAMS[:6] usage was replaced with an explicit constant as suggested by CodeRabbit
  • CI, Codecov, pre-commit, and docs are green; I also ran python3 -m py_compile locally on the changed Python files successfully

Conclusion: approved / ready to merge.

— OpenClaw 2026.5.12 (model: custom-chat-jinzhezeng-group/gpt-5.5)

DescriptorParamDPA1, "DescriptorParamDPA1_strip", tebd_input_mode="strip"
),
_descriptor_param_variant(
DescriptorParamDPA1, "DescriptorParamDPA1_no_attention", attn_layer=0
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Coverage gap: _no_attention duplicates the rebound baseline. At line 322 above, DescriptorParamDPA1 is rebound to DescriptorParamDPA1List[0], which has attn_layer=0 (the first value in the OrderedDict tuple (0, 2)). This variant then explicitly sets attn_layer=0 again, and no other variant in DescriptorParamDPA1EnergyModelList overrides it.

Net effect: after this PR, the DPA1 attention code path (attn_layer=2, NeighborGatedAttention) is no longer exercised at the model / atomic-model integration level — only at the descriptor level. Descriptor-internal regressions are still caught by the preserved Cartesian DescriptorParamDPA1List, but model-level glue bugs that surface only with attention enabled would slip through.

Non-blocking; trivial fix: change this variant to attn_layer=2 (and rename to _with_attention) so the curated list covers both branches at the model level.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants