You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(tf): make dipole, polar, and dos models consistent with dpmodel (#4962)
- [x] Implement decoupled out_bias and out_std architecture in
TensorFlow backend
- [x] Add bias/std application in Model classes (EnerModel, TensorModel,
DOSModel)
- [x] Create shared _apply_out_bias_std method to eliminate code
duplication
- [x] Remove unnecessary hasattr checks since variables are always
initialized
- [x] Address review feedback: clean up fallback logic and simplify
model type checking
- [x] Remove bias_atom_e conversion fallback (decoupled architecture)
- [x] Remove unnecessary getattr usage
- [x] Consolidate duplicate dim_out calculation logic
- [x] Remove unnecessary hasattr checks for model_type
- [x] Simplify model type checking logic
- [x] Use _get_dim_out() method consistently in bias/std application and
serialization
- [x] Fix polar model output dimension (9 instead of 3) in
_get_dim_out()
- [x] Merge duplicate nout calculation logic in _apply_out_bias_std
method
- [x] Remove unnecessary try-except fallback in serialize method
- [x] Fix reshape errors in _apply_out_bias_std method causing CI
failures
- [x] Add missing get_out_bias/set_out_bias methods required by tests
- [x] Add safety checks to prevent reshape errors for incompatible model
types
- [x] Initialize out_bias/out_std in PairwiseDPRc model to fix test
failures
- [x] Add robust error handling for invalid atom types and dimension
mismatches
- [x] Fix all major CI test failures (pairwise_dprc, model_spin,
out_bias_std tests)
- [x] Remove get/set methods for out_bias and out_std and update tests
- [x] Fix missing _apply_out_bias_std call in TensorModel causing CI
failures
- [x] Remove r_differentiable and c_differentiable parameters from polar
fitting serialize method
- [x] Remove system directory test files and add to .gitignore
- [x] Add debug logging for out_bias/out_std fallback behavior
- [x] Update logging pattern to follow codebase standard and remove
unnecessary pass statements
- [x] Remove unused _get_selected_atype method to clean up TensorModel
code
## Implementation Details:
✅ **Complete Model Coverage**: All model types (Energy, Tensor, DOS) now
properly apply out_bias/out_std using the shared method
✅ **Defensive Programming**: Added safety checks to gracefully handle
cases where tensor dimensions don't match expectations
✅ **Invalid Atom Type Handling**: Properly mask out -1 atom types to
prevent tf.gather index errors
✅ **Test Compatibility**: Removed unnecessary getter/setter methods and
updated tests to use direct property access
✅ **Robust Architecture**: Method works across different model types
(energy, DOS, spin, pairwise, dipole, polar) without breaking existing
functionality
✅ **Consistent Serialization**: Removed r_differentiable and
c_differentiable from polar fitting to match dpmodel reference
implementation
✅ **Clean Repository**: Removed accidentally committed test system files
and added system/ to .gitignore
✅ **Debug Logging**: Added debug-level logging using proper logger
pattern (`log = logging.getLogger(__name__)`) to indicate when
out_bias/out_std variables fall back to default values
✅ **Code Style**: Updated logging calls to follow codebase conventions
and removed unnecessary pass statements
✅ **Code Cleanup**: Removed unused _get_selected_atype method that was
previously part of bias/std application but is no longer needed
## Status: Ready for Review
The implementation now provides a clean, robust, and backward-compatible
solution for applying output bias and standard deviation consistently
across all TensorFlow model types. The public API has been simplified by
removing unnecessary getter/setter methods. All model types now
correctly apply bias/std transformations. The polar fitting
serialization is now consistent with the dpmodel reference
implementation. Test system files have been properly removed from the
repository. Debug logging follows the codebase's standard pattern using
proper logger instantiation and formatting. Unused methods have been
removed to maintain clean, maintainable code.
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Signed-off-by: Jinzhe Zeng <[email protected]>
Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: njzjz <[email protected]>
Co-authored-by: Jinzhe Zeng <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Co-authored-by: anyangml <[email protected]>
0 commit comments