Skip to content

Conversation

@mohammed-saalim
Copy link
Contributor

Summary
Adds missing float to int32 conversion support in the Vulkan backend's view_convert_buffer shader.

Problem
When exporting models that require float-to-int32 dtype conversion to the Vulkan backend, execution fails at runtime with:

Exception raised from get_shader_info at /pytorch/executorch/backends/vulkan/runtime/api/ShaderRegistry.cpp:54:
(it != listings_.end()) is false! Could not find ShaderInfo with name view_convert_buffer_float_int32
This occurs because the view_convert_buffer shader only supports conversions FROM int32/uint8 TO float/half, but not the reverse direction.

Solution
Added float → int32 conversion variant to the shader generation configuration in
view_convert_buffer.yaml
.

Changed file:

backends/vulkan/runtime/graph/ops/glsl/view_convert_buffer.yaml
Change:

yaml
combos:

  • parameter_values: [int32, float]
  • parameter_values: [int32, half]
  • parameter_values: [uint8, float]
  • parameter_values: [uint8, half]
  • parameter_values: [uint8, int32]
  • parameter_values: [float, int32] # <-- Added
    Testing
    Unable to test on Windows due to build environment constraints (requires CMake + MSVC). The change follows the existing pattern for other dtype conversion combinations in the same file.

Test case that would trigger this:

Models with operations requiring float→int32 conversion (e.g., certain quantization or indexing operations)
Export to Vulkan backend using VulkanPartitioner
Additional Context
This issue was encountered while exporting a depth estimation model (PanDA) to the Vulkan backend for Android deployment. The model worked with XNNPACK but failed with Vulkan due to this missing shader variant.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

Copilot AI review requested due to automatic review settings February 11, 2026 19:06
@pytorch-bot pytorch-bot bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Feb 11, 2026
@pytorch-bot
Copy link

pytorch-bot bot commented Feb 11, 2026

🔗 Helpful Links

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

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

❌ 2 New Failures, 1 Unrelated Failure

As of commit 0534658 with merge base eb888f8 (image):

NEW FAILURES - The following jobs have failed:

BROKEN TRUNK - The following job failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

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 Feb 11, 2026
Adds missing float to int32 conversion support in the Vulkan backend's view_convert_buffer shader. This fixes runtime errors when models require float to int32 dtype conversions.

Fixes ShaderInfo not found error for 'view_convert_buffer_float_int32'
@mohammed-saalim mohammed-saalim force-pushed the add-float-int32-vulkan-shader branch from 7ded14f to 0534658 Compare February 11, 2026 19:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds the missing float -> int32 shader variant for the Vulkan backend’s view_convert_buffer op so models requiring that dtype conversion no longer fail at runtime due to an unregistered shader name.

Changes:

  • Add float,int32 to the generated shader combination list for view_convert_buffer.
  • Remove an editable-install warning block from the “building from source” docs.

Reviewed changes

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

File Description
docs/source/using-executorch-building-from-source.md Removes an editable-install warning/workaround block from the build-from-source guide.
backends/vulkan/runtime/graph/ops/glsl/view_convert_buffer.yaml Adds the float -> int32 combo so view_convert_buffer_float_int32 gets generated/registered.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- parameter_values: [uint8, float]
- parameter_values: [uint8, half]
- parameter_values: [uint8, int32]
- parameter_values: [float, int32]
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

Adding the float→int32 combo makes view_convert_buffer perform a direct GLSL cast from float to int (OUT_T(t_inp[...]) where OUT_T becomes int). In GLSL, float-to-int conversion is undefined/unspecified for NaNs and for values outside the representable int32 range, which can lead to non-deterministic results. Consider updating the shader logic for this combo to explicitly define behavior (e.g., clamp to int32 min/max before casting and decide how to handle NaNs), so the new variant is robust and matches the expected runtime semantics.

Suggested change
- parameter_values: [float, int32]

Copilot uses AI. Check for mistakes.
- parameter_values: [uint8, float]
- parameter_values: [uint8, half]
- parameter_values: [uint8, int32]
- parameter_values: [float, int32]
Copy link

Copilot AI Feb 11, 2026

Choose a reason for hiding this comment

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

This change fixes a runtime crash path (missing shader variant), but there doesn’t appear to be a Vulkan test that exercises float→int32 view/copy conversion. Adding a small unit/integration test that runs a minimal graph/model requiring float→int32 conversion and validates output (and/or that the shader is present in the registry) would help prevent regressions.

Copilot uses AI. Check for mistakes.
@mohammed-saalim
Copy link
Contributor Author

@pytorchbot label "release notes: vulkan"

@pytorch-bot pytorch-bot bot added the release notes: vulkan Changes to the Vulkan backend delegate label Feb 11, 2026
@SS-JIA SS-JIA merged commit 89fbdd6 into pytorch:main Feb 12, 2026
151 of 154 checks passed
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/ release notes: vulkan Changes to the Vulkan backend delegate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants