deepmodeling / deepmodeling/DeePTB

[Code scan] Wannier90 export fails when model/device is CUDA

Open
#361 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:
`load_data_for_model()` moves data to `self.device`, but `ToWannier90._get_data_and_blocks()` calls `.numpy()` directly on tensors for positions, scaled positions, and cell.

Code reference:
https://github.com/deepmodeling/deeptb/blob/86c60c73996f0dd961c3138f2e88424382cb734e/dptb/postprocess/interfaces.py#L44-L49

Impact:
Exporting with a CUDA device raises `TypeError: can't convert cuda tensor to numpy` instead of writing Wannier90 files.

Suggested fix:
Convert tensors with `.detach().cpu().numpy()` before passing data to NumPy or file-writing code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.