deepmodeling / deepmodeling/DeePTB

[Code scan] Fix diff_on eigenvalue loss indexing for 2D band tensors

Open Beginner friendly
#357 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:
`EigLoss.forward` asserts that `eig_pred_cut` and `eig_label_cut` are 2D tensors, but the `diff_on` branch indexes them as if they were 3D (`[:, k_diff_i, :]`).

Code references:
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/nnops/loss.py#L188-L193
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/nnops/loss.py#L223-L237

Impact:
Any run with `diff_on=True` raises an indexing error instead of computing the differential eigenvalue loss.

Suggested fix:
Index the k-point dimension consistently for 2D tensors, for example `eig_label_cut[k_diff_i, :] - eig_label_cut[k_diff_j, :]`, with the same correction for predictions and masked variants.

Contributor guide

Open the contributing guide

Research direction

Start in dptb/nnops/loss.py at the referenced EigLoss.forward sections around lines 188-193 and 223-237. Trace the diff_on path and its masked variants for the asserted 2D tensors. Done means diff_on=True no longer raises an indexing error and computes the differential eigenvalue loss consistently for predictions and labels.

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.