Repository: pytorch
Issue: `torch.linspace` doesn't agree with decomposition.
Labels: triaged,module: linear algebra,module: decompositions

### 🐛 Describe the bug

Code:

```python
import torch
import torch._refs


print('torch: ', torch.linspace(4.9, 3, 5, dtype=torch.int64))
print('decomp: ', torch._refs.linspace(4.9, 3, 5, dtype=torch.int64))

import numpy
print('numpy: ', numpy.linspace(4.9, 3, 5, dtype=numpy.int64))
```

Output:

```
(xla2) hanq-macbookpro:torch_xla hanq$ python decomp.py
torch:  tensor([4, 3, 3, 3, 3])
decomp:  tensor([4, 4, 3, 3, 3])
numpy:  [4 4 3 3 3]
```

Expected:
torch and it's own decomposition should produce the same output. Ideally, that should also match numpy's behavior.

### Versions

(xla2) hanq-macbookpro:torch_xla hanq$ python collect_env.py
Collecting environment information...
PyTorch version: 2.4.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 14.7 (arm64)
GCC version: Could not collect
Clang version: 16.0.4
CMake version: version 3.30.2
Libc version: N/A

Python version: 3.10.14 (main, Mar 21 2024, 11:21:31) [Clang 14.0.6 ] (64-bit runtime)
Python platform: macOS-14.7-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M1 Pro

Versions of relevant libraries:
[pip3] bert-pytorch==0.0.1a4
[pip3] functorch==1.14.0a0+b71aa0b
[pip3] mypy==1.10.1
[pip3] mypy-extensions==1.0.0
[pip3] numpy==2.0.1
[pip3] onnx==1.16.1
[pip3] optree==0.11.0
[pip3] pytorch-labs-segment-anything-fast==0.2
[pip3] pytorch-lightning==2.2.4
[pip3] torch==2.4.1
[pip3] torch_geometric==2.4.0
[pip3] torch_xla2==0.0.1
[pip3] torchao==0.1
[pip3] torchaudio==2.4.0
[pip3] torchmetrics==1.4.0
[pip3] torchmultimodal==0.1.0b0
[pip3] torchvision==0.19.0
[conda] bert-pytorch              0.0.1a4                   dev_0    <develop>
[conda] functorch                 1.14.0a0+b71aa0b          pypi_0    pypi
[conda] numpy                     2.0.1                    pypi_0    pypi
[conda] optree                    0.11.0                   pypi_0    pypi
[conda] pytorch-labs-segment-anything-fast 0.2                      pypi_0    pypi
[conda] pytorch-lightning         2.2.4                    pypi_0    pypi
[conda] torch                     2.4.1                    pypi_0    pypi
[conda] torch-geometric           2.4.0                    pypi_0    pypi
[conda] torch-xla2                0.0.1                    pypi_0    pypi
[conda] torchao                   0.1                      pypi_0    pypi
[conda] torchaudio                2.4.0                    pypi_0    pypi
[conda] torchbench                0.1                       dev_0    <develop>
[conda] torchmetrics              1.4.0                    pypi_0    pypi
[conda] torchmultimodal           0.1.0b0                  pypi_0    pypi
[conda] torchvision               0.19.0                   pypi_0    pypi

cc @jianyuh @nikitaved @pearu @mruberry @walterddr @xwang233 @Lezcano @SherlockNoMad