[Vulkan] scalar_tensor uploads float bytes to integer scalar shaders
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- computer-graphics, testing-qa
Hướng nghiên cứu
Start in backends/vulkan/runtime/graph/ops/impl/ScalarTensor.cpp and compare its parameter upload with the declaration in backends/vulkan/runtime/graph/ops/glsl/scalar_tensor.glsl. Run the provided Vulkan regression cases with the scalar-tensor exporter fixes from #23156. Done means the buffer type matches the shader declaration and integer outputs preserve values such as 16777217.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐛 Describe the bug
While implementing the scalar-tensor delegation fixes in #23156, I found a separate runtime parameter-type mismatch in ScalarTensor.cpp.
The runtime always extracts the scalar as float and uploads a float parameter buffer, but selects the shader's scalar parameter type from graph.dtype_of(scalar_in). An integer literal therefore selects an integer parameter declaration while receiving float bytes. For example, 3.0f has the bit pattern 0x40400000, which an int32 parameter reads as 1077936128.
Converting every integer scalar through float also loses precision for exactly representable int32 values above 2**24, such as 16777217.
The relevant code is in ScalarTensor.cpp, and the parameter declaration comes from scalar_tensor.glsl.
This becomes reachable through ordinary exported models after fixing the raw ATen registration and serialized operator name described in item 2 of #23156. Without those exporter fixes, the scalar tensors fall back to CPU and hide this runtime defect.
The following regression cases exercise mixed scalar types and integer precision. They require a Vulkan-enabled runtime and the scalar-tensor exporter fixes from #23156:
import torch
from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner
from executorch.exir import to_edge_transform_and_lower
from executorch.extension.pybindings.portable_lib import (
_load_for_executorch_from_buffer,
)
class WhereScalars(torch.nn.Module):
def __init__(self, positive, negative):
super().__init__()
self.positive = positive
self.negative = negative
def forward(self, x):
return torch.where(x, self.positive, self.negative)
inputs = (torch.tensor([True, False, True, False]),)
for positive, negative in ((3, -7.0), (3.0, -7), (16777217, -7)):
model = WhereScalars(positive, negative)
edge = to_edge_transform_and_lower(
torch.export.export(model, inputs),
partitioner=[VulkanPartitioner()],
)
program_buffer = edge.to_executorch().buffer
module = _load_for_executorch_from_buffer(program_buffer)
actual = module.run_method("forward", inputs)[0]
torch.testing.assert_close(actual, model(*inputs), atol=0, rtol=0)
The parameter buffer's type must match the shader declaration. Integer outputs should preserve the integer value without an intermediate float conversion. A local fix using int32 parameters for integer outputs and float parameters for floating-point outputs passes all three cases on MoltenVK. The surrounding Vulkan regression suite also passes: 36 tests, including dynamic eager attention and SDPA.
Versions
ExecuTorch base commit 0c7ce72758c0cbb832c5ac5970626beb347ca745, with local changes for #23156; PyTorch 2.13.0; Python 3.11; macOS arm64 on Apple M1 Pro using MoltenVK.
Drafted with OpenAI Codex. The parameter-type diagnosis is based on the runtime source; the local fix and regression cases were executed on the GPU.
cc @SS-JIA @manuelcandales @digantdesai @cbilgin
- Ngôn ngữ chính
- Python
- Star
- 5k
- Fork
- 1.2k
- Merge trung bình
- 2 ngày 10 giờ
- Pull request đã merge (30 ngày)
- 573
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pytorch/executorch
-
enhancement triaged
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 68/100
pytorch/executorch#21640 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement module: examples
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
pytorch/executorch#23164 · 7 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Qualcomm: 8-bit per-channel weight scales are floored at the 16-bit eps, and the HTP miscomputes near-zero channelsCó thể đã có người làm @psiddh đã nhận hôm nay. Đang mởmodule: qnn partner: qualcomm
pytorch/executorch#23160 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[cpu kernels] native_layer_norm: layer_norm_scalar returns NaN on large-mean rows; Half/BF16 at N>=256 slow after #23153Có thể đã có người làm @JakeStevens đã nhận hôm nay. Đang mởmodule: kernels
pytorch/executorch#23159 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Vulkan] Missing/partial op support blocks full delegation of a dynamic-shape transformer encoderĐang mởmodule: vulkan
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
pytorch/executorch#23156 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của pytorch/executorch
Issue tương tự
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
vllm-project/vllm-metal#822 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
vector-store
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 90/100
mem0ai/mem0#7461 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug]: chunk_span_bounds and _validated_chunk_spans reject Pydantic models ChunkSpan and AudioFileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BasedHardware/omi#19047 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày