[torchlib] Float remainder is off by the divisor when the quotient rounds up, and nan for an infinite divisor
メンテナーはふだん 3 日以内に返信
評価
調査の方向性
Start with _aten_remainder, whose TODO points to the PyTorch kernel; compare its remainder behavior with the examples in the issue, including quotient rounding and infinite divisors. Check the relevant tests for exported torch.remainder behavior. Done when exported results match PyTorch for the reported cases, including large quotients and both divisor signs.
索引モデルが issue の本文から書いたものです。
説明
Float remainder (a % b, torch.remainder) is exported as a - Floor(a / b) * b. When a / b rounds up to a whole number the result is off by a whole b, an infinite divisor gives nan, and large quotients lose their low digits.
import torch
class Model(torch.nn.Module):
def forward(self, a, b):
return a % b
inf = float("inf")
args = (torch.tensor([1.0, 4.2, 1e10, 5.0, -5.0]), torch.tensor([0.1, 1.4, 3.0, inf, inf]))
onnx_program = torch.onnx.export(Model(), args, dynamo=True)
print(onnx_program(*args)[0]) # tensor([0., 0., 0., nan, nan])
print(Model()(*args)) # tensor([0.1000, 1.4000, 1.0000, 5.0000, inf])
This matters for code that wraps a value into a period, such as a phase or an angle (phase % 1.0, theta % (2 * math.pi)). At the boundary, the exported model gives 0 where PyTorch gives a value just below the period.
The TODO in _aten_remainder already points at the PyTorch kernel, which takes the exact fmod(a, b) and adds b when the signs differ.
Versions: onnxscript main (d7cb02b0), torch 2.14.1, onnxruntime 1.31.0, Linux, CPU.
- 主要言語
- Python
- スター
- 456
- フォーク
- 148
- 平均マージ
- 3日 19時間
- マージ済み PR(30日)
- 20
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/onnxscript のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/onnxscript#3003 · コメント 3 件 ·
メンテナーはふだん 3 日以内に返信
-
CI : Pin github actions to full commit SHA対応中かも @Aniketsy が 177 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/onnxscript#2903 · コメント 6 件 ·
メンテナーはふだん 3 日以内に返信
-
optimize() crashes when constant folding produces a string tensor対応中かも @nniiovoo が 2 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
microsoft/onnxscript#3129 ·
メンテナーはふだん 3 日以内に返信
-
bug module: torchlib
難易度 3/5 1〜2日 初心者へのやさしさ 64/100
microsoft/onnxscript#3124 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
-
[torchlib] Python floats in float64 models are exported with float32 precision対応中かも @usmanmateen が 7 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 56/100
microsoft/onnxscript#3117 ·
メンテナーはふだん 3 日以内に返信
microsoft/onnxscript の issue をすべて見る
似ている issue
-
ready-for-agent tooling
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
KRoperUK/smeg-plus-patches#249 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
monzta1/ToneCommand#293 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
oracle/graalvm-reachability-metadata#11318 ·
メンテナーはふだん 1 日以内に返信
-
area: parser bug difficulty: easy
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
hayagrivai-labs/phantom#150 ·
メンテナーはふだん 1 日以内に返信
-
difficulty: easy good first issue help wanted mentor available testing
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
hayagrivai-labs/sciproof#179 ·
メンテナーはふだん 1 日以内に返信