Repository: pytorch
Issue: Cloning a sparse tensor in inductor causes "RuntimeError: Cannot access data pointer of Tensor that doesn't have storage"
Labels: module: sparse,triaged,oncall: pt2,module: inductor

### 🐛 Describe the bug

This fails in inductor but works in eager and aot_eager.  I believe inductor is just calling the "normal" clone but needs to handle the sparse tensor clone specially.

```
import torch

def output(f):
    print(repr(f))

def test_matching_coalesced(t1):
    t2 = t1.clone()
    output(t2)

t1 = torch.sparse_coo_tensor(((0, 1), (1, 0)), (1, 2), size=(2, 2))

# Works:
test_matching_coalesced(t1)
f = torch.compile(test_matching_coalesced, backend="inductor")

# Fails with RuntimeError: Cannot access data pointer of Tensor that doesn't have storage
f(t1)
```

There are a couple existing issues which have the same error message but I wasn't sure if it was the same problem and this is a much simpler repro:
- https://github.com/pytorch/pytorch/issues/96041
- https://github.com/pytorch/pytorch/issues/91810

### Versions

```
Collecting environment information...
PyTorch version: 2.3.0a0+gitff1beb9
Is debug build: True
CUDA used to build PyTorch: 12.0
ROCM used to build PyTorch: N/A

OS: CentOS Stream 9 (x86_64)
GCC version: (GCC) 11.4.1 20231218 (Red Hat 11.4.1-3)
Clang version: Could not collect
CMake version: version 3.28.1
Libc version: glibc-2.34

Python version: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0] (64-bit runtime)
Python platform: Linux-5.19.0-0_fbk12_zion_rc2_11583_g0bef9520ca2b-x86_64-with-glibc2.34
Is CUDA available: True
CUDA runtime version: 12.0.140
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration:
GPU 0: NVIDIA H100
GPU 1: NVIDIA H100
GPU 2: NVIDIA H100
GPU 3: NVIDIA H100
GPU 4: NVIDIA H100
GPU 5: NVIDIA H100
GPU 6: NVIDIA H100
GPU 7: NVIDIA H100

Nvidia driver version: 525.105.17
cuDNN version: Probably one of the following:
/usr/lib64/libcudnn.so.8.8.0
/usr/lib64/libcudnn_adv_infer.so.8.8.0
/usr/lib64/libcudnn_adv_train.so.8.8.0
/usr/lib64/libcudnn_cnn_infer.so.8.8.0
/usr/lib64/libcudnn_cnn_train.so.8.8.0
/usr/lib64/libcudnn_ops_infer.so.8.8.0
/usr/lib64/libcudnn_ops_train.so.8.8.0
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False
CPU:
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Address sizes:                   52 bits physical, 57 bits virtual
Byte Order:                      Little Endian
CPU(s):                          384
On-line CPU(s) list:             0-383
Vendor ID:                       AuthenticAMD
Model name:                      AMD EPYC 9654 96-Core Processor
CPU family:                      25
Model:                           17
Thread(s) per core:              2
Core(s) per socket:              96
Socket(s):                       2
Stepping:                        1
Frequency boost:                 enabled
CPU max MHz:                     2400.0000
CPU min MHz:                     1500.0000
BogoMIPS:                        4792.72
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht$
Virtualization:                  AMD-V
L1d cache:                       6 MiB (192 instances)
L1i cache:                       6 MiB (192 instances)
L2 cache:                        192 MiB (192 instances)
L3 cache:                        768 MiB (24 instances)
NUMA node(s):                    2
NUMA node0 CPU(s):               0-95,192-287
NUMA node1 CPU(s):               96-191,288-383
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          Not affected
Vulnerability Mmio stale data:   Not affected
Vulnerability Retbleed:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Vulnerable, IBPB: conditional, IBRS_FW, STIBP: always-on, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected
Versions of relevant libraries:
[pip3] bert-pytorch==0.0.1a4
[pip3] clip-anytorch==2.5.2
[pip3] CoCa-pytorch==0.1.0
[pip3] dalle2-pytorch==1.14.2
[pip3] ema-pytorch==0.3.1
[pip3] flake8==6.1.0
[pip3] flake8-bugbear==23.3.23
[pip3] flake8-coding==1.3.3
[pip3] flake8-comprehensions==3.12.0
[pip3] flake8-executable==2.1.3
[pip3] flake8-logging-format==0.9.0
[pip3] flake8-pyi==23.3.1
[pip3] flake8-simplify==0.19.3
[pip3] functorch==1.14.0a0+b71aa0b
[pip3] mypy==1.7.0
[pip3] mypy-extensions==1.0.0
[pip3] mypy-extensions==1.0.0
[pip3] numpy==1.26.0
[pip3] onnx==1.15.0
[pip3] open-clip-torch==2.23.0
[pip3] optree==0.10.0
[pip3] pytorch-triton==2.2.0+e28a256d71
[pip3] pytorch-warmup==0.1.1
[pip3] rotary-embedding-torch==0.3.3
[pip3] torch==2.3.0a0+gitff1beb9
[pip3] torch-fidelity==0.3.0
[pip3] torch_geometric==2.4.0
[pip3] torchaudio==2.2.0a0+6518fa9
[pip3] torchdata==0.7.0a0+11bb5b8
[pip3] torchdata==0.7.0a0+11bb5b8
[pip3] torchmetrics==1.2.1
[pip3] torchmetrics==1.2.1
[pip3] torchmultimodal==0.1.0b0
[pip3] torchrec==0.3.2
[pip3] torchtext==0.16.0a0+b0ebddc
[pip3] torchvision==0.18.0a0+f52fd33
[pip3] vector-quantize-pytorch==1.12.5
[conda] bert-pytorch              0.0.1a4                   dev_0    <develop>
[conda] blas                      1.0                         mkl
[conda] clip-anytorch             2.5.2                    pypi_0    pypi
[conda] coca-pytorch              0.1.0                    pypi_0    pypi
[conda] dalle2-pytorch            1.14.2                   pypi_0    pypi
[conda] diffusers-torch           0.18.2          py311h92b7b1e_0
[conda] ema-pytorch               0.3.1                    pypi_0    pypi
[conda] functorch                 1.14.0a0+b71aa0b          pypi_0    pypi
[conda] magma-cuda116             2.6.1                         1    pytorch
[conda] mkl                       2023.1.0         h213fc3f_46344
[conda] mkl-include               2023.1.0         h06a4308_46344
[conda] mkl-service               2.4.0           py311h5eee18b_1
[conda] mkl_fft                   1.3.8           py311h5eee18b_0
[conda] mkl_random                1.2.4           py311hdb19cb5_0
[conda] numpy                     1.26.0                   pypi_0    pypi
[conda] open-clip-torch           2.23.0                   pypi_0    pypi
[conda] optree                    0.10.0                   pypi_0    pypi
[conda] pytorch                   2.1.0           cpu_py311h6d93b4c_0
[conda] pytorch-triton            2.2.0+e28a256d71          pypi_0    pypi
[conda] pytorch-warmup            0.1.1                    pypi_0    pypi
[conda] rotary-embedding-torch    0.3.3                    pypi_0    pypi
[conda] torch                     2.3.0a0+gitff1beb9           dev_0    <develop>
[conda] torch-fidelity            0.3.0                    pypi_0    pypi
[conda] torch-geometric           2.4.0                    pypi_0    pypi
[conda] torchaudio                2.2.0a0+6518fa9           dev_0    <develop>
[conda] torchdata                 0.7.0a0+11bb5b8          pypi_0    pypi
[conda] torchfix                  0.2.0                    pypi_0    pypi
[conda] torchmetrics              1.2.1                    pypi_0    pypi
[conda] torchmultimodal           0.1.0b0                  pypi_0    pypi
[conda] torchrec                  0.3.2                     dev_0    <develop>
[conda] torchtext                 0.16.0a0+b0ebddc           dev_0    <develop>
[conda] torchvision               0.18.0a0+f52fd33           dev_0    <develop>
[conda] vector-quantize-pytorch   1.12.5                   pypi_0    pypi

cc @alexsamardzic @nikitaved @pearu @cpuhrsch @amjames @bhosmer @jcaip @ezyang @msaroufim @bdhirsh @anijain2305 @zou3519 @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @peterbell10 @ipiszy @yf225 @chenyang78 @kadeng @muchulee8 @aakhundov @ColinPeppler