Skip to content

fix(tf): handle multiframe DeepSpin extension#5851

Open
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/tf-deepspin-multiframe-extension-5660
Open

fix(tf): handle multiframe DeepSpin extension#5851
njzjz-bot wants to merge 1 commit into
deepmodeling:masterfrom
njzjz-bot:fix/tf-deepspin-multiframe-extension-5660

Conversation

@njzjz-bot

Copy link
Copy Markdown
Contributor

Closes #5660.

Summary

  • build TensorFlow DeepSpin physical and virtual coordinate buffers for every input frame in both direct and external-neighbor-list paths
  • separate extended coordinate frame strides from original-atom aparam strides during NULL-atom selection
  • copy physical force, magnetic force, atomic energy, and atomic virial outputs with explicit source/destination frame offsets
  • derive the atomic-energy source width from the TensorFlow tensor, since spin models emit energies only for physical atoms while C++ preserves extended virtual slots
  • add distinct two-frame direct and InputNlist atomic regressions for both double and float

Why existing tests missed this

All TensorFlow DeepSpin C++ tests used scalar-energy, single-frame calls. The extension helpers therefore only needed frame-zero buffers, and frame-zero copyback filled every asserted output. No test exercised the documented vector-energy overload with nframes > 1, so undersized extension buffers, incorrect inferred frame counts, and missing output frame offsets remained invisible.

The new tests perturb both coordinates and spins in frame 2, evaluate each frame separately, and compare every batched slice against its one-frame reference. They also assert the frame references differ, preventing duplicated-frame behavior from passing.

Validation

  • ruff format .
  • ruff check .
  • clang-format --dry-run --Werror on all changed C++ files
  • built deepmd_op, deepmd_backend_tf, and runUnitTests_cc
  • all 16 TestInferDeepSpin and TestInferDeepSpinNopbc typed tests passed
  • focused four-case two-frame matrix passed: direct/InputNlist × double/float

Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh

Build TensorFlow DeepSpin virtual-atom coordinates for every frame and use
explicit frame strides when copying physical, magnetic, and atomic outputs
back from extended buffers.

Derive atomic-energy frame width from the TensorFlow output so physical-only
energies do not interleave frames in the extended atom layout.

Coding-Agent: Codex
Codex-Version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning-Effort: xhigh
@dosubot dosubot Bot added the bug label Jul 16, 2026
@github-actions github-actions Bot added the C++ label Jul 17, 2026
@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 2.12766% with 92 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.33%. Comparing base (6c3b985) to head (1250729).

Files with missing lines Patch % Lines
source/api_cc/tests/test_deeppot_tf_spin.cc 0.00% 92 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (6c3b985) and HEAD (1250729). Click for more details.

HEAD has 42 uploads less than BASE
Flag BASE (6c3b985) HEAD (1250729)
56 14
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5851      +/-   ##
==========================================
- Coverage   78.58%   70.33%   -8.25%     
==========================================
  Files        1050     1024      -26     
  Lines      120637   114250    -6387     
  Branches     4356     3535     -821     
==========================================
- Hits        94801    80357   -14444     
- Misses      24278    33088    +8810     
+ Partials     1558      805     -753     

☔ View full report in Codecov by Harness.
📢 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.

@njzjz

njzjz commented Jul 18, 2026

Copy link
Copy Markdown
Member

Possible reviewers based on changed lines, exact file history, and exact-file review history:

  • @wanghan-iapcm — 4 commits on changed files; 20 reviews on exact changed files (source/api_cc/src/DeepSpinTF.cc, source/api_cc/src/common.cc).
  • @OutisLi — 12 reviews on exact changed files (source/api_cc/src/common.cc).

No review request was made automatically.

Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh

@njzjz
njzjz requested review from OutisLi and wanghan-iapcm July 18, 2026 07:26
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.

[Code scan] Handle multi-frame TensorFlow DeepSpin extension buffers

2 participants