Skip to content

Conversation

@jakobnissen
Copy link
Member

Vamb used to have the following pattern a lot of places:

my_tensor = _torch.zeros(n)
if self.usecuda:
    my_tensor.cuda()

This is wasteful, as the tensor is instantiated on CPU, then moved to GPU, instead of creating it directly on the GPU.
In this commit, where possible, we instantiate on the correct device from the beginning.

WARNING This is vibe coded, and part of me learning how to use an AI agent. I've reviewed the changes, but the agents should not be trusted. Hence, this must be tested before merging.

Vamb used to have the following pattern a lot of places:
```python
my_tensor = _torch.zeros(n)
if self.usecuda:
    my_tensor.cuda()
```
This is wasteful, as the tensor is instantiated on CPU, then moved to GPU,
instead of creating it directly on the GPU.
In this commit, where possible, we instantiate on the correct device from
the beginning.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants