fix(dpmodel): move econf embeddings to active backend#5840
Conversation
Materialize portable NumPy electronic-configuration tables in the namespace, dtype, and device of the type-embedding weights before evaluation. This prevents NativeLayer from selecting NumPy and coercing backend-native parameters back to CPU. Add a direct mixed-state regression covering Torch output identity, numerical parity, and change_type_map regeneration without relying on eager-converting backend wrappers. Coding-Agent: Codex Codex-Version: codex-cli 0.144.4 Model: gpt-5.6-sol Reasoning-Effort: xhigh
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesElectronic-configuration backend alignment
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #5840 +/- ##
==========================================
- Coverage 78.58% 77.86% -0.72%
==========================================
Files 1050 1050
Lines 120637 120639 +2
Branches 4356 4354 -2
==========================================
- Hits 94801 93936 -865
- Misses 24278 25144 +866
- Partials 1558 1559 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Possible reviewers based on changed lines, exact file history, and exact-file review history:
No review request was made automatically. Coding agent: Codex |
Fixes #5641
Summary
NativeLayerfrom selecting NumPy and coercing Torch/JAX/array-API weights back to CPUchange_type_map()through the same call-time boundaryWhy existing tests missed this
The cross-backend consistency tests already include electronic-configuration embeddings, but their JAX, array-api-strict, TF2, and exportable-PyTorch wrappers eagerly convert NumPy attributes when constructing the backend object. That converts both the weights and
econf_tebd, so the generic dpmodel mixed-state boundary is never exercised.The direct dpmodel path uses NumPy parameters and a NumPy electronic-configuration table, where
NativeLayerselecting its namespace from the input is correct. Existing tests therefore compared homogeneous NumPy state or homogeneous wrapper-converted state, but never backend-native weights alongside the intentionally portable NumPy constant. CPU-only numerical comparisons also did not assert the returned array backend, dtype, or device.Validation
source/tests/consistent/test_type_embedding.py: 64 passed, 49 backend-dependent skipschange_type_map()regenerates the NumPy electronic-configuration tableruff format .ruff check .Coding agent: Codex
Codex version: codex-cli 0.144.4
Model: gpt-5.6-sol
Reasoning effort: xhigh
Summary by CodeRabbit
Bug Fixes
Tests