Portable div(rounding_mode="trunc") and fmod round int64 values through double
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
🐛 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
- Lingua principale
- Python
- Stelle
- 5.1k
- Fork
- 1.2k
- Merge medio
- 1g 21h
- PR unite (30g)
- 695
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di pytorch/executorch
-
enhancement triaged
Difficoltà 2/5 Mezza giornata Idoneità per principianti 68/100
pytorch/executorch#21640 ·
I maintainer di solito rispondono entro 1 giorno
-
[Rpi5 setup] Make Raspberry Pi cross-compiled binaries run out of the box on supported OS versionsForse già presa @digantdesai l’ha presa oggi. Apertamodule: microcontrollers rfc
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
pytorch/executorch#24228 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
-
[ET-VK] fp16 linear on an RDNA3.5 iGPU: default (texture) export runs at ~1.1 TFLOP/s, coopmat unreachable without buffer storage, and the stock buffer path is ~20x less accurateForse già presa @SS-JIA l’ha presa oggi. Apertamodule: vulkan rfc
Difficoltà 4/5 3-5 giorni Idoneità per principianti 42/100
pytorch/executorch#24196 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[QNN] 16a8w: gathered tensor read wrong by a consumer that only feeds a graph outputForse già presa @psiddh l’ha presa oggi. Apertabug module: qnn partner: qualcomm
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
pytorch/executorch#24125 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Elastic on-device inference - swap LLM mid-generation and carry KV cache (molt / kvine)Forse già presa @mergennachin l’ha presa oggi. Apertamodule: llm/evaluation rfc
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
pytorch/executorch#24106 · 2 assegnatari ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di pytorch/executorch
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 86/100
awslabs/visual-asset-management-system#937 ·
I maintainer di solito rispondono entro 1 giorno
-
Admin member of a research group cannot see the HX2 allocation until they've been added to itAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
follow-up
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 83/100
I maintainer di solito rispondono entro 3 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 2 giorni