Skip to content

test: add .pte and .pt2 tests for dp convert-backend#5384

Open
wanghan-iapcm wants to merge 1 commit intodeepmodeling:masterfrom
wanghan-iapcm:fix-convert-backend-pte-tests
Open

test: add .pte and .pt2 tests for dp convert-backend#5384
wanghan-iapcm wants to merge 1 commit intodeepmodeling:masterfrom
wanghan-iapcm:fix-convert-backend-pte-tests

Conversation

@wanghan-iapcm
Copy link
Copy Markdown
Collaborator

@wanghan-iapcm wanghan-iapcm commented Apr 7, 2026

Summary

  • Add .pte and .pt2 to parameterized extensions in test_models.py to verify convert-backend works for the pt_expt exportable formats
  • Switch fparam_aparam model (1 atom type) from type_one_side=False to True (with ndim 2→1), which is equivalent for single-type models but enables pt_expt export
  • Skip se_e2_a/se_e2_r for .pte/.pt2type_one_side=False with multiple types triggers GuardOnDataDependentSymNode in make_fx (data-dependent indexing in NetworkCollection(ndim=2))
  • Skip test_descriptor and test_fitting_last_layer for .pte/.pt2 (not implemented in pt_expt DeepEval)

Test plan

  • python -m pytest source/tests/infer/test_models.py -v — 55 passed, 67 skipped
  • python -m pytest source/tests/infer/test_models.py -v -k "pte or pt2" — 12 passed (fparam_aparam), rest skipped
  • Existing .pb/.pth tests unaffected

Summary by CodeRabbit

  • Tests
    • Updated test case configurations with modified model descriptor and embedding parameters
    • Extended test suite parameterization to support additional model file formats (.pte, .pt2)
    • Reorganized model compatibility skip conditions for improved test structure and maintainability

Add pt_expt backend (.pte/.pt2) to the parameterized extensions in
test_models.py to verify convert-backend works for the new exportable
formats.

The fparam_aparam model (1 atom type) is switched from type_one_side=False
to type_one_side=True (with ndim 2→1), which is equivalent for single-type
models but enables pt_expt export. Models with type_one_side=False and
multiple types (se_e2_a, se_e2_r) are skipped for .pte/.pt2 as make_fx
cannot trace data-dependent indexing in NetworkCollection(ndim=2).
@github-actions github-actions bot added the Python label Apr 7, 2026
@wanghan-iapcm wanghan-iapcm requested a review from njzjz April 7, 2026 13:49
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 7, 2026

📝 Walkthrough

Walkthrough

This change updates test configurations and test suite to support pt-expt model backends (.pte and .pt2 extensions). YAML test case files are modified to adjust embedding dimensionality and type-one-side handling flags. The test suite reorganizes skip logic to handle different model backends appropriately.

Changes

Cohort / File(s) Summary
YAML Test Configuration Updates
source/tests/infer/fparam_aparam-testcase.yaml, source/tests/infer/fparam_aparam.yaml, source/tests/infer/fparam_aparam_default.yaml
Modified model descriptor configurations: changed embedding.ndim from 2 to 1 and type_one_side flag from false/False to true/True across descriptor and fitting model sections for type: se_e2_a.
Test Suite Backend Support
source/tests/infer/test_models.py
Expanded parameterized model extensions to include .pte and .pt2 (pt-expt backends). Reorganized skip logic from per-test setUp() to setUpClass with global pt-expt conditions. Added explicit descriptor evaluation skip for pt-expt extensions and broadened test_fitting_last_layer skip coverage.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

new feature, Python

Suggested reviewers

  • njzjz
  • iProzd
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add .pte and .pt2 tests for dp convert-backend' directly aligns with the main changes: adding .pte and .pt2 test extensions to verify convert-backend support.

✏️ 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/infer/test_models.py (1)

42-45: Prefer deriving the pt_expt skip from fixture metadata.

The hard-coded ("se_e2_a", "se_e2_r") list will stay stale the next time a fixture is made exportable. The fixture already carries model_def_script.descriptor.type_one_side, so reading the skip condition from case would keep this gate aligned with the actual model data instead of the testcase key.

♻️ Suggested refactor
     `@classmethod`
     def setUpClass(cls) -> None:
         key, extension = cls.param
         if extension in (".pte", ".pt2") and not INSTALLED_PT_EXPT:
             raise unittest.SkipTest("pt_expt backend not installed")
-        if key in ("se_e2_a", "se_e2_r") and extension in (".pte", ".pt2"):
+        case = get_cases()[key]
+        descriptor = (case.model_def_script or {}).get("descriptor", {})
+        if (
+            extension in (".pte", ".pt2")
+            and descriptor.get("type") in {"se_e2_a", "se_e2_r"}
+            and not descriptor.get("type_one_side", False)
+        ):
             raise unittest.SkipTest(
                 "type_one_side=False is not supported for pt_expt export"
             )
         if key == "se_e2_r" and extension == ".pth":
             raise unittest.SkipTest(
                 "se_e2_r type_one_side is not supported for PyTorch models"
             )
-        cls.case = get_cases()[key]
+        cls.case = case
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@source/tests/infer/test_models.py` around lines 42 - 45, Replace the
hard-coded key check with a metadata-driven condition: instead of testing if key
in ("se_e2_a", "se_e2_r"), read the fixture's descriptor via the test case
(e.g., case.model_def_script.descriptor.type_one_side) and if that value is
False and extension is in (".pte", ".pt2") raise unittest.SkipTest; update the
conditional that currently uses variables key and extension to use
case.model_def_script.descriptor.type_one_side for the gate so the skip stays in
sync with fixture metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@source/tests/infer/test_models.py`:
- Around line 42-45: Replace the hard-coded key check with a metadata-driven
condition: instead of testing if key in ("se_e2_a", "se_e2_r"), read the
fixture's descriptor via the test case (e.g.,
case.model_def_script.descriptor.type_one_side) and if that value is False and
extension is in (".pte", ".pt2") raise unittest.SkipTest; update the conditional
that currently uses variables key and extension to use
case.model_def_script.descriptor.type_one_side for the gate so the skip stays in
sync with fixture metadata.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 75ef918e-5c9d-4fdd-a70c-1ed85d0f074f

📥 Commits

Reviewing files that changed from the base of the PR and between 52792f0 and 34d4cb5.

📒 Files selected for processing (4)
  • source/tests/infer/fparam_aparam-testcase.yaml
  • source/tests/infer/fparam_aparam.yaml
  • source/tests/infer/fparam_aparam_default.yaml
  • source/tests/infer/test_models.py

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.74%. Comparing base (efc27cf) to head (34d4cb5).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5384      +/-   ##
==========================================
- Coverage   82.38%   79.74%   -2.65%     
==========================================
  Files         812      812              
  Lines       83611    83476     -135     
  Branches     4091     4051      -40     
==========================================
- Hits        68882    66567    -2315     
- Misses      13508    15682    +2174     
- Partials     1221     1227       +6     

☔ 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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants