Skip to content

Support int8 texture tensors without requiring int8 buffers #4485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

SS-JIA
Copy link
Contributor

@SS-JIA SS-JIA commented Jul 31, 2024

Summary:

Context

By default, storage buffers in Vulkan must contain 32 bit data types; using 8 bit and 16 bit data types in buffers can be enabled optionally by supporting the VK_KHR_8bit_storage extension or the VK_KHR_16bit_storage extension respectively.

Previously, 8-bit and 16-bit tensors were enabled by using those extensions; however, this meant that 8-bit and 16-bit tensors could not be used if the Vulkan driver does not support the corresponding extension.

This diff adds support for 8-bit texture-backed tensors without the need for the VK_KHR_8bit_storage extension. This is done by introducing shaders that manually pack and repack 4 8-bit integers into a single int32 value. Once the tensor data has been transferred to an image texture (which will use the VK_FORMAT_R8G8B8A8_SINT image format) the extension will no longer be required.

Differential Revision: D60536832

Copy link

pytorch-bot bot commented Jul 31, 2024

🔗 Helpful Links

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

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

✅ No Failures

As of commit c269cf9 with merge base 1090bcd (image):
💚 Looks good so far! There are no failures yet. 💚

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

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported labels Jul 31, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60536832

1 similar comment
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60536832

@SS-JIA SS-JIA force-pushed the export-D60536832 branch from ad47a9a to e61fc08 Compare August 1, 2024 23:39
SS-JIA added a commit to SS-JIA/executorch-1 that referenced this pull request Aug 1, 2024
…4485)

Summary:
Pull Request resolved: pytorch#4485

## Context

By default, storage buffers in Vulkan must contain 32 bit data types; using 8 bit and 16 bit data types in buffers can be enabled optionally by supporting the [VK_KHR_8bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_8bit_storage.html) extension or the [VK_KHR_16bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_16bit_storage.html) extension respectively.

Previously, 8-bit and 16-bit tensors were enabled by using those extensions; however, this meant that 8-bit and 16-bit tensors could not be used if the Vulkan driver does not support the corresponding extension.

This diff adds support for 8-bit texture-backed tensors without the need for the VK_KHR_8bit_storage extension. This is done by introducing shaders that manually pack and repack 4 8-bit integers into a single int32 value. Once the tensor data has been transferred to an image texture (which will use the `VK_FORMAT_R8G8B8A8_SINT` image format) the extension will no longer be required.

Differential Revision: D60536832
SS-JIA added a commit to SS-JIA/executorch-1 that referenced this pull request Aug 2, 2024
…4485)

Summary:
Pull Request resolved: pytorch#4485

## Context

By default, storage buffers in Vulkan must contain 32 bit data types; using 8 bit and 16 bit data types in buffers can be enabled optionally by supporting the [VK_KHR_8bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_8bit_storage.html) extension or the [VK_KHR_16bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_16bit_storage.html) extension respectively.

Previously, 8-bit and 16-bit tensors were enabled by using those extensions; however, this meant that 8-bit and 16-bit tensors could not be used if the Vulkan driver does not support the corresponding extension.

This diff adds support for 8-bit texture-backed tensors without the need for the VK_KHR_8bit_storage extension. This is done by introducing shaders that manually pack and repack 4 8-bit integers into a single int32 value. Once the tensor data has been transferred to an image texture (which will use the `VK_FORMAT_R8G8B8A8_SINT` image format) the extension will no longer be required.

Differential Revision: D60536832
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60536832

@SS-JIA SS-JIA force-pushed the export-D60536832 branch from e61fc08 to c08a603 Compare August 2, 2024 16:10
…4485)

Summary:
Pull Request resolved: pytorch#4485

## Context

By default, storage buffers in Vulkan must contain 32 bit data types; using 8 bit and 16 bit data types in buffers can be enabled optionally by supporting the [VK_KHR_8bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_8bit_storage.html) extension or the [VK_KHR_16bit_storage](https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_KHR_16bit_storage.html) extension respectively.

Previously, 8-bit and 16-bit tensors were enabled by using those extensions; however, this meant that 8-bit and 16-bit tensors could not be used if the Vulkan driver does not support the corresponding extension.

This diff adds support for 8-bit texture-backed tensors without the need for the VK_KHR_8bit_storage extension. This is done by introducing shaders that manually pack and repack 4 8-bit integers into a single int32 value. Once the tensor data has been transferred to an image texture (which will use the `VK_FORMAT_R8G8B8A8_SINT` image format) the extension will no longer be required.

Reviewed By: jorgep31415

Differential Revision: D60536832
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D60536832

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 448c7d3.

jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Changes following from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Changes following from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

ghstack-source-id: 246607065
Pull Request resolved: #5934
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
…ture"

Changes following from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Changes following from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Pull Request resolved: #5934

Changes following from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246658454
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
…ture"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246672275
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
…ture"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 7, 2024
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246725187
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246850704
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
…ture"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
…ture"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246869292
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
…ture"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 8, 2024
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246872869
@exported-using-ghexport

Differential Revision: [D63918659](https://our.internmc.facebook.com/intern/diff/D63918659/)
facebook-github-bot pushed a commit that referenced this pull request Oct 8, 2024
Summary:
Pull Request resolved: #5934

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.
ghstack-source-id: 246872869
exported-using-ghexport

bypass-github-export-checks
bypass-github-pytorch-ci-checks
bypass-github-executorch-ci-checks

Reviewed By: SS-JIA

Differential Revision: D63918659

fbshipit-source-id: d4095228fac24be118af8bb0bf42b453ca0a03a2
jorgep31415 added a commit that referenced this pull request Oct 9, 2024
…ge, take 2"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.
Changes follow from #4485 to support texture2d and support uint8, respectively.

Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 9, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.
Changes follow from #4485 to support texture2d and support uint8, respectively.

Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 9, 2024
…ge, take 2"


"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.
Changes follow from #4485 to support texture2d and support uint8, respectively.

Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/)

[ghstack-poisoned]
jorgep31415 added a commit that referenced this pull request Oct 9, 2024
"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.
Changes follow from #4485 to support texture2d and support uint8, respectively.

Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/)

[ghstack-poisoned]
facebook-github-bot pushed a commit that referenced this pull request Oct 9, 2024
Summary:
Pull Request resolved: #6028

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from #4485 to support `texture2d` and support `uint8`, respectively.

(Redo of #5934)
ghstack-source-id: 247078906

Reviewed By: SS-JIA

Differential Revision: D64076249

fbshipit-source-id: 541cfddf92c55ebd4c6e39c6bd041fb5aa78b3b9
kedarnath03 pushed a commit to kedarnath03/executorch that referenced this pull request Jun 25, 2025
Pull Request resolved: pytorch/executorch#6028

"bitw8" = bit width 8, which is equivalent to 8-bit. We use "bitw8" as the name since shader compilation disallows names starting with a digit.

Changes follow from pytorch/executorch#4485 to support `texture2d` and support `uint8`, respectively.

(Redo of pytorch/executorch#5934)
ghstack-source-id: 247078906

Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/)
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. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants