Skip to content

Commit 359ac31

Browse files
authored
Arm backend: update Vulkan SDK setup for newer glslc (pytorch#20023)
update Vulkan SDK setup for newer glslc, which fixes testing time shader compiles where the system had an old glslc (and revises the version used in our test scripts) Also mark custom shader tests as vgf so they run in just the VGF or general testing, not in e.g. baremetal. cc @SS-JIA @manuelcandales @digantdesai @cbilgin @freddan80 @per @zingo @oscarandersson8218 @mansnils @Sebastian-Larsson @rascani --------- Signed-off-by: Rob Elliott <Robert.Elliott@arm.com>
1 parent 44a91bf commit 359ac31

7 files changed

Lines changed: 28 additions & 25 deletions

File tree

backends/arm/scripts/docgen/vgf/vgf-getting-started-tutorial.md.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ In this tutorial you have learned how to use ExecuTorch to export a PyTorch mode
135135

136136
Issue: glslc is not found when configuring the executor runner.
137137
Solution: The Vulkan sdk is likely not in your path, check whether setup_path.sh contains something like
138-
`export PATH=$(pwd)/examples/arm/arm-scratch/vulkan_sdk/1.4.321.1/x86_64/bin:$PATH`.
138+
`export PATH=$(pwd)/examples/arm/arm-scratch/vulkan_sdk/1.4.341.1/x86_64/bin:$PATH`.
139139
If not, add it and source the file.
140140

141141
If you encountered any bugs or issues following this tutorial please file a bug/issue here on [Github](https://github.com/pytorch/executorch/issues/new).

backends/arm/scripts/vulkan_utils.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,30 @@ fi
1717
script_dir=$(cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd)
1818
source "${script_dir}/utils.sh"
1919

20-
vulkan_sdk_version="1.4.321.1"
20+
vulkan_sdk_version=""
2121
vulkan_sdk_base_dir="vulkan_sdk"
2222

2323
os_name="${OS:-$(uname -s)}"
2424
vulkan_sdk_arch="${ARCH}"
2525

26-
# Vulkan SDK selection differs between macOS and Linux; macOS has its own SDK version
26+
# macOS and Linux x86_64 use the official LunarG SDK tarballs. Linux ARM64
27+
# uses a separately repackaged mirror of the same SDK version.
2728
if [[ "${os_name}" == "Darwin" ]]; then
28-
# Latest published macOS SDK is 1.4.321.0 (1.4.321.1 is not available for macOS)
29-
vulkan_sdk_version="1.4.321.0"
29+
vulkan_sdk_version="1.4.341.1"
3030
vulkan_sdk_arch="macOS"
3131
vulkan_sdk_url="https://sdk.lunarg.com/sdk/download/${vulkan_sdk_version}/mac/vulkansdk-macos-${vulkan_sdk_version}.zip"
32-
vulkan_sdk_sha256="d873c43acacec1e3330fb530dafd541aa5d8a5726575a98a3f70ca505fc203db"
32+
vulkan_sdk_sha256="632cbe96c8ed6ed00c6ce25e3a7738c466134f76586e1c51f1419410d7f9042e"
3333
elif [[ "${os_name}" == "Linux" ]] && [[ "${ARCH}" == "x86_64" ]]; then
34+
vulkan_sdk_version="1.4.341.1"
3435
vulkan_sdk_url="https://sdk.lunarg.com/sdk/download/${vulkan_sdk_version}/linux/vulkansdk-linux-x86_64-${vulkan_sdk_version}.tar.xz"
35-
vulkan_sdk_sha256="f22a3625bd4d7a32e7a0d926ace16d5278c149e938dac63cecc00537626cbf73"
36+
vulkan_sdk_sha256="3bf0f762afb6c79bc6a9d9fb5998745ccff928800a29619b501ed9de7fd9789b"
3637
elif [[ "${os_name}" == "Linux" ]] && ([[ "${ARCH}" == "aarch64" ]] || [[ "${ARCH}" == "arm64" ]]); then
38+
vulkan_sdk_version="1.4.341.1"
3739
if [[ "${vulkan_sdk_arch}" == "arm64" ]]; then
3840
vulkan_sdk_arch="aarch64"
3941
fi
40-
vulkan_sdk_url="https://github.com/jakoch/vulkan-sdk-arm/releases/download/1.4.321.1/vulkansdk-ubuntu-22.04-arm-1.4.321.1.tar.xz"
41-
vulkan_sdk_sha256="c57e318d0940394d3a304034bb7ddabda788b5b0b54638e80e90f7264efe9f84"
42+
vulkan_sdk_url="https://github.com/jakoch/vulkan-sdk-arm/releases/download/${vulkan_sdk_version}/vulkansdk-ubuntu-22.04-arm-${vulkan_sdk_version}.tar.xz"
43+
vulkan_sdk_sha256="345312aee2c835e128b30653278593f899a659a7ba287c571cafb22acb708b8f"
4244
else
4345
log_step "vulkan" "Error: only macOS and Linux are supported (detected ${os_name}); architecture must be x86-64 or aarch64/arm64"
4446
exit 1
@@ -164,7 +166,8 @@ function setup_path_vulkan() {
164166
vulkan_sdk_arch_root="$(cd "${vulkan_sdk_arch_root}" && pwd)"
165167
vulkan_sdk_bin_path="$(cd "${vulkan_sdk_bin_dir}" && pwd)"
166168

167-
append_env_in_setup_path PATH "${vulkan_sdk_bin_path}"
169+
# Prefer the SDK-provided compiler over any host-installed glslc.
170+
prepend_env_in_setup_path PATH "${vulkan_sdk_bin_path}"
168171
if [[ "${OS:-}" == "Darwin" ]]; then
169172
prepend_env_in_setup_path DYLD_LIBRARY_PATH "${vulkan_sdk_arch_root}/lib"
170173
local moltenvk_icd_path="${vulkan_sdk_arch_root}/share/vulkan/icd.d/MoltenVK_icd.json"

backends/arm/test/misc/test_custom_shader_payloads.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def _decode_sampler_payload(
100100

101101
# Covers basic payload encoding and decoding for shader metadata.
102102
# Checks bindings, workgroup sizes, language, and formats are preserved.
103-
def test_buffer_shader_payload_encodes_bindings_and_formats():
103+
def test_buffer_shader_payload_vgf_encodes_bindings_and_formats():
104104
payload = decode_payload(
105105
encode_payload(
106106
build_grid_sampler_2d_payload(
@@ -124,7 +124,7 @@ def test_buffer_shader_payload_encodes_bindings_and_formats():
124124

125125
# Covers sampler-specific payload fields for sampled image inputs.
126126
# Checks filter, address mode, and border color are encoded in the payload.
127-
def test_sampler_shader_payload_encodes_sampler_fields():
127+
def test_sampler_shader_payload_vgf_encodes_sampler_fields():
128128
payload = _decode_sampler_payload()
129129

130130
assert (
@@ -145,7 +145,7 @@ def test_sampler_shader_payload_encodes_sampler_fields():
145145

146146
# Covers the local shader asset contract used by the tests.
147147
# Checks the expected GLSL/SPIR-V asset names and that the SPIR-V bytes look valid.
148-
def test_shader_payload_uses_expected_glsl_and_spirv_asset():
148+
def test_shader_payload_vgf_uses_expected_glsl_and_spirv_asset():
149149
buffer_payload = build_grid_sampler_2d_payload(
150150
interpolation_mode=0,
151151
padding_mode=0,
@@ -160,7 +160,7 @@ def test_shader_payload_uses_expected_glsl_and_spirv_asset():
160160

161161
# Covers validation of unsupported shader option values.
162162
# Checks invalid mode and padding_mode values raise instead of encoding silently.
163-
def test_shader_payload_rejects_invalid_mode_values():
163+
def test_shader_payload_vgf_rejects_invalid_mode_values():
164164
with pytest.raises(RuntimeError, match="Unsupported grid_sample mode"):
165165
_decode_sampler_payload(mode="garbage")
166166

@@ -170,7 +170,7 @@ def test_shader_payload_rejects_invalid_mode_values():
170170

171171
# Covers storage-image outputs, which should not carry sampler state.
172172
# Checks output payloads omit sampler metadata for storage images.
173-
def test_storage_image_payload_does_not_require_sampler_fields():
173+
def test_storage_image_payload_vgf_does_not_require_sampler_fields():
174174
payload = _decode_sampler_payload()
175175

176176
assert payload["output_0_vkdescriptortype"] == "VK_DESCRIPTOR_TYPE_STORAGE_IMAGE"

backends/arm/test/ops/test_custom_shader_lowering.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def forward(self, x: torch.Tensor, grid: torch.Tensor) -> torch.Tensor:
7979

8080
# Covers lowering of a standalone custom op to a buffer-backed tosa.CUSTOM.
8181
# Checks the emitted custom node carries the expected operator, domain, and buffer descriptors.
82-
def test_new_custom_op_lowers_to_tosa_custom_buffer_shader():
82+
def test_new_custom_op_vgf_lowers_to_tosa_custom_buffer_shader():
8383
if shutil.which("glslc") is None:
8484
pytest.skip("glslc not found")
8585
register_test_threes_library_ops()
@@ -105,7 +105,7 @@ def test_new_custom_op_lowers_to_tosa_custom_buffer_shader():
105105

106106
# Covers replacing aten.add with a shader-backed custom op.
107107
# Checks the rewritten node lowers to tosa.CUSTOM with storage-buffer descriptors.
108-
def test_replacement_op_lowers_to_tosa_custom_shader():
108+
def test_replacement_op_vgf_lowers_to_tosa_custom_shader():
109109
if shutil.which("glslc") is None:
110110
pytest.skip("glslc not found")
111111
register_test_shader_library_ops()
@@ -132,7 +132,7 @@ def test_replacement_op_lowers_to_tosa_custom_shader():
132132

133133
# Covers the in-tree grid-sampler rewrite path.
134134
# Checks grid_sampler_2d.default lowers to tosa.CUSTOM with the Vulkan shader domain.
135-
def test_in_tree_grid_sampler_lowers_to_tosa_custom():
135+
def test_in_tree_grid_sampler_vgf_lowers_to_tosa_custom():
136136
edge_model = to_edge(
137137
export(_GridSampleModule(), (torch.randn(1, 3, 8, 8), torch.randn(1, 4, 4, 2)))
138138
)
@@ -155,7 +155,7 @@ def test_in_tree_grid_sampler_lowers_to_tosa_custom():
155155

156156
# Covers sampler/image descriptor selection during lowering.
157157
# Checks the lowered payload uses combined-image-sampler input, tensor grid input, and storage-image output.
158-
def test_sampler_shader_lowering_emits_expected_descriptor_types():
158+
def test_sampler_shader_vgf_lowering_emits_expected_descriptor_types():
159159
if shutil.which("glslc") is None:
160160
pytest.skip("glslc not found")
161161
register_test_shader_library_ops()
@@ -188,7 +188,7 @@ def test_sampler_shader_lowering_emits_expected_descriptor_types():
188188
assert payload["output_0_vkdescriptortype"] == "VK_DESCRIPTOR_TYPE_STORAGE_IMAGE"
189189

190190

191-
def test_grid_read_shader_lowering_uses_distinct_custom_operator():
191+
def test_grid_read_shader_vgf_lowering_uses_distinct_custom_operator():
192192
if shutil.which("glslc") is None:
193193
pytest.skip("glslc not found")
194194
register_test_shader_library_ops()
@@ -212,7 +212,7 @@ def test_grid_read_shader_lowering_uses_distinct_custom_operator():
212212
assert custom_node.kwargs["operator_name"] == TEST_GRID_READ_TENSOR_OPERATOR
213213

214214

215-
def test_sampler_shader_lowering_rejects_three_channel_image_payload():
215+
def test_sampler_shader_vgf_lowering_rejects_three_channel_image_payload():
216216
if shutil.which("glslc") is None:
217217
pytest.skip("glslc not found")
218218
register_test_shader_library_ops()
@@ -237,7 +237,7 @@ def test_sampler_shader_lowering_rejects_three_channel_image_payload():
237237

238238
# Covers decoding of implementation_attrs after lowering.
239239
# Checks the payload exposes the expected entry point and binding numbering.
240-
def test_shader_lowering_decodes_expected_implementation_attrs():
240+
def test_shader_lowering_vgf_decodes_expected_implementation_attrs():
241241
edge_model = to_edge(
242242
export(_GridSampleModule(), (torch.randn(1, 3, 8, 8), torch.randn(1, 4, 4, 2)))
243243
)

backends/arm/test/passes/test_rewrite_grid_sampler_to_tosa_custom_pass.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def forward(self, x, grid):
4444
)
4545

4646

47-
def test_rewrite_grid_sampler_to_tosa_custom_no_target():
47+
def test_rewrite_grid_sampler_to_tosa_custom_vgf_no_target():
4848
model = GridSampler2d()
4949
example_inputs = (
5050
torch.randn(1, 3, 8, 8),

backends/vulkan/cmake/ShaderLibrary.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if(NOT GLSLC_PATH AND EXECUTORCH_BUILD_VULKAN)
3030
message(
3131
FATAL_ERROR
3232
"glslc from the Vulkan SDK must be installed to build the Vulkan backend. "
33-
"Please install the Vulkan SDK 1.4.321.0 or newer from "
33+
"Please install the Vulkan SDK 1.4.341.1 or newer from "
3434
"https://vulkan.lunarg.com/sdk/home and ensure that the glslc binary is in your PATH. "
3535
"Note that the glslc distributed with the Android NDK is not compatible since it "
3636
"does not support the GL_EXT_integer_dot_product extension. "

docs/source/backends/arm-vgf/tutorials/vgf-getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ In this tutorial you have learned how to use ExecuTorch to export a PyTorch mode
219219

220220
Issue: glslc is not found when configuring the executor runner.
221221
Solution: The Vulkan sdk is likely not in your path, check whether setup_path.sh contains something like
222-
`export PATH=$(pwd)/examples/arm/arm-scratch/vulkan_sdk/1.4.321.1/x86_64/bin:$PATH`.
222+
`export PATH=$(pwd)/examples/arm/arm-scratch/vulkan_sdk/1.4.341.1/x86_64/bin:$PATH`.
223223
If not, add it and source the file.
224224

225225
If you encountered any bugs or issues following this tutorial please file a bug/issue here on [Github](https://github.com/pytorch/executorch/issues/new).

0 commit comments

Comments
 (0)