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.
This issue is part of a Codex global repository scan.
Problem:
EigLoss.forwardasserts thateig_pred_cutandeig_label_cutare 2D tensors, but thediff_onbranch 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=Trueraises 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.