Skip to content

Vulkan: fix the shared-device test and Windows builds after #23151 - #24843

Merged
SS-JIA merged 1 commit into
pytorch:mainfrom
SS-JIA:export-D130716215
Nov 10, 2026
Merged

SS-JIA merged 1 commit into
pytorch:mainfrom
SS-JIA:export-D130716215

Conversation

@SS-JIA

@SS-JIA SS-JIA commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary:
#23151 broke several Buck builds:

vulkan_shared_device_test compares Vulkan queue handles with VK_NULL_HANDLE, which some Vulkan headers define as 0, so gtest compares a pointer with an int and the test does not compile. Compare with nullptr.

The _no_volk variants of that test link libvulkan, which the Linux, Android and Apple test hosts do not have. Keep only the volk variant.

vulkan_compute_api exported vulkan_shared:runtime, which pulls in the ExecuTorch runtime. A Windows binary that links the compute API with link_style = "shared" then builds portable_type as a DLL, which fails to link. The compute API only needs SharedVulkanDevice, so move it into its own vulkan_shared:device target with no runtime deps and export that instead.

On Windows, callers declared the shared API dllimport, so a binary that links the static build of the library cannot resolve it. Drop dllimport for callers; a plain declaration links against both the import library and the static library.

Authored with Metamate (agentcloud).

Reviewed By: shoumikhin

Differential Revision: D130716215

cc @manuelcandales @digantdesai @cbilgin

…3151

Summary:
pytorch#23151 broke several Buck builds:

`vulkan_shared_device_test` compares Vulkan queue handles with `VK_NULL_HANDLE`, which some Vulkan headers define as `0`, so gtest compares a pointer with an int and the test does not compile. Compare with `nullptr`.

The `_no_volk` variants of that test link `libvulkan`, which the Linux, Android and Apple test hosts do not have. Keep only the volk variant.

`vulkan_compute_api` exported `vulkan_shared:runtime`, which pulls in the ExecuTorch runtime. A Windows binary that links the compute API with `link_style = "shared"` then builds `portable_type` as a DLL, which fails to link. The compute API only needs `SharedVulkanDevice`, so move it into its own `vulkan_shared:device` target with no runtime deps and export that instead.

On Windows, callers declared the shared API `dllimport`, so a binary that links the static build of the library cannot resolve it. Drop `dllimport` for callers; a plain declaration links against both the import library and the static library.

Authored with Metamate (agentcloud).

Reviewed By: shoumikhin

Differential Revision: D130716215
Copilot AI balanced review requested due to automatic review settings November 10, 2026 15:36
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Nov 10, 2026
@pytorch-bot

pytorch-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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

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 Nov 10, 2026
@meta-codesync

meta-codesync Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

@SS-JIA has exported this pull request. If you are a Meta employee, you can view the originating Diff in D130716215.

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The Windows static/shared-linking fix requires native Buck validation of exports across the newly separated device and runtime libraries, but the internal Buck wrapper and Windows toolchain are unavailable in this review snapshot.

No open issues 🎉

What changed in this PR

This PR addresses Buck build regressions introduced by #23151’s shared Vulkan context integration, covering test compilation, dependency isolation, and Windows linking.

Changes:

  • Use nullptr for queue-handle assertions and retain only the volk-based shared-device test.
  • Split SharedVulkanDevice into a runtime-independent target for the Vulkan compute API.
  • Remove Windows caller-side dllimport to support both static and import-library linking.
File Description
backends/​vulkan/​test/​shared_device/​SharedDeviceAdapterTest.cpp Replace null-handle assertion operands with nullptr.
backends/​vulkan/​targets.bzl Export the device-only dependency and remove the no-volk test variant.
backends/​vulkan_shared/​targets.bzl Separate the shared device from runtime-dependent components.
backends/​vulkan_shared/​runtime/​export.h Use plain API declarations for Windows callers.

Review effort: Balanced

@SS-JIA
SS-JIA merged commit 4529a94 into pytorch:main Nov 10, 2026
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. meta-exported 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.

3 participants