Skip to content

Comments

Create ptr tensor on same device as Z when batching atomic graphs#166

Open
thomasloux wants to merge 1 commit intovldgroup:mainfrom
thomasloux:fix/batch-atomicgraphs-device
Open

Create ptr tensor on same device as Z when batching atomic graphs#166
thomasloux wants to merge 1 commit intovldgroup:mainfrom
thomasloux:fix/batch-atomicgraphs-device

Conversation

@thomasloux
Copy link

Error:
ptr (pointer to first atom indices for each system in a batched AtomicGraph) is always initialized on cpu, even if the input sequence is on another device.

Reproduce:

from graph_pes.atomic_graph import AtomicGraph, to_batch
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
atoms = bulk("Si", "diamond", a=5.43, cubic=True)
atoms = AtomicGraph.from_ase(atoms).to(device)
print(atoms.Z.device) # cuda:0
batch = to_batch([atoms])
print(batch.Z.device, batch.ptr.device) #cuda:0 cpu

Solve by creating the ptr tensor on same device as Z.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant