Closed tvercaut closed 1 year ago
I had a similar issue and was caused by having Pytorch 1.12.1 (the stable version) and the nightly version of maskedtensor. For me the solution was to uninstall maskedtensor-nightly and use !pip install maskedtensor. See this closed issue for more details: https://github.com/pytorch/maskedtensor/issues/50
cc @george-qi
As per https://github.com/pytorch/maskedtensor/issues/71#issuecomment-1286134243, I tried with the upstream pytorch and confirms it works there subject to modifying maskedtensor
by torch.masked
:
# Try with the nightly version of PyTorch
!pip3 install --pre torch torchvision torchaudio torchtext --extra-index-url https://download.pytorch.org/whl/nightly/cu117 --upgrade
import torch
print(f'Running PyTorch version: {torch.__version__}')
crow_indices = torch.tensor([0, 2, 4])
col_indices = torch.tensor([0, 1, 0, 1])
values = torch.tensor([1, 2, 3, 4])
mask_values = torch.tensor([True, False, False, True])
csr = torch.sparse_csr_tensor(crow_indices, col_indices, values, dtype=torch.double)
mask = torch.sparse_csr_tensor(crow_indices, col_indices, mask_values, dtype=torch.bool)
mt = torch.masked.masked_tensor(csr, mask)
🐛 Describe the bug
The tutorial code from https://pytorch.org/maskedtensor/main/notebooks/sparse.html#sparse-csr is failling on google colab.
leads to