Skip to content

Conversation

@faaany
Copy link
Contributor

@faaany faaany commented Jan 24, 2025

The following code will not move tensor to the desired target_device:

import torch
import bitsandbytes as bnb

random_tensor = torch.randn((3, 3), dtype=torch.float16)
target_device = 2
new_value = bnb.nn.Int8Params(random_tensor, requires_grad=False).to(target_device)
print(new_value)
# Parameter containing:
# Parameter(Int8Params([[ 127,  -97, -126],
#             [  60,   11,  127],
#             [-127,   90,  -35]], device='xpu:0', dtype=torch.int8))

To fix this, we need to pass the device index to the xpu method just like in the cuda method.

@yao-matrix
Copy link

@jiqing-feng

@github-actions
Copy link

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@matthewdouglas matthewdouglas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@matthewdouglas matthewdouglas merged commit a0a95fd into bitsandbytes-foundation:multi-backend-refactor Jan 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants