Skip to content

MPS: log and exp not working for integer Tensors #78019

@lhoenig

Description

@lhoenig

🐛 Describe the bug

Calling .log() and .exp() on Tensors with dtype int64 crashes outright, and applied to int32 Tensors always returns all-zero Tensors.

pt.tensor(5, dtype=pt.int64, device="mps").exp()  # crash
pt.tensor(5, dtype=pt.int64, device="mps").log()  # crash
pt.tensor(5, dtype=pt.int32, device="mps").exp()  # returns tensor(0., device='mps:0')
pt.tensor(5, dtype=pt.int32, device="mps").log()  # returns tensor(0., device='mps:0')

Crashes are of the form

2022-05-20 23:43:05.779 Python[84906:1380850] Error getting visible function:
 (null) Function logarithm_i64 was not found in the library
/AppleInternal/Library/BuildRoots/b6051351-c030-11ec-96e9-3e7866fcf3a1/Library/Caches/com.apple.xbs/Sources/MetalPerformanceShaders/MPSCore/Utility/MPSKernelDAG.mm:755: failed assertion `Error getting visible function:
 (null) Function logarithm_i64 was not found in the library'
[1]    84906 abort      ipython

Versions

Collecting environment information...
PyTorch version: 1.12.0a0+git734a97a
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 12.4 (arm64)
GCC version: Could not collect
Clang version: 13.1.6 (clang-1316.0.21.2.5)
CMake version: version 3.23.1
Libc version: N/A

Python version: 3.9.12 (main, May  8 2022, 17:57:49)  [Clang 13.1.6 (clang-1316.0.21.2)] (64-bit runtime)
Python platform: macOS-12.4-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
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

Versions of relevant libraries:
[pip3] mypy==0.950
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.22.0
[pip3] torch==1.12.0a0+git734a97a
[pip3] torch-scatter==2.0.9
[pip3] torch-tb-profiler==0.4.0
[pip3] torchaudio==0.11.0
[pip3] torchvision==0.12.0
[conda] Could not collect

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: mpsRelated to Apple Metal Performance Shaders frameworktriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions