Skip to content

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

Description

@njzjz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions