deepmodeling / deepmodeling/DeePTB
[Code scan] Initialize EigLoss windowed loss when no bands fall inside the energy window
- Dominant language
- Python
- Stars
- 122
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
This issue is part of a Codex global repository scan.
Problem:
In `EigLoss.forward`, `loss` is assigned only if `mask_in` contains at least one selected value. If the configured energy window excludes all selected bands but `mask_out` contains entries, the code evaluates `loss + ...` before `loss` exists.
Code reference:
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/nnops/loss.py#L215-L219
Impact:
Valid narrow-window configurations can fail with `UnboundLocalError` during training or evaluation.
Suggested fix:
Initialize `loss` before the mask branches, or compute in-window and out-of-window terms independently before summing the terms that are present.
Contributor guide
Research direction
Start at dptb/nnops/loss.py around EigLoss.forward lines 215–219 and trace the mask_in and mask_out branches. Exercise a narrow energy window with no bands in mask_in but entries in mask_out; done means valid training or evaluation no longer raises UnboundLocalError and the applicable loss terms are summed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100