[torchlib] log2 and log10 lose float64 precision
メンテナーはふだん 4 日以内に返信
@Syedmudassir1604 がすでに取り組んでいます。
2026年11月2日 から。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- python
調査の方向性
torchlib の aten_log2 と aten_log10 の実装から始めてください。これらは float32 の定数 Log(2.0) または Log(10.0) の CastLike で除算しています。issue の再現コードを実行し、float64 でのエクスポート結果が PyTorch の出力からずれる様子を確認してください。n = 8 と n = 1024 のエクスポート値が float64 で PyTorch と一致し、torch.floor(torch.log2(n)) が 3 と 10 を返せば完了です。
索引モデルが issue の本文から書いたものです。
説明
In a float64 model, torch.log2 and torch.log10 export with only about float32 accuracy, so whole-number results come out just below the whole number:
import torch
class Model(torch.nn.Module):
def forward(self, x):
return torch.log2(x), torch.log10(x)
x = torch.tensor([8.0, 1000.0], dtype=torch.float64)
onnx_program = torch.onnx.export(Model(), (x,), dynamo=True)
torch.set_printoptions(precision=17)
print(*onnx_program(x)) # [2.99999999175649368, 9.96578425727775219] [0.90308997445095363, 2.99999995833973321]
print(*Model()(x)) # [3.00000000000000000, 9.96578428466208699] [0.90308998699194354, 3.00000000000000000]
aten_log2 and aten_log10 divide by op.CastLike(op.Log(2.0), self). Log runs on a float32 constant and only the result is cast, so the graph holds 0.6931471824645996 instead of log(2) = 0.6931471805599453 as a float64 initializer, and every result is off by about 3e-9 relative. That's within the 1e-7 float64 tolerance of assert_onnx_program, which is why the op tests pass.
It matters wherever the result is floored or compared, for example torch.floor(torch.log2(n)) for a bit length or a number of levels: the exported model gives 2 for n = 8 and 9 for n = 1024, where PyTorch gives 3 and 10.
Versions: onnxscript 0.7.2 and main (682b59de), torch 2.14.1, onnxruntime 1.31.0, Linux, CPU.
- 主要言語
- Python
- スター
- 457
- フォーク
- 149
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 24
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/onnxscript のほかの issue
-
`fuse_skip_rms_normalization` fuses a float16 residual into a norm whose scale is float32, which ONNX Runtime rejects対応中かも @justinchuby が 2 日前に担当しました。 オープンmodule: optimizer
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
microsoft/onnxscript#3155 · コメント 3 件 · リアクション 1 件 · 担当者 2 名 ·
メンテナーはふだん 4 日以内に返信
-
Constant folding uses onnx's plain reference ops, never onnx.reference.ops_optimized対応中かも @todkarsant が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/onnxscript#3003 · コメント 3 件 ·
メンテナーはふだん 4 日以内に返信
-
CI : Pin github actions to full commit SHA対応中かも @Aniketsy が 187 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/onnxscript#2903 · コメント 6 件 ·
メンテナーはふだん 4 日以内に返信
-
Batch-transpose fusion into `FusedMatMul` sets `transBatchA` on inputs of different ranks, which ONNX Runtime can't compute対応中かも @Syedmudassir1604 が 2 日前に担当しました。 オープンmodule: optimizer
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
microsoft/onnxscript#3156 ·
メンテナーはふだん 4 日以内に返信
-
`SlicesSplit` rule makes `optimizer.optimize` quadratic in the number of `Slice` nodes対応中かも @mayuriphad が 1 日前に担当しました。 オープンmodule: optimizer
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
microsoft/onnxscript#3154 ·
メンテナーはふだん 4 日以内に返信
microsoft/onnxscript の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
hkust-nlp/Toolathlon#101 ·
-
enhancement good first issue
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
SkyTruth/cerulean-cloud#219 ·
-
area:security priority:low size:small
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
RonaldHensbergen/composable-data-stack#1217 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
blixvip/BlendClone#27 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100