Portable div(rounding_mode="trunc") and fmod round int64 values through double
Mantenedores costumam responder em até 1 dia
Avaliação
Esta issue ainda não foi avaliada.
Descrição
🐛 Describe the bug
The portable div with rounding_mode="trunc" and fmod give wrong results for int64 values above 2^53:
import torch
from executorch.exir import to_edge
from executorch.extension.pybindings.portable_lib import _load_for_executorch_from_buffer
class M(torch.nn.Module):
def forward(self, a, b):
return torch.div(a, b, rounding_mode="trunc"), torch.fmod(a, b)
a = torch.tensor([(1 << 62) + 3, -((1 << 62) + 3), 9007199254740993])
b = torch.tensor([3, 10, 2])
prog = to_edge(torch.export.export(M(), (a, b))).to_executorch()
print([t.tolist() for t in _load_for_executorch_from_buffer(prog.buffer).forward((a, b))])
print([t.tolist() for t in M()(a, b)])
[[1537228672809129216, -461168601842738816, 4503599627370496], [1, -4, 0]]
[[1537228672809129302, -461168601842738790, 4503599627370496], [1, -7, 1]]
div.out_mode and div.Scalar_mode_out compute the integer quotient with /, then call std::trunc on it, which converts it to double and back. fmod.Tensor_out and fmod.Scalar_out switch every integer compute type to Double and use std::fmod. Integer division already truncates, and % gives the fmod result directly, so neither needs a double.
I'll open a PR that skips std::trunc for integer types and computes integer fmod with %.
Versions
executorch 1.5.1 (kernels/portable/cpu/op_div.cpp and op_fmod.cpp are the same on main at 5b14a2f), torch 2.14.1+cpu, Python 3.12, Linux x86_64 (WSL2).
cc @larryliu0820 @manuelcandales @JakeStevens
- Linguagem predominante
- Python
- Estrelas
- 5.1k
- Forks
- 1.2k
- Merge médio
- 2d 6h
- PRs com merge (30d)
- 692
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de pytorch/executorch
-
enhancement triaged
Dificuldade 2/5 Meio dia Facilidade para iniciantes 68/100
pytorch/executorch#21640 ·
Mantenedores costumam responder em até 1 dia
-
module: cuda
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 10/100
pytorch/executorch#24353 ·
Mantenedores costumam responder em até 1 dia
-
More Exynos SoCs supportAberta
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 10/100
pytorch/executorch#24350 ·
Mantenedores costumam responder em até 1 dia
-
`torch.complex` fails Edge export and CPU executionTalvez já em andamento @JakeStevens assumiu hoje. Abertabug module: kernels triaged
pytorch/executorch#24328 · 2 responsáveis ·
Mantenedores costumam responder em até 1 dia
-
module: openvino
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 15/100
pytorch/executorch#24325 ·
Mantenedores costumam responder em até 1 dia
Todas as issues de pytorch/executorch
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
namespace operations
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 65/100
EclipseFdn/open-vsx.org#15057 ·
Mantenedores costumam responder em até 1 dia
-
Mission statement: why this is free, in the README, Why This Exists and the wiki HomeTalvez já em andamento @ChiefGyk3D assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
ChiefGyk3D/Clouds-Against-Humanity#348 ·
Mantenedores costumam responder em até 1 dia
-
[Perf] Default --vllm-watermark 0.05 for rollouts (hybrid models re-preempt under KV pressure)Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 74/100
vllm-project/vime#508 ·
Mantenedores costumam responder em até 4 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 1 dia