Skip to content

[ET-VK] Add nchw_to_int8x4_buffer shader for prepacking int8 staging data#17448

Merged
SS-JIA merged 3 commits into
gh/SS-JIA/422/origfrom
gh/SS-JIA/423/orig
Feb 13, 2026
Merged

[ET-VK] Add nchw_to_int8x4_buffer shader for prepacking int8 staging data#17448
SS-JIA merged 3 commits into
gh/SS-JIA/422/origfrom
gh/SS-JIA/423/orig

Conversation

@pytorchbot

Copy link
Copy Markdown
Collaborator

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #17392 by @SS-JIA
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/423/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/423/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/SS-JIA/422/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/SS-JIA/423/orig
Differential Revision: D93000169
@diff-train-skip-merge

…data

Pull Request resolved: #17392

This adds a GLSL compute shader and supporting C++ dispatch logic to transfer
int8 tensor data from a staging buffer (in NCHW contiguous order) to a GPU
buffer in any PackedInt8 layout (4W, 4C, 4W4C, 4H4W, 4C1W).

Previously there was no prepack path for kInt8x4 tensors, so constant int8
tensors (TensorRef inputs) could not be transferred to GPU buffers. This is
needed to support constant quantized weights in q8ta operators.

The shader uses texel-level dispatch where each thread writes one texel (one
int32 = 4 packed int8 values). It decomposes the texel index into block-space
coordinates using BufferMetadata strides and hashed_layout dim_order, then reads
the corresponding int8 bytes from the staging buffer (interpreted as int32 for
device compatibility, avoiding the need for 8-bit buffer support).

New files:
- nchw_to_int8x4_buffer.glsl: Compute shader handling all PackedInt8 layouts
- nchw_to_int8x4_buffer.yaml: Shader variant config
- Q8taStaging.h/cpp: C++ dispatch function creating the PrepackNode

Modified files:
- Staging.cpp: Routes kInt8x4 tensors in prepack_op() to the new function
- TestQ8taBinary.cpp: Prepacks TensorRef inputs before quantization
- test_q8ta_binary.cpp: Adds const_b test cases for constant tensor B inputs

This diff was authored with Claude.
ghstack-source-id: 341022576
@exported-using-ghexport

Differential Revision: [D93000169](https://our.internmc.facebook.com/intern/diff/D93000169/)
@pytorchbot pytorchbot requested a review from SS-JIA as a code owner February 13, 2026 16:14
@pytorch-bot

pytorch-bot Bot commented Feb 13, 2026

Copy link
Copy Markdown

🔗 Helpful Links

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

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 Feb 13, 2026
ssjia added 2 commits February 13, 2026 12:38
Pull Request resolved: #17393

This removes the dynamic dispatch logic in q8ta_conv2d() that selected between the im2col and general convolution paths. The function now unconditionally uses q8ta_conv2d_general(). This simplifies the dispatch since the im2col path selection will be handled upstream by the pattern matcher routing to specialized ops (q8ta_conv2d_pw, q8ta_conv2d_dw, etc.) instead of being decided at runtime.
ghstack-source-id: 341022577
@exported-using-ghexport

Differential Revision: [D93000164](https://our.internmc.facebook.com/intern/diff/D93000164/)
Pull Request resolved: #17394

This adds fine-grained ET_EVENT_TRACER profiling blocks to the Vulkan backend's execute() method in VulkanBackend.cpp. Previously, only GPU shader timestamps were logged. Now the following phases are individually traced: ETVK_COPY_INPUTS (host-to-GPU input transfer), ETVK_RESIZE (graph resize propagation), ETVK_COMPUTE_GRAPH_EXECUTE (GPU compute dispatch), ETVK_COPY_OUTPUTS (GPU-to-host output transfer), and ETVK_EXECUTE (overall delegate execution). The GPU shader timestamp extraction is also moved to occur right after execute() completes rather than at the end of the function, so it falls within the ETVK_EXECUTE span.
ghstack-source-id: 341022578
@exported-using-ghexport

Differential Revision: [D93000163](https://our.internmc.facebook.com/intern/diff/D93000163/)
@SS-JIA SS-JIA merged commit 97926c3 into gh/SS-JIA/422/orig Feb 13, 2026
62 of 64 checks passed
@SS-JIA SS-JIA deleted the gh/SS-JIA/423/orig branch February 13, 2026 17:38
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants