Repository navigation
fix(dpmodel): handle zero-node DPA4C spin graphs - #6007
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
njzjz-bot
left a comment
There was a problem hiding this comment.
The fix replaces the ambiguous empty-tensor reshape with the already-known feature width, so it preserves the nonempty layout while making the zero-node case well-defined. The new NumPy/PyTorch tests cover zero-node and isolated-node graphs across precisions/channel widths and include the spin-gradient path. I did not find a blocking issue. Upstream currently shows only the successful triage check; the PR also reports focused source-build validation.
Agent: ChatGPT
Model: GPT-5.6 Sol
OutisLi
left a comment
There was a problem hiding this comment.
The explicit cross-Gram feature width matches the actual tensor layout and get_dim_out(), fixes zero-node graphs without a special-case branch, and preserves nonempty-input semantics and serialization. Verified the regression by restoring the original reshape in memory: all 8 zero-node cases failed while all 8 isolated-node controls passed; all 16 cases passed with this fix, including spin-gradient checks. Related dpmodel/pt_expt descriptor and graph-lower suites: 142 passed, 16 skipped. Ruff and diff checks passed. Local validation was CPU-only; GPU execution was not verified. No blocking issues found.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6007 +/- ##
==========================================
- Coverage 77.85% 77.60% -0.25%
==========================================
Files 1170 1170
Lines 140914 140914
Branches 5056 5063 +7
==========================================
- Hits 109705 109354 -351
- Misses 29325 29678 +353
+ Partials 1884 1882 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Fixes #5991.
The native-spin cross Gram has shape
(N, quadrupole_width, C_2). Reshaping it to(N, -1)raises forN == 0, since the feature width cannot be inferred from an empty array. Use the existingquadrupole_width * degree_channels[2]instead. This preserves the feature layout for nonempty inputs and requires no empty-graph special case.Add regression tests through the actual
DescrptDPA4C.call_graph()API in both NumPy and PyTorch. They cover float32/float64, channels 8/32, zero nodes and two isolated nodes, with the spin gate open. Check output shape/dtype, and PyTorch device and spin gradients.Validation
Built from upstream
58a12b1e0a72cfcc322c64d70c21469220bef74fon Linux x86-64 / Python 3.12.3, with PyTorch 2.11.0+cpu and TensorFlow CPU 2.21.0. Compiled the native C++ libraries and TensorFlow/PyTorch operators from this source.Before the production change, the new tests produced 8 failed, 8 passed: all eight zero-node cases failed at the reported reshape, while the isolated-node controls passed. After the change, 16 passed.
Result: 173 passed, 17 skipped. This includes all 31 CPU-operator tests, existing nonempty-input parity/gradient contracts, graph lowering, and a TensorFlow inference smoke test. The skipped cases are one JAX test (JAX is not installed) and 16 CUDA-only tests; GPU execution is not claimed. The run emitted operator-registration and TorchScript deprecation warnings.
ruff check .,ruff format --check ., andgit diff --checkpassed.AI assistance
This implementation and its local verification were prepared with assistance from OpenAI Codex.
Summary by CodeRabbit
Bug Fixes
Tests