Skip to content

[ET-VK][build] Fix Windows Vulkan/Android build and llama ETDump profiling#21148

Merged
SS-JIA merged 1 commit into
mainfrom
etvk-windows-build-fixes
Jul 23, 2026
Merged

[ET-VK][build] Fix Windows Vulkan/Android build and llama ETDump profiling#21148
SS-JIA merged 1 commit into
mainfrom
etvk-windows-build-fixes

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Three additive, backward-compatible fixes needed to build the ExecuTorch Vulkan backend and profile the llama runner from a Windows host. Each change is guarded so it is a no-op on non-Windows / non-profiling builds.

Fixes

  • backends/vulkan/runtime/gen_vulkan_spv.py — normalize CRLF to LF at the top of preprocess(), before the trailing-backslash macro-continuation regex runs. GLSL templates checked out with CRLF line endings otherwise leave a lone backslash that escape() turns into an unterminated Python string literal (SyntaxError: unterminated string literal) during shader codegen.

  • third-party/CMakeLists.txt — allow importing a prebuilt host flatc/flatcc via FLATC_EXECUTABLE / FLATCC_EXECUTABLE instead of building them from source. The existing WIN32 host-tool build only supports the Visual Studio generator (VS-only CMAKE_GENERATOR_PLATFORM, .exe-less BUILD_BYPRODUCTS), which fails under the Ninja generator required by the Android NDK cross-compile.

  • examples/models/llama/CMakeLists.txt — link etdump and define ET_EVENT_TRACER_ENABLED when the etdump target exists (i.e. core libs built with EXECUTORCH_BUILD_DEVTOOLS=ON + EXECUTORCH_ENABLE_EVENT_TRACER=ON). This enables ETDump collection and makes the Vulkan delegate emit per-dispatch GPU timestamps for per-shader profiling.

All three changes are additive and guarded, so they are no-ops on non-Windows hosts and on non-profiling builds.

Test plan

Cross-compiled ExecuTorch core libs + llama_main for Android arm64 with the Vulkan backend enabled from a Windows host (NDK r29, Ninja generator, imported host flatc/flatcc). Confirmed libvulkan_backend.a is linked and llama_main runs on a Galaxy S24 (Adreno 750): Qwen3 0.6B ~80 tok/s decode, Llama 3.2 1B 8da4w ~60 tok/s decode. With DEVTOOLS/EVENT_TRACER on, collected an ETDump containing per-shader Vulkan events and analyzed the prefill/decode breakdown via custom_inspector.py --mode llm.

This PR was authored with Claude Code.

🤖 Generated with Claude Code

cc @manuelcandales @digantdesai @cbilgin

…iling

Summary:

Three additive, backward-compatible fixes needed to build the ExecuTorch Vulkan
backend and profile the llama runner from a Windows host. Each is guarded so it
is a no-op on non-Windows / non-profiling builds.

- backends/vulkan/runtime/gen_vulkan_spv.py: normalize CRLF -> LF at the top of
  preprocess() before the trailing-backslash macro-continuation regex. GLSL
  templates checked out with CRLF otherwise leave a lone backslash that escape()
  turns into an unterminated Python string literal
  ("SyntaxError: unterminated string literal") during shader codegen.

- third-party/CMakeLists.txt: allow importing a prebuilt host flatc/flatcc via
  FLATC_EXECUTABLE / FLATCC_EXECUTABLE instead of building them from source. The
  existing WIN32 host-tool build only supports the Visual Studio generator
  (VS-only CMAKE_GENERATOR_PLATFORM, .exe-less BUILD_BYPRODUCTS), which fails
  under the Ninja generator required by the Android NDK cross-compile.

- examples/models/llama/CMakeLists.txt: link etdump and define
  ET_EVENT_TRACER_ENABLED when the etdump target exists (i.e. core libs built
  with EXECUTORCH_BUILD_DEVTOOLS=ON + EXECUTORCH_ENABLE_EVENT_TRACER=ON). This
  enables ETDump collection and makes the Vulkan delegate emit per-dispatch GPU
  timestamps for per-shader profiling.

Test Plan:

Cross-compiled ExecuTorch core libs + llama_main for Android arm64 with the
Vulkan backend enabled from a Windows host (NDK r29, Ninja generator, imported
host flatc/flatcc). Confirmed libvulkan_backend.a is linked and llama_main runs
on a Galaxy S24 (Adreno 750): Qwen3 0.6B ~80 tok/s decode, Llama 3.2 1B 8da4w
~60 tok/s decode. With DEVTOOLS/EVENT_TRACER on, collected an ETDump containing
per-shader Vulkan events and analyzed prefill/decode breakdown via
custom_inspector.py --mode llm.

Reviewers:

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Jul 22, 2026
@pytorch-bot

pytorch-bot Bot commented Jul 22, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21148

Note: Links to docs will display an error until the docs builds have been completed.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

✅ No Failures

As of commit f4a0e68 with merge base 86c3470 (image):
💚 Looks good so far! There are no failures yet. 💚

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 22, 2026
@github-actions

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@SS-JIA
SS-JIA merged commit 9df506e into main Jul 23, 2026
219 of 224 checks passed
@SS-JIA
SS-JIA deleted the etvk-windows-build-fixes branch July 23, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants