Skip to content

Vulkan: register the missing logical_not runtime op - #22786

Closed
msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/vulkan-logical-not
Closed

msluszniak wants to merge 2 commits into
pytorch:mainfrom
msluszniak:ms/vulkan-logical-not

Conversation

@msluszniak

Copy link
Copy Markdown
Contributor

aten.logical_not.default is in the partitioner's supported set but has no VK_REGISTER_OP anywhere under runtime/. It partitions into a delegate subgraph and the resulting .pte then aborts at load, so a model that reaches it is unrunnable rather than merely slow. An RF-DETR segmentation export hits it 32 times through the decoder's attention-mask logic.

aten.bitwise_not.default and aten.logical_not.default are both registered for boolean tensors only, where the two are the same operation, so the existing kernel covers it. logical_and and logical_or already reuse their bitwise counterparts in BinaryOp.cpp the same way; logical_not was the one left out.

Verified on a Mali-G76 (Galaxy S10+) with a minimal gt.Scalar -> logical_not -> where model that lowers to a single Vulkan subgraph:

runner result
before assert failed (VK_HAS_OP(op_name)): Missing operator: aten.logical_not.default, exit 134
after matches eager elementwise, exit 0

The boolean ops had no delegate test at all, which is how this went unnoticed. Adds one for logical_not, selecting through the mask because a boolean output cannot go through torch.allclose.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

@msluszniak
msluszniak requested a review from SS-JIA as a code owner September 13, 2026 21:17
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Sep 13, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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:

❌ 1 Awaiting Approval, 2 New Failures

As of commit 81d875d with merge base 161fbd5 (image):

AWAITING APPROVAL - The following workflow needs approval before CI can run:

NEW FAILURES - The following jobs have failed:

  • Build documentation / build (buck2) / Build doc (gh)
    Could not load credentials from any providers
  • Cadence Build & Test / Resolve CI docker image / resolve (gh)
    ##[error]Refusing to check out fork pull request code from a 'pull_request_target' workflow. This workflow runs with the base repository's GITHUB_TOKEN, secrets, default-branch cache scope, and runner access. Fetching and executing a fork's code in that trusted context commonly leads to "pwn request" vulnerabilities. To opt in, review the risks at https://gh.io/securely-using-pull_request_target and set 'allow-unsafe-pr-checkout: true' on the actions/checkout step.

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 Sep 13, 2026
Comment thread backends/vulkan/runtime/graph/ops/impl/UnaryOp.cpp Outdated
@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.

msluszniak and others added 2 commits September 17, 2026 17:33
`aten.logical_not.default` is in the partitioner's supported set but has no
`VK_REGISTER_OP` anywhere under `runtime/`, so it partitions into a delegate
subgraph and the resulting `.pte` aborts at load with a missing operator error.
Any model that reaches it is unrunnable rather than merely slow, which is worse
than not claiming the op at all: an RF-DETR segmentation export hits it 32 times
through the decoder's attention-mask logic.

Both `aten.bitwise_not.default` and `aten.logical_not.default` are registered
for boolean tensors only, where the two are the same operation, so the existing
kernel covers it. `logical_and` and `logical_or` already reuse their bitwise
counterparts in BinaryOp.cpp the same way; `logical_not` was the one left out.

The boolean ops had no delegate test at all, which is how this went unnoticed.
Adds one for logical_not, selecting through the mask because a boolean output
cannot go through torch.allclose.

(cherry picked from commit 2d09bb1)
@msluszniak
msluszniak force-pushed the ms/vulkan-logical-not branch from 84e19e9 to 81d875d Compare September 17, 2026 15:35
@psiddh

psiddh commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

The motivation is good, but we should be careful here not breaking any existing contract and assumptions (as this PR touches the Android native runtime contract.) I imported this internally as D119925752 and I’m seeing multiple CI failures. Digging into it more until we establish clearunderstanding whether these are default-path regressions or only split-backend-mode failures.

@executorch-triage executorch-triage Bot added the community: contribution PRs coming from community (excluding hardware partners) label Sep 22, 2026
mergennachin added a commit that referenced this pull request Oct 5, 2026
…l_not (#23246)

is_bitw8 did not include kBool, so bool staging required 8-bit storage
buffers even for texture tensors. It now takes the bitw8 path.
VulkanBackend::init rejects graphs with non-constant bool buffers with
NotSupported on devices without 8-bit storage buffers, and destroys the
partially built graph on any init error. aten.logical_not was already
accepted by the partitioner but had no runtime registration; it now maps
to the uint8 bitwise_not kernel.

Part 7/15 of the Vulkan transformer and operator-conformance stack.
#23245 has landed; this is now the bottom PR, reviewed directly against
main. Integration PR: #23254. Related logical_not registration: #22786.

Prior native validation: 2 passed and one expected skip on MoltenVK with
portable CPU kernels.

Rebased onto main at `91d26b314053`, including the upstream Adreno UBO
indexing fix. The code patch is unchanged. The complete shader set
compiles, all 15 graph-builder/serialization tests pass, and lintrunner
and git diff --check pass. Hardware and SwiftShader CI will rerun on the
rebased stack.

Recreates #23207 through ghstack. Prior review discussion remains on
that PR.

Authored with OpenAI Codex; split planned with Claude Code.


cc @SS-JIA @manuelcandales @digantdesai @cbilgin
@SS-JIA

SS-JIA commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Hi @msluszniak — #23246 has merged and appears to supersede this implementation. It includes the same aten.logical_not.default registration plus broader bool staging and unsupported-device handling.

Could you double-check whether anything from this PR is still missing on main? If not, can this PR be closed as superseded by #23246? The Mali/RF-DETR validation here remains useful context.

Bot note: This message was drafted by an AI review bot for the reviewer.

@msluszniak

Copy link
Copy Markdown
Contributor Author

Agreed, closing as superseded by #23246.

@msluszniak msluszniak closed this Oct 7, 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. community: contribution PRs coming from community (excluding hardware partners) 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.

4 participants