torchvulkan 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.github/workflows/release.yaml +13 -10
  2. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.github/workflows/test_torchvulkan.yml +6 -7
  3. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/CMakeLists.txt +3 -0
  4. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/PKG-INFO +5 -4
  5. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/README.md +2 -2
  6. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/pyproject.toml +4 -4
  7. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/backend.cpp +1 -1
  8. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/decompositions.cpp +6 -1
  9. torchvulkan-0.2.2/src/api/fallback.cpp +13 -0
  10. torchvulkan-0.2.2/src/api/fallback.h +11 -0
  11. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/binary.cpp +3 -2
  12. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/bitwise.cpp +2 -1
  13. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/compare.cpp +4 -3
  14. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/fill.cpp +2 -1
  15. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/grid_sample.cpp +1 -2
  16. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/indexing.cpp +6 -5
  17. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/linalg.cpp +5 -11
  18. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/matmul.cpp +5 -4
  19. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/nllloss.cpp +3 -2
  20. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/reduce.cpp +3 -1
  21. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/scan.cpp +3 -0
  22. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/scatter.cpp +2 -1
  23. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/search.cpp +2 -1
  24. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/sort.cpp +2 -1
  25. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/special.cpp +2 -1
  26. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/unary.cpp +3 -2
  27. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/registration.cpp +0 -14
  28. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/tensor/transfer.cpp +2 -1
  29. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/core/dtype.slang +3 -1
  30. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/eig.slang +1 -1
  31. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/grid_sample.slang +120 -1
  32. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/householder.slang +2 -1
  33. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/allocator.cpp +50 -17
  34. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/allocator.h +0 -1
  35. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/cache.cpp +34 -11
  36. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/cache.h +11 -5
  37. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/device_context.cpp +36 -2
  38. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/device_context.h +5 -0
  39. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/shader.cpp +0 -7
  40. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/shader.h +0 -1
  41. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/vulkan_context.cpp +1 -0
  42. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/vulkan_context.h +2 -0
  43. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/tests/test_pytorch_ops.py +12 -7
  44. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/torchvulkan/__init__.py +15 -5
  45. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/torchvulkan/_version.py +3 -3
  46. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/tox.ini +1 -3
  47. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.github/actions/setup-toolchain/action.yml +0 -0
  48. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.github/scripts/fetch-moltenvk-macos.sh +0 -0
  49. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.github/scripts/install-toolchain-linux.sh +0 -0
  50. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/.gitignore +0 -0
  51. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/LICENSE +0 -0
  52. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/benchmark/benchmark.py +0 -0
  53. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/examples/conv.py +0 -0
  54. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/examples/llm.py +0 -0
  55. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/examples/mlp.py +0 -0
  56. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/extern/vma/vk_mem_alloc.h +0 -0
  57. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/extern/volk/volk.c +0 -0
  58. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/extern/volk/volk.h +0 -0
  59. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/licenses/MoltenVK-LICENSE +0 -0
  60. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/media/benchmark-cuda.png +0 -0
  61. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/requirements.txt +0 -0
  62. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/scripts/build_shaders.py +0 -0
  63. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/scripts/config.py +0 -0
  64. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/scripts/pack_shaders.py +0 -0
  65. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/guard.cpp +0 -0
  66. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/hook.cpp +0 -0
  67. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/complex.cpp +0 -0
  68. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/conv.cpp +0 -0
  69. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/ctc.cpp +0 -0
  70. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/distributions.cpp +0 -0
  71. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/dropout.cpp +0 -0
  72. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/fft.cpp +0 -0
  73. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/helpers.h +0 -0
  74. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/internal.h +0 -0
  75. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/nn.cpp +0 -0
  76. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/optim.cpp +0 -0
  77. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/pool.cpp +0 -0
  78. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/random.cpp +0 -0
  79. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/sampling.cpp +0 -0
  80. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/shape.cpp +0 -0
  81. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/ops/upsample.cpp +0 -0
  82. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/tensor/allocation.cpp +0 -0
  83. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/tensor/cast.cpp +0 -0
  84. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/api/tensor/views.cpp +0 -0
  85. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/CMakeLists.txt +0 -0
  86. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/core/cast.slang +0 -0
  87. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/core/indexing.slang +0 -0
  88. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/core/philox.slang +0 -0
  89. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/core/special_functions.slang +0 -0
  90. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/arg_reduce.slang +0 -0
  91. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/binary.slang +0 -0
  92. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/cast.slang +0 -0
  93. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/cholesky.slang +0 -0
  94. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/compare.slang +0 -0
  95. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/conv.slang +0 -0
  96. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/copy.slang +0 -0
  97. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/ctc.slang +0 -0
  98. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/distribution.slang +0 -0
  99. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/dropout.slang +0 -0
  100. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/embedding_backward.slang +0 -0
  101. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/fft.slang +0 -0
  102. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/fill.slang +0 -0
  103. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/index_gather.slang +0 -0
  104. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/integer_binary.slang +0 -0
  105. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/jacobi.slang +0 -0
  106. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/ldl.slang +0 -0
  107. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/lu.slang +0 -0
  108. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/matmul_coop.slang +0 -0
  109. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/matmul_simd.slang +0 -0
  110. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/multinomial.slang +0 -0
  111. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/nllloss.slang +0 -0
  112. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/pool.slang +0 -0
  113. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/random.slang +0 -0
  114. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/reduce.slang +0 -0
  115. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/reduce_subgroup.slang +0 -0
  116. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/resample.slang +0 -0
  117. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/resample_u8.slang +0 -0
  118. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/scan.slang +0 -0
  119. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/scan_arg.slang +0 -0
  120. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/scatter.slang +0 -0
  121. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/searchsorted.slang +0 -0
  122. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/sort.slang +0 -0
  123. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/special.slang +0 -0
  124. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/triangular_solve.slang +0 -0
  125. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/unary.slang +0 -0
  126. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/unary_ops.slang +0 -0
  127. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/shaders/ops/where.slang +0 -0
  128. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/builders.h +0 -0
  129. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/dispatch.cpp +0 -0
  130. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/dispatch.h +0 -0
  131. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/generator.cpp +0 -0
  132. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/generator.h +0 -0
  133. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/memory.cpp +0 -0
  134. {torchvulkan-0.2.1 → torchvulkan-0.2.2}/src/vulkan/memory.h +0 -0
@@ -21,7 +21,7 @@ jobs:
21
21
 
22
22
  - uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
23
23
  with:
24
- python-version: "3.10"
24
+ python-version: "3.15"
25
25
 
26
26
  - name: Build sdist
27
27
  run: |
@@ -34,18 +34,20 @@ jobs:
34
34
  path: dist/*.tar.gz
35
35
 
36
36
  build_wheels:
37
- name: Wheels (${{ matrix.name }})
37
+ name: Wheels (${{ matrix.name }} / ${{ matrix.python }})
38
38
  runs-on: ${{ matrix.os }}
39
39
  strategy:
40
40
  fail-fast: false
41
41
  matrix:
42
+ os: [ubuntu-latest, macos-15, windows-latest]
43
+ python: [cp311, cp312, cp313, cp314, cp315]
42
44
  include:
43
- - name: Linux x86_64
44
- os: ubuntu-latest
45
- - name: macOS Apple Silicon
46
- os: macos-15
47
- - name: Windows x86_64
48
- os: windows-latest
45
+ - os: ubuntu-latest
46
+ name: Linux x86_64
47
+ - os: macos-15
48
+ name: macOS Apple Silicon
49
+ - os: windows-latest
50
+ name: Windows x86_64
49
51
  steps:
50
52
  - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
51
53
  with:
@@ -67,13 +69,14 @@ jobs:
67
69
  uses: ./.github/actions/setup-toolchain
68
70
 
69
71
  - name: Build wheels
70
- uses: pypa/cibuildwheel@9c00cb4f6b517705a3794b22395aedc36257242c # v3.2.1
72
+ uses: pypa/cibuildwheel@f9b966cfadf4109556cadc5bb39ddb72d0ce664e # v4.3.5
71
73
  env:
72
74
  CIBW_BUILD_VERBOSITY: "1"
75
+ CIBW_BUILD: ${{ matrix.python }}-*
73
76
 
74
77
  - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
75
78
  with:
76
- name: dist-${{ matrix.os }}
79
+ name: dist-${{ matrix.os }}-${{ matrix.python }}
77
80
  path: wheelhouse/*.whl
78
81
 
79
82
  pypi-publish:
@@ -8,7 +8,7 @@ on:
8
8
 
9
9
  jobs:
10
10
  build-and-test:
11
- name: ${{ matrix.os }} / Py${{ matrix.python-version }} / ${{ matrix.torch-factor }}
11
+ name: ${{ matrix.os }} / Py${{ matrix.python-version }}
12
12
  runs-on: ${{ matrix.os }}
13
13
  env:
14
14
  SKBUILD_CMAKE_GENERATOR: Ninja
@@ -16,8 +16,7 @@ jobs:
16
16
  fail-fast: false
17
17
  matrix:
18
18
  os: [ubuntu-latest, macos-15, windows-latest]
19
- python-version: ["3.10", "3.12", "3.14"]
20
- torch-factor: ["torch210", "torch213"]
19
+ python-version: ["3.11", "3.13", "3.15"]
21
20
 
22
21
  steps:
23
22
  - name: Checkout Code
@@ -50,7 +49,7 @@ jobs:
50
49
  DNNL_MAX_CPU_ISA: AVX2 # legacy name for the same oneDNN ISA cap (older bundled oneDNN)
51
50
  LP_NATIVE_VECTOR_WIDTH: "256" # cap lavapipe's LLVM JIT to AVX2; AVX-512 codegen faults (0xc000001d) on GHA runners
52
51
  run: |
53
- tox -e py-${{ matrix.torch-factor }}
52
+ tox -e py
54
53
 
55
54
  validation:
56
55
  name: validation layers (lavapipe, debug)
@@ -83,7 +82,7 @@ jobs:
83
82
  run: |
84
83
  python -m pip install --upgrade pip
85
84
  pip install tox
86
- tox -e py-torch213 -- -k "TestVulkanRuntime or test_correctness_add or test_correctness_mm or test_correctness_sum or test_correctness_sort or test_correctness_index or test_correctness_cumsum or test_gradients_nn_functional_linear"
85
+ tox -e py -- -k "test_correctness_add or test_correctness_mm or test_correctness_sum or test_correctness_sort or test_correctness_index or test_correctness_cumsum or test_gradients_nn_functional_linear"
87
86
 
88
87
  sanitizers:
89
88
  name: ASan + UBSan (lavapipe)
@@ -108,7 +107,7 @@ jobs:
108
107
  SKBUILD_CMAKE_ARGS: "-DCMAKE_CXX_FLAGS=-fsanitize=address,undefined -fno-omit-frame-pointer;-DCMAKE_MODULE_LINKER_FLAGS=-fsanitize=address,undefined"
109
108
  run: |
110
109
  python -m pip install --upgrade pip
111
- pip install "torch==2.13.0" pytest expecttest numpy ninja scikit-build-core setuptools_scm
110
+ pip install $(python -c 'import tomllib; print(" ".join(tomllib.load(open("pyproject.toml", "rb"))["build-system"]["requires"]))') pytest expecttest numpy ninja
112
111
  pip install . --no-build-isolation -v
113
112
 
114
113
  - name: Run tests with the sanitizer runtimes preloaded
@@ -123,7 +122,7 @@ jobs:
123
122
  run: |
124
123
  cd "$RUNNER_TEMP"
125
124
  export LD_PRELOAD="$(gcc -print-file-name=libasan.so):$(gcc -print-file-name=libubsan.so)"
126
- python -m pytest "$GITHUB_WORKSPACE/tests/test_pytorch_ops.py" -q -k "TestVulkanRuntime or test_correctness_add or test_correctness_mm or test_correctness_sort or test_correctness_index or test_correctness_sum"
125
+ python -m pytest "$GITHUB_WORKSPACE/tests/test_pytorch_ops.py" -q -k "test_correctness_add or test_correctness_mm or test_correctness_sort or test_correctness_index or test_correctness_sum"
127
126
 
128
127
  testing-success:
129
128
  name: testing success
@@ -30,6 +30,9 @@ target_compile_features(torchvulkan_lib PRIVATE cxx_std_20)
30
30
 
31
31
  install(TARGETS torchvulkan_lib DESTINATION torchvulkan)
32
32
 
33
+ file(WRITE "${TORCHVULKAN_GENERATED_DIR}/_build_info.py" "torch_version = \"${Torch_VERSION}\"\n")
34
+ install(FILES "${TORCHVULKAN_GENERATED_DIR}/_build_info.py" DESTINATION torchvulkan)
35
+
33
36
  if(APPLE)
34
37
  find_library(TORCHVULKAN_MOLTENVK NAMES libMoltenVK.dylib)
35
38
  if(TORCHVULKAN_MOLTENVK)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: torchvulkan
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Cross-Platform Vulkan Backend for PyTorch
5
5
  Author: Zain Sharief
6
6
  License-Expression: MIT
@@ -9,7 +9,8 @@ License-File: licenses/MoltenVK-LICENSE
9
9
  Project-URL: Homepage, https://github.com/zainsharief/torchvulkan
10
10
  Project-URL: Repository, https://github.com/zainsharief/torchvulkan
11
11
  Project-URL: Issues, https://github.com/zainsharief/torchvulkan/issues
12
- Requires-Dist: torch>=2.10.0
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: torch<2.16,>=2.15.0
13
14
  Provides-Extra: test
14
15
  Requires-Dist: pytest; extra == "test"
15
16
  Requires-Dist: tox; extra == "test"
@@ -23,7 +24,7 @@ Description-Content-Type: text/markdown
23
24
  <p align="center">
24
25
  <a href="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml"><img alt="CI" src="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml/badge.svg"></a>
25
26
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
26
- <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-blue">
27
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue">
27
28
  <img alt="Status: experimental" src="https://img.shields.io/badge/status-experimental-orange">
28
29
  </p>
29
30
 
@@ -195,6 +196,7 @@ TORCHVULKAN_STRICT=1 python your_script.py
195
196
  | Variable | Effect |
196
197
  | --- | --- |
197
198
  | `TORCHVULKAN_STRICT=1` | Raise an error instead of falling back to the CPU. |
199
+ | `TORCHVULKAN_STRICT_ALLOCATION=1` | Raise an out-of-memory error instead of allocating past the VRAM budget. By default torchvulkan allocates anyway (with a one-time warning), and the driver may put the memory in system RAM, which is much slower. |
198
200
  | `TORCHVULKAN_SYSTEM_VULKAN=1` | macOS: use the system Vulkan loader instead of the bundled MoltenVK. |
199
201
  | `TORCHVULKAN_VALIDATION=1` | Enable the Khronos validation layer, if it's installed. `=sync` also enables synchronization validation. On macOS this needs `TORCHVULKAN_SYSTEM_VULKAN=1`. |
200
202
  | `TORCHVULKAN_PROFILE=1` | Print each compute pipeline's driver statistics (such as register use) when it's compiled, on drivers that support `VK_KHR_pipeline_executable_properties`. |
@@ -208,7 +210,6 @@ TORCHVULKAN_STRICT=1 python your_script.py
208
210
  - `float64` runs on the GPU only on devices with `shaderFloat64`; elsewhere it falls back to the CPU. Transcendental functions such as `exp`, `sin` and `tanh` are computed in `float32` precision for `float64` tensors.
209
211
  - `bfloat16` runs on the GPU only on devices with `VK_KHR_shader_bfloat16`; elsewhere it falls back to the CPU.
210
212
  - Complex tensors can live on the device and FFTs run on the GPU, but most complex arithmetic falls back to the CPU.
211
- - `torch>=2.10.0` only. The extension is compiled against 2.13.0 but has testing support for >=2.10.0.
212
213
  - APIs and coverage may change before `1.0.0`.
213
214
 
214
215
  ## How it works
@@ -6,7 +6,7 @@
6
6
  <p align="center">
7
7
  <a href="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml"><img alt="CI" src="https://github.com/zainsharief/torchvulkan/actions/workflows/test_torchvulkan.yml/badge.svg"></a>
8
8
  <a href="LICENSE"><img alt="License: MIT" src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
9
- <img alt="Python 3.10+" src="https://img.shields.io/badge/python-3.10%2B-blue">
9
+ <img alt="Python 3.11+" src="https://img.shields.io/badge/python-3.11%2B-blue">
10
10
  <img alt="Status: experimental" src="https://img.shields.io/badge/status-experimental-orange">
11
11
  </p>
12
12
 
@@ -178,6 +178,7 @@ TORCHVULKAN_STRICT=1 python your_script.py
178
178
  | Variable | Effect |
179
179
  | --- | --- |
180
180
  | `TORCHVULKAN_STRICT=1` | Raise an error instead of falling back to the CPU. |
181
+ | `TORCHVULKAN_STRICT_ALLOCATION=1` | Raise an out-of-memory error instead of allocating past the VRAM budget. By default torchvulkan allocates anyway (with a one-time warning), and the driver may put the memory in system RAM, which is much slower. |
181
182
  | `TORCHVULKAN_SYSTEM_VULKAN=1` | macOS: use the system Vulkan loader instead of the bundled MoltenVK. |
182
183
  | `TORCHVULKAN_VALIDATION=1` | Enable the Khronos validation layer, if it's installed. `=sync` also enables synchronization validation. On macOS this needs `TORCHVULKAN_SYSTEM_VULKAN=1`. |
183
184
  | `TORCHVULKAN_PROFILE=1` | Print each compute pipeline's driver statistics (such as register use) when it's compiled, on drivers that support `VK_KHR_pipeline_executable_properties`. |
@@ -191,7 +192,6 @@ TORCHVULKAN_STRICT=1 python your_script.py
191
192
  - `float64` runs on the GPU only on devices with `shaderFloat64`; elsewhere it falls back to the CPU. Transcendental functions such as `exp`, `sin` and `tanh` are computed in `float32` precision for `float64` tensors.
192
193
  - `bfloat16` runs on the GPU only on devices with `VK_KHR_shader_bfloat16`; elsewhere it falls back to the CPU.
193
194
  - Complex tensors can live on the device and FFTs run on the GPU, but most complex arithmetic falls back to the CPU.
194
- - `torch>=2.10.0` only. The extension is compiled against 2.13.0 but has testing support for >=2.10.0.
195
195
  - APIs and coverage may change before `1.0.0`.
196
196
 
197
197
  ## How it works
@@ -1,5 +1,5 @@
1
1
  [build-system]
2
- requires = ["torch==2.13.0", "scikit-build-core", "setuptools_scm"]
2
+ requires = ["torch==2.15.0", "scikit-build-core", "setuptools_scm"]
3
3
  build-backend = "scikit_build_core.build"
4
4
 
5
5
  [project]
@@ -7,7 +7,8 @@ name = "torchvulkan"
7
7
  description = "Cross-Platform Vulkan Backend for PyTorch"
8
8
  readme = "README.md"
9
9
  dynamic = ["version"]
10
- dependencies = ["torch>=2.10.0"]
10
+ requires-python = ">=3.11"
11
+ dependencies = ["torch>=2.15.0,<2.16"]
11
12
  license = "MIT"
12
13
  license-files = ["LICENSE", "licenses/MoltenVK-LICENSE"]
13
14
  authors = [{ name = "Zain Sharief"}]
@@ -33,10 +34,9 @@ write_to = "torchvulkan/_version.py"
33
34
  test = ["pytest", "tox"]
34
35
 
35
36
  [tool.cibuildwheel]
36
- build = "cp310-* cp311-* cp312-* cp313-* cp314-*"
37
+ build = "cp311-* cp312-* cp313-* cp314-* cp315-*"
37
38
  skip = "*-musllinux_* *_i686 *-win32"
38
39
  test-command = 'python -c "import torchvulkan; print(torchvulkan.__version__)"'
39
- test-requires = "torch>=2.10.0"
40
40
 
41
41
  [tool.cibuildwheel.linux]
42
42
  manylinux-x86_64-image = "manylinux_2_34"
@@ -49,7 +49,7 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
49
49
  });
50
50
 
51
51
  m.def("empty_cache", []() {
52
- for (DeviceContext* device : VulkanContext::Instance().devices) device->shader_manager->flushAndReleaseBuffers();
52
+ for (DeviceContext* device : VulkanContext::Instance().devices) device->releaseCachedBuffers(SIZE_MAX, MemoryUsage::DEVICE_ONLY);
53
53
  }, py::call_guard<py::gil_scoped_release>());
54
54
 
55
55
  m.def("_save_pipeline_caches", []() {
@@ -338,7 +338,12 @@ at::Tensor mish_vulkan(const at::Tensor& self)
338
338
  at::Tensor logit_vulkan(const at::Tensor& self, c10::optional<double> eps)
339
339
  {
340
340
  at::Tensor x = promote_to_float(self);
341
- if (eps.has_value()) x = at::clamp(x, *eps, 1.0 - *eps);
341
+ // lo is checked first, matching the CPU when eps > 0.5 makes lo > hi
342
+ if (eps.has_value()) {
343
+ at::Tensor lo = at::full({}, *eps, x.options());
344
+ at::Tensor hi = at::full({}, 1.0 - *eps, x.options());
345
+ x = at::where(at::lt(x, lo), lo, at::where(at::gt(x, hi), hi, x));
346
+ }
342
347
  return at::log(at::div(x, at::rsub(x, 1)));
343
348
  }
344
349
 
@@ -0,0 +1,13 @@
1
+ #include <torch/extension.h>
2
+ #include <ATen/native/CPUFallback.h>
3
+ #include "api/fallback.h"
4
+
5
+ void vulkan_cpu_fallback(const c10::OperatorHandle& op, torch::jit::Stack* stack)
6
+ {
7
+ TORCHVULKAN_FALLBACK("Silent fallback detected for operation: ", op.schema().operator_name(), ".");
8
+ at::native::cpu_fallback(op, stack);
9
+ }
10
+
11
+ TORCH_LIBRARY_IMPL(_, PrivateUse1, m) {
12
+ m.fallback(torch::CppFunction::makeFromBoxedFunction<&vulkan_cpu_fallback>());
13
+ }
@@ -0,0 +1,11 @@
1
+ #pragma once
2
+ #include <c10/util/Exception.h>
3
+ #include "vulkan/vulkan_context.h"
4
+
5
+ // every CPU fallback, for unimplemented ops and for registered ops with an unsupported dtype or shape;
6
+ // an error under TORCHVULKAN_STRICT=1
7
+ #define TORCHVULKAN_FALLBACK(...) \
8
+ do { \
9
+ if (VulkanContext::Instance().isStrict()) TORCH_CHECK(false, "torchvulkan [NOT IMPLEMENTED]: ", __VA_ARGS__, " Set TORCHVULKAN_STRICT=0 to disable strict mode."); \
10
+ TORCH_WARN_ONCE("torchvulkan [WARNING]: ", __VA_ARGS__, " Set TORCHVULKAN_STRICT=1 to enable strict mode."); \
11
+ } while (0)
@@ -9,6 +9,7 @@
9
9
  #include "vulkan/allocator.h"
10
10
  #include "api/ops/helpers.h"
11
11
  #include "api/ops/internal.h"
12
+ #include "api/fallback.h"
12
13
 
13
14
  namespace {
14
15
 
@@ -120,7 +121,7 @@ at::Tensor binary_op_vulkan(
120
121
  std::optional<at::Tensor> out = dispatch_binary_shader(self, at::Tensor(), other, alpha, operation, at::result_type(self, other));
121
122
  if (out.has_value()) return *out;
122
123
 
123
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A binary op on ", self.scalar_type(), " can't run on the Vulkan device. Falling back to CPU.");
124
+ TORCHVULKAN_FALLBACK("A binary op on ", self.scalar_type(), " can't run on the Vulkan device. Falling back to CPU.");
124
125
  return fallback(self.cpu(), other).to(self.device());
125
126
  }
126
127
 
@@ -145,7 +146,7 @@ at::Tensor binary_op_vulkan(
145
146
  std::optional<at::Tensor> out = dispatch_binary_shader(lhs, rhs, at::Scalar(0), alpha, operation, at::result_type(self, other));
146
147
  if (out.has_value()) return *out;
147
148
 
148
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A binary op on ", at::result_type(self, other), " can't run on the Vulkan device. Falling back to CPU.");
149
+ TORCHVULKAN_FALLBACK("A binary op on ", at::result_type(self, other), " can't run on the Vulkan device. Falling back to CPU.");
149
150
  return fallback(lhs.cpu(), rhs.cpu()).to(lhs.device());
150
151
  }
151
152
 
@@ -3,6 +3,7 @@
3
3
  #include "vulkan/memory.h"
4
4
  #include "vulkan/vulkan_context.h"
5
5
  #include "api/ops/helpers.h"
6
+ #include "api/fallback.h"
6
7
 
7
8
  namespace {
8
9
 
@@ -116,7 +117,7 @@ at::Tensor& integer_binary_out(
116
117
  ? dispatch_integer_binary_shader(self, at::Tensor(), other.item(), result, operation)
117
118
  : dispatch_integer_binary_shader(self, other, at::Scalar(0), result, operation);
118
119
  if (!ran) {
119
- TORCH_WARN_ONCE("torchvulkan [WARNING]: ", name, " on ", dtype, " can't run on the Vulkan device. Falling back to CPU.");
120
+ TORCHVULKAN_FALLBACK(name, " on ", dtype, " can't run on the Vulkan device. Falling back to CPU.");
120
121
  result.copy_(cpu_integer_binary(self.cpu(), other.cpu(), operation));
121
122
  }
122
123
  if (!result.is_same(out)) fill_out(out, result);
@@ -5,6 +5,7 @@
5
5
  #include "vulkan/vulkan_context.h"
6
6
  #include "vulkan/allocator.h"
7
7
  #include "api/ops/helpers.h"
8
+ #include "api/fallback.h"
8
9
 
9
10
  namespace {
10
11
 
@@ -132,7 +133,7 @@ at::Tensor where_vulkan(
132
133
  DeviceContext* context = get_device_context(out);
133
134
  int32_t out_dims = static_cast<int32_t>(iter.ndim());
134
135
  if (!is_dtype_supported(context, promoted) || out_dims > MAX_DIMS || !fits_32bit_indexing(iter)) {
135
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This where can't run on the Vulkan device. Falling back to CPU.");
136
+ TORCHVULKAN_FALLBACK("This where can't run on the Vulkan device. Falling back to CPU.");
136
137
  return at::where(c.cpu(), a.cpu(), b.cpu()).to(device);
137
138
  }
138
139
 
@@ -172,7 +173,7 @@ at::Tensor& compare_scalar_out_vulkan(const at::Tensor& self, const at::Scalar&
172
173
  if (!out.sizes().equals(self.sizes())) out.resize_(self.sizes());
173
174
  c10::ScalarType promoted = at::result_type(self, other);
174
175
  if (!dispatch_compare_shader(self, nullptr, other, out, op, promoted)) {
175
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This comparison can't run on the Vulkan device. Falling back to CPU.");
176
+ TORCHVULKAN_FALLBACK("This comparison can't run on the Vulkan device. Falling back to CPU.");
176
177
  out.copy_(cpu_compare_scalar(self.cpu(), other, op));
177
178
  }
178
179
  return out;
@@ -195,7 +196,7 @@ at::Tensor& compare_out_vulkan(const at::Tensor& self, const at::Tensor& other,
195
196
  at::Tensor lhs = self.to(out.device());
196
197
  at::Tensor rhs = other.to(out.device());
197
198
  if (!dispatch_compare_shader(lhs, &rhs, at::Scalar(0), out, op, promoted)) {
198
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This comparison can't run on the Vulkan device. Falling back to CPU.");
199
+ TORCHVULKAN_FALLBACK("This comparison can't run on the Vulkan device. Falling back to CPU.");
199
200
  out.copy_(cpu_compare(self.cpu(), other.cpu(), op));
200
201
  }
201
202
  return out;
@@ -3,6 +3,7 @@
3
3
  #include "vulkan/vulkan_context.h"
4
4
  #include "vulkan/allocator.h"
5
5
  #include "api/ops/helpers.h"
6
+ #include "api/fallback.h"
6
7
 
7
8
  namespace {
8
9
 
@@ -17,7 +18,7 @@ at::Tensor& fill_scalar_vulkan(
17
18
 
18
19
  int32_t out_dims = static_cast<int32_t>(iter.ndim());
19
20
  if (!is_dtype_supported(self, iter.dtype()) || out_dims > MAX_DIMS || !fits_32bit_indexing(iter)) {
20
- TORCH_WARN_ONCE("torchvulkan [WARNING]: Can't fill a ", iter.dtype(), " tensor of this shape on the Vulkan device. Falling back to CPU.");
21
+ TORCHVULKAN_FALLBACK("Can't fill a ", iter.dtype(), " tensor of this shape on the Vulkan device. Falling back to CPU.");
21
22
  self.copy_(at::empty(self.sizes(), self.options().device(at::kCPU)).fill_(value));
22
23
  return self;
23
24
  }
@@ -56,7 +56,7 @@ int64_t outputs_of(const GridSampleProblem& p) { return p.out[0] * p.out[1] * p.
56
56
  int64_t tap_count(int64_t interpolation, int64_t dims)
57
57
  {
58
58
  if (interpolation == 1) return 1;
59
- if (interpolation == 2) return 16;
59
+ if (interpolation == 2) return dims == 3 ? 64 : 16;
60
60
  return dims == 3 ? 8 : 4;
61
61
  }
62
62
 
@@ -138,7 +138,6 @@ std::vector<int64_t> output_shape(const GridSampleProblem& p)
138
138
 
139
139
  at::Tensor grid_sampler_forward(const at::Tensor& input, const at::Tensor& grid, int64_t dims, int64_t interpolation, int64_t padding, bool align_corners)
140
140
  {
141
- TORCH_CHECK(dims == 2 || interpolation != 2, "grid_sampler(): bicubic interpolation only supports 4D input");
142
141
  GridSampleProblem p = make_problem(input, grid, dims);
143
142
  at::Tensor output = at::empty(output_shape(p), p.input.options());
144
143
  if (p.channels > 0) dispatch_grid_sample_shader(p, output, at::Tensor(), at::Tensor(), at::Tensor(), at::Tensor(), GridSampleMode::FORWARD, interpolation, padding, align_corners);
@@ -7,6 +7,7 @@
7
7
  #include "vulkan/memory.h"
8
8
  #include "vulkan/vulkan_context.h"
9
9
  #include "api/ops/helpers.h"
10
+ #include "api/fallback.h"
10
11
 
11
12
  namespace {
12
13
 
@@ -120,7 +121,7 @@ at::Tensor& gather_out_vulkan(const at::Tensor& self, int64_t dim, const at::Ten
120
121
  if (src.size(dim) == 0 || !is_dtype_copyable(self, self.scalar_type()) ||
121
122
  !dispatch_index_gather_shader(result, restride_for_dim(src, dim, idx.sizes()), {idx}, {src.size(dim)}, {src.stride(dim)}, false))
122
123
  {
123
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This gather can't run on the Vulkan device. Falling back to CPU.");
124
+ TORCHVULKAN_FALLBACK("This gather can't run on the Vulkan device. Falling back to CPU.");
124
125
  out.copy_(at::gather(self.cpu(), dim, index.cpu()));
125
126
  }
126
127
  return out;
@@ -132,7 +133,7 @@ at::Tensor index_select_vulkan(const at::Tensor& self, int64_t dim, const at::Te
132
133
  TORCH_CHECK_INDEX(index.scalar_type() == at::kLong || index.scalar_type() == at::kInt, "index_select(): Expected dtype int32 or int64 for index");
133
134
 
134
135
  if (self.dim() == 0) {
135
- TORCH_WARN_ONCE("torchvulkan [WARNING]: index_select on a 0-dim tensor runs on the CPU.");
136
+ TORCHVULKAN_FALLBACK("index_select on a 0-dim tensor runs on the CPU.");
136
137
  return at::index_select(self.cpu(), dim, index.cpu()).to(self.device());
137
138
  }
138
139
 
@@ -150,7 +151,7 @@ at::Tensor index_select_vulkan(const at::Tensor& self, int64_t dim, const at::Te
150
151
  if (self.size(dim) == 0 || !is_dtype_copyable(self, self.scalar_type()) ||
151
152
  !dispatch_index_gather_shader(out, restride_for_dim(self, dim, out_sizes), {idx}, {self.size(dim)}, {self.stride(dim)}, false))
152
153
  {
153
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This index_select can't run on the Vulkan device. Falling back to CPU.");
154
+ TORCHVULKAN_FALLBACK("This index_select can't run on the Vulkan device. Falling back to CPU.");
154
155
  return at::index_select(self.cpu(), dim, index.cpu()).to(self.device());
155
156
  }
156
157
  return out;
@@ -229,7 +230,7 @@ at::Tensor& index_out_vulkan(const at::Tensor& self, const c10::List<std::option
229
230
  if (!is_dtype_copyable(self, self.scalar_type()) ||
230
231
  !dispatch_index_gather_shader(out, plan.src, plan.indices, plan.index_sizes, plan.index_strides, /*wrap_negative=*/true))
231
232
  {
232
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This index can't run on the Vulkan device. Falling back to CPU.");
233
+ TORCHVULKAN_FALLBACK("This index can't run on the Vulkan device. Falling back to CPU.");
233
234
  c10::List<std::optional<at::Tensor>> cpu_indices;
234
235
  for (const std::optional<at::Tensor>& index : indices) {
235
236
  cpu_indices.push_back(index.has_value() && index->defined() ? std::optional<at::Tensor>(index->cpu()) : std::nullopt);
@@ -276,7 +277,7 @@ at::Tensor embedding_dense_backward_vulkan(
276
277
  if (!at::isFloatingType(grad_output.scalar_type()) || !is_dtype_supported(device, grad_output.scalar_type()) ||
277
278
  !fits_32bit_indexing({flat_grad, grad_weight}))
278
279
  {
279
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This embedding backward can't run on the Vulkan device. Falling back to CPU.");
280
+ TORCHVULKAN_FALLBACK("This embedding backward can't run on the Vulkan device. Falling back to CPU.");
280
281
  return at::embedding_dense_backward(grad_output.cpu(), indices.cpu(), num_weights_, padding_idx_, scale_grad_by_freq).to(grad_output.device());
281
282
  }
282
283
 
@@ -1,5 +1,4 @@
1
1
  #include <torch/extension.h>
2
- #include <torch/version.h>
3
2
  #include <ATen/ExpandUtils.h>
4
3
  #include <ATen/WrapDimUtils.h>
5
4
  #include <algorithm>
@@ -12,6 +11,7 @@
12
11
  #include "vulkan/memory.h"
13
12
  #include "vulkan/vulkan_context.h"
14
13
  #include "api/ops/helpers.h"
14
+ #include "api/fallback.h"
15
15
 
16
16
  namespace {
17
17
 
@@ -318,7 +318,7 @@ at::Tensor solve_triangular_left(const at::Tensor& A, const at::Tensor& B, bool
318
318
  auto [a, b] = broadcast_batches(A, B);
319
319
  if (b.numel() == 0 || a.size(-1) == 0) return b.clone();
320
320
  if (a.is_complex() || b.is_complex()) {
321
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A complex triangular solve can't run on the Vulkan device. Falling back to CPU.");
321
+ TORCHVULKAN_FALLBACK("A complex triangular solve can't run on the Vulkan device. Falling back to CPU.");
322
322
  at::ScalarType type = at::promote_types(a.scalar_type(), b.scalar_type());
323
323
  return at::linalg_solve_triangular(a.cpu().to(type), b.cpu().to(type), upper, /*left=*/true, unit).to(B.device());
324
324
  }
@@ -354,7 +354,7 @@ std::tuple<at::Tensor, at::Tensor, at::Tensor> lu_factor_impl(const at::Tensor&
354
354
  {
355
355
  TORCH_CHECK(A.dim() >= 2, name, ": Expected tensor with 2 or more dimensions. Got size: ", A.sizes(), " instead");
356
356
  if (A.is_complex()) {
357
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A complex LU factorization can't run on the Vulkan device. Falling back to CPU.");
357
+ TORCHVULKAN_FALLBACK("A complex LU factorization can't run on the Vulkan device. Falling back to CPU.");
358
358
  auto [lu, pivots, info] = at::linalg_lu_factor_ex(A.cpu());
359
359
  return std::make_tuple(lu.to(A.device()), pivots.to(A.device()), info.to(A.device()));
360
360
  }
@@ -492,14 +492,8 @@ std::tuple<at::Tensor&, at::Tensor&, at::Tensor&, at::Tensor&> linalg_solve_ex_o
492
492
  check_square(A, "torch.linalg.solve");
493
493
  bool vector_case = is_vector_rhs(A, B);
494
494
  at::Tensor b = vector_case ? B.unsqueeze(left ? -1 : -2) : B;
495
- // torch 2.10's solve backward expects the LU of A^T when A is contiguous and real; 2.11 factors A itself
496
- #if TORCH_VERSION_MAJOR == 2 && TORCH_VERSION_MINOR <= 10
497
- bool use_A_T = A.is_contiguous() && !A.is_complex();
498
- #else
499
- bool use_A_T = false;
500
- #endif
501
- auto [lu, piv, inf] = lu_factor_impl(use_A_T ? A.mT() : A, "torch.linalg.solve");
502
- at::Tensor x = lu_solve_impl(lu, piv, b, left, /*adjoint=*/use_A_T);
495
+ auto [lu, piv, inf] = lu_factor_impl(A, "torch.linalg.solve");
496
+ at::Tensor x = lu_solve_impl(lu, piv, b, left, /*adjoint=*/false);
503
497
  if (vector_case) x = x.squeeze(left ? -1 : -2);
504
498
  fill_out(result, x);
505
499
  fill_out(LU, lu);
@@ -6,6 +6,7 @@
6
6
  #include "vulkan/allocator.h"
7
7
  #include "api/ops/helpers.h"
8
8
  #include "api/ops/internal.h"
9
+ #include "api/fallback.h"
9
10
 
10
11
  namespace {
11
12
 
@@ -171,7 +172,7 @@ at::Tensor dispatch_matmul_simd_shader(
171
172
  DeviceContext* device = get_device_context(self_);
172
173
  c10::ScalarType result_dtype = at::result_type(shape.self, shape.other);
173
174
  if (!is_dtype_supported(device, result_dtype) || WG * WG > device->properties.limits.maxComputeWorkGroupInvocations) {
174
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A ", result_dtype, " matmul can't run on the Vulkan device. Falling back to CPU.");
175
+ TORCHVULKAN_FALLBACK("A ", result_dtype, " matmul can't run on the Vulkan device. Falling back to CPU.");
175
176
  return cpu_fallback();
176
177
  }
177
178
 
@@ -190,7 +191,7 @@ at::Tensor dispatch_matmul_simd_shader(
190
191
  uint32_t tile_m = c10::elementSize(result_dtype) < 8 ? 128 : 64;
191
192
  if (tile_m == 128 && shared_bytes(128) > max_shared_memory) tile_m = 64;
192
193
  if (shared_bytes(tile_m) > max_shared_memory) {
193
- TORCH_WARN_ONCE("torchvulkan [WARNING]: a ", result_dtype, " matmul tile needs ", shared_bytes(tile_m),
194
+ TORCHVULKAN_FALLBACK("a ", result_dtype, " matmul tile needs ", shared_bytes(tile_m),
194
195
  " bytes of shared memory but the device provides ", max_shared_memory, ". Falling back to CPU.");
195
196
  return cpu_fallback();
196
197
  }
@@ -204,7 +205,7 @@ at::Tensor dispatch_matmul_simd_shader(
204
205
  return finish_matmul_output(apply_matmul_activation(result, activation), shape);
205
206
  }
206
207
  if (!fits_matmul_indexing(ops, out)) {
207
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A matmul is too large for 32-bit indexing. Falling back to CPU.");
208
+ TORCHVULKAN_FALLBACK("A matmul is too large for 32-bit indexing. Falling back to CPU.");
208
209
  return cpu_fallback();
209
210
  }
210
211
 
@@ -299,7 +300,7 @@ at::Tensor dispatch_matmul_coop_shader(
299
300
  DeviceContext* device = get_device_context(self_);
300
301
  c10::ScalarType promoted_type = at::result_type(self_, other_);
301
302
  if (!is_dtype_supported(device, promoted_type)) {
302
- TORCH_WARN_ONCE("torchvulkan [WARNING]: Vulkan device does not support ", promoted_type, ". Falling back to CPU.");
303
+ TORCHVULKAN_FALLBACK("Vulkan device does not support ", promoted_type, ". Falling back to CPU.");
303
304
  return cpu_fallback();
304
305
  }
305
306
 
@@ -6,6 +6,7 @@
6
6
  #include "vulkan/allocator.h"
7
7
  #include "api/ops/helpers.h"
8
8
  #include "api/ops/internal.h"
9
+ #include "api/fallback.h"
9
10
 
10
11
  namespace {
11
12
 
@@ -84,7 +85,7 @@ std::tuple<at::Tensor, at::Tensor> nll_loss_forward_vulkan(
84
85
  TORCH_CHECK(self.dim() == 1 || self.dim() == 2, "torchvulkan [ERROR]: nll_loss only supports 1D (unbatched) or 2D input.");
85
86
 
86
87
  if (!is_dtype_supported(self, self.scalar_type()) || self.numel() > std::numeric_limits<int32_t>::max()) {
87
- TORCH_WARN_ONCE("torchvulkan [WARNING]: Vulkan device does not support ", self.scalar_type(), ". Falling back to CPU.");
88
+ TORCHVULKAN_FALLBACK("Vulkan device does not support ", self.scalar_type(), ". Falling back to CPU.");
88
89
  c10::optional<at::Tensor> cpu_weight = weight.has_value() && weight->defined() ? c10::optional<at::Tensor>(weight->cpu()) : c10::nullopt;
89
90
  auto [cpu_output, cpu_total_weight] = at::nll_loss_forward(self.cpu(), target.cpu(), cpu_weight, reduction, ignore_index);
90
91
  return {cpu_output.to(self.device()), cpu_total_weight.to(self.device())};
@@ -124,7 +125,7 @@ at::Tensor nll_loss_backward_vulkan(
124
125
  TORCH_CHECK(self.dim() == 1 || self.dim() == 2, "torchvulkan [ERROR]: nll_loss only supports 1D (unbatched) or 2D input.");
125
126
 
126
127
  if (!is_dtype_supported(self, self.scalar_type()) || self.numel() > std::numeric_limits<int32_t>::max()) {
127
- TORCH_WARN_ONCE("torchvulkan [WARNING]: Vulkan device does not support ", self.scalar_type(), ". Falling back to CPU.");
128
+ TORCHVULKAN_FALLBACK("Vulkan device does not support ", self.scalar_type(), ". Falling back to CPU.");
128
129
  c10::optional<at::Tensor> cpu_weight = weight.has_value() && weight->defined() ? c10::optional<at::Tensor>(weight->cpu()) : c10::nullopt;
129
130
  at::Tensor cpu_grad_input = at::nll_loss_backward(
130
131
  grad_output.cpu(), self.cpu(), target.cpu(), cpu_weight, reduction, ignore_index, total_weight.cpu());
@@ -9,6 +9,7 @@
9
9
  #include "vulkan/allocator.h"
10
10
  #include "api/ops/helpers.h"
11
11
  #include "api/ops/internal.h"
12
+ #include "api/fallback.h"
12
13
 
13
14
  namespace {
14
15
 
@@ -148,7 +149,7 @@ at::Tensor reduce_dims_vulkan(
148
149
  bool has_subgroup)
149
150
  {
150
151
  if (!is_dtype_supported(self, self.scalar_type()) || self.dim() > MAX_DIMS || !fits_32bit_indexing({self})) {
151
- TORCH_WARN_ONCE("torchvulkan [WARNING]: A ", self.scalar_type(), " reduction of this shape can't run on the Vulkan device. Falling back to CPU.");
152
+ TORCHVULKAN_FALLBACK("A ", self.scalar_type(), " reduction of this shape can't run on the Vulkan device. Falling back to CPU.");
152
153
  return cpu_reduce_fallback(self.cpu(), dims, keepdim, operation).to(self.device());
153
154
  }
154
155
 
@@ -297,6 +298,7 @@ at::Tensor argreduce(
297
298
  }
298
299
 
299
300
  if (!is_dtype_supported(x, x.scalar_type()) || x.dim() == 0 || x.dim() > MAX_DIMS || x.numel() == 0 || !fits_32bit_indexing({x})) {
301
+ TORCHVULKAN_FALLBACK("This ", op == ArgOp::ARGMAX ? "argmax" : "argmin", " on ", x.scalar_type(), " can't run on the Vulkan device. Falling back to CPU.");
300
302
  at::Tensor cpu = op == ArgOp::ARGMAX ? at::argmax(self.cpu(), dim, keepdim) : at::argmin(self.cpu(), dim, keepdim);
301
303
  return cpu.to(self.device());
302
304
  }
@@ -6,6 +6,7 @@
6
6
  #include "vulkan/vulkan_context.h"
7
7
  #include "vulkan/allocator.h"
8
8
  #include "api/ops/helpers.h"
9
+ #include "api/fallback.h"
9
10
 
10
11
  namespace {
11
12
 
@@ -25,6 +26,7 @@ at::Tensor cumscan(
25
26
 
26
27
  int64_t d = c10::maybe_wrap_dim(dim, x.dim());
27
28
  if (!is_dtype_supported(x, compute) || x.dim() > MAX_DIMS || !fits_32bit_indexing({x})) {
29
+ TORCHVULKAN_FALLBACK("A ", compute, " cumulative op of this shape can't run on the Vulkan device. Falling back to CPU.");
28
30
  at::Tensor cpu = op == ScanOp::SUM ? at::cumsum(x.cpu(), d) : op == ScanOp::PROD ? at::cumprod(x.cpu(), d) : at::logcumsumexp(x.cpu(), d);
29
31
  return cpu.to(out_dtype).to(self.device());
30
32
  }
@@ -124,6 +126,7 @@ void cumscanarg(
124
126
  }
125
127
  int64_t d = c10::maybe_wrap_dim(dim, self.dim());
126
128
  if (!is_dtype_supported(self, self.scalar_type()) || self.dim() > MAX_DIMS || !fits_32bit_indexing({self})) {
129
+ TORCHVULKAN_FALLBACK("A ", self.scalar_type(), op == CumArgOp::MAX ? " cummax" : " cummin", " of this shape can't run on the Vulkan device. Falling back to CPU.");
127
130
  auto r = op == CumArgOp::MAX ? at::cummax(self.cpu(), dim) : at::cummin(self.cpu(), dim);
128
131
  values.copy_(std::get<0>(r));
129
132
  indices.copy_(std::get<1>(r));
@@ -7,6 +7,7 @@
7
7
  #include "vulkan/memory.h"
8
8
  #include "vulkan/vulkan_context.h"
9
9
  #include "api/ops/helpers.h"
10
+ #include "api/fallback.h"
10
11
 
11
12
  namespace {
12
13
 
@@ -181,7 +182,7 @@ at::Tensor scatter_along_dim(const at::Tensor& self, int64_t dim, const at::Tens
181
182
  }
182
183
 
183
184
  if (!can_scatter(s, idx.numel())) {
184
- TORCH_WARN_ONCE("torchvulkan [WARNING]: This scatter can't run on the Vulkan device. Falling back to CPU.");
185
+ TORCHVULKAN_FALLBACK("This scatter can't run on the Vulkan device. Falling back to CPU.");
185
186
  at::Tensor cpu = s.cpu().clone();
186
187
  if (mode == ScatterMode::LAST) cpu.scatter_(dim, idx.cpu(), values.cpu());
187
188
  else cpu.scatter_reduce_(dim, idx.cpu(), values.cpu(), mode == ScatterMode::SUM ? "sum" : mode == ScatterMode::PROD ? "prod" : mode == ScatterMode::MEAN ? "mean" : mode == ScatterMode::AMAX ? "amax" : "amin", include_self);