deepmodeling / deepmodeling/DeePTB

[Code scan] Initialize EigLoss windowed loss when no bands fall inside the energy window

Open Beginner friendly
#356 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.