Open
Description
🐛 Describe the bug
Vulkan divide ops with rounding_mode="trunc" do not match eager/portable. When rounding mode is "floor" the output matches. It's not immediately clear if this is within expected numerical bounds, but enough values are off by 1 that it looks like the computation does not match. Feel free to close this issue if this is the expected behavior.
import torch
from executorch.backends.vulkan.partitioner.vulkan_partitioner import VulkanPartitioner
from executorch.exir import to_edge_transform_and_lower, EdgeCompileConfig, to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
from typing import Callable, List, Optional, Tuple, Union
class Model(torch.nn.Module):
def forward(self, x, y):
return torch.div(x, y, rounding_mode="trunc")
model = Model()
inputs = (
torch.randn(1, 12),
torch.randn(1, 12),
)
eager_outputs = model(*inputs)
ep = torch.export.export(model.eval(), inputs)
print(ep)
lowered = to_edge_transform_and_lower(
ep,
partitioner=[VulkanPartitioner()],
compile_config=EdgeCompileConfig(_check_ir_validity=False)
).to_executorch()
print(lowered.exported_program())
et_model = _load_for_executorch_from_buffer(lowered.buffer)
et_outputs = et_model([*inputs])[0]
print(f"Inputs: {inputs}")
print(f"Eager: {eager_outputs}")
print(f"ET: {et_outputs}")
Outputs:
Inputs: (tensor([[ 1.3996, 0.2905, 0.9381, 0.7877, 0.5824, -0.5655, 0.3260, -0.0476,
0.2626, -0.3083, -2.1130, 0.5721]]), tensor([[-0.7415, 0.2069, -0.5097, 0.2503, 1.0457, 0.6018, -0.6957, -0.0889,
1.3877, -0.1224, -1.4198, 1.6500]]))
Eager: tensor([[-1., 1., -1., 3., 0., -0., -0., 0., 0., 2., 1., 0.]])
ET: tensor([[-2., 1., -2., 3., 0., -1., -1., 0., 0., 2., 1., 0.]])
Versions
Run on Meta internal master, Jul 3, fbcode/SwiftShader