[ExecuTorch][WebGPU] Add quantize_per_tensor op (int8 buffer path)#21187
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/21187
Note: Links to docs will display an error until the docs builds have been completed. ❌ 41 New Failures, 2 Unrelated FailuresAs of commit bee86cb with merge base 4a26c64 ( NEW FAILURES - The following jobs have failed:
FLAKY - The following jobs failed but were likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
This was referenced Jul 22, 2026
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
JCNTH
added a commit
that referenced
this pull request
Jul 24, 2026
Pull Request resolved: #21187 Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served. Solution: Port `quantized_decomposed.quantize_per_tensor.default` (fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound as `array<u32>` (the landed `q4gsw` idiom), since WebGPU always allocates buffers and ignores the serialized `memory_layout`. Implementation: `QuantizePerTensor.cpp` registers only `.default` (mirrors Vulkan), reads `scale`/`zero_point` at fixed arg indices with `out = args.back()` (robust to the overload's arg count), and guards int8 output / `numel % 4 == 0` (the `array<u32>` binding) / fp32 input / non-null buffers, all fail-loud. `quantize_per_tensor.wgsl` computes `round(x * inv_scale) + zero_point`, clamps to `[-128, 127]`, and packs; `inv_scale` is the reciprocal taken in double then cast to f32, bit-matching torch's `round(input * (1.0 / scale))`. `WebGPUTensor` gains an `is_int8` flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkan `runtime/graph/ops/glsl/q8ta_quantize.glsl` + `impl/QuantizeDequantize.cpp`. ghstack-source-id: 406366809 @exported-using-ghexport Differential Revision: [D112257614](https://our.internmc.facebook.com/intern/diff/D112257614/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
Problem: The WebGPU delegate has no per-tensor quantization — the C0 gate for the int8 activation path that the Vulkan delegate's q8ta quantized ops build on. Without it, no int8-input/output op can be served.
Solution: Port
quantized_decomposed.quantize_per_tensor.default(fp32 -> int8), the backend's first non-fp32 storage-buffer op. The int8 output is packed 4 elements per 32-bit word and bound asarray<u32>(the landedq4gswidiom), since WebGPU always allocates buffers and ignores the serializedmemory_layout.Implementation:
QuantizePerTensor.cppregisters only.default(mirrors Vulkan), readsscale/zero_pointat fixed arg indices without = args.back()(robust to the overload's arg count), and guards int8 output /numel % 4 == 0(thearray<u32>binding) / fp32 input / non-null buffers, all fail-loud.quantize_per_tensor.wgslcomputesround(x * inv_scale) + zero_point, clamps to[-128, 127], and packs;inv_scaleis the reciprocal taken in double then cast to f32, bit-matching torch'sround(input * (1.0 / scale)).WebGPUTensorgains anis_int8flag (distinguishes int8 from uint8/bool, which share a 1-byte size) so the handler can reject a non-int8 output. Mirrors Vulkanruntime/graph/ops/glsl/q8ta_quantize.glsl+impl/QuantizeDequantize.cpp.@exported-using-ghexport
Differential Revision: D112257614
Differential Revision: D112257614