[torchlib] log2 and log10 lose float64 precision
Maintainer thường phản hồi trong vòng 4 ngày
@Syedmudassir1604 đang làm issue này rồi.
Từ ngày 2/11/2026.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- machine-learning
Hướng nghiên cứu
Bắt đầu từ các triển khai torchlib của aten_log2 và aten_log10, chúng chia cho một CastLike của hằng số float32 Log(2.0) hoặc Log(10.0). Chạy reproducer trong issue để thấy sai lệch của các giá trị xuất ở float64 so với đầu ra của PyTorch. Hoàn thành khi các giá trị xuất cho n = 8 và n = 1024 khớp với PyTorch ở float64 và torch.floor(torch.log2(n)) cho ra 3 và 10.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 457
- Fork
- 149
- Merge trung bình
- 3 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 24
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/onnxscript
-
`fuse_skip_rms_normalization` fuses a float16 residual into a norm whose scale is float32, which ONNX Runtime rejectsCó thể đã có người làm @justinchuby đã nhận 3 ngày trước. Đang mởmodule: optimizer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/onnxscript#3155 · 3 bình luận · 1 reaction · 2 người được giao ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Constant folding uses onnx's plain reference ops, never onnx.reference.ops_optimizedCó thể đã có người làm @todkarsant đã nhận 3 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/onnxscript#3003 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
CI : Pin github actions to full commit SHACó thể đã có người làm @Aniketsy đã nhận 188 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/onnxscript#2903 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 4 ngày
-
Batch-transpose fusion into `FusedMatMul` sets `transBatchA` on inputs of different ranks, which ONNX Runtime can't computeCó thể đã có người làm @Syedmudassir1604 đã nhận 3 ngày trước. Đang mởmodule: optimizer
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
microsoft/onnxscript#3156 ·
Maintainer thường phản hồi trong vòng 4 ngày
-
`SlicesSplit` rule makes `optimizer.optimize` quadratic in the number of `Slice` nodesCó thể đã có người làm @mayuriphad đã nhận 2 ngày trước. Đang mởmodule: optimizer
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 68/100
microsoft/onnxscript#3154 ·
Maintainer thường phản hồi trong vòng 4 ngày
Tất cả issue của microsoft/onnxscript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
adafruit/Fruit-Jam-OS#98 ·
-
python triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/semantic-kernel#14753 ·
Maintainer thường phản hồi trong vòng 5 ngày
-
area:cli area:configuration documentation priority:low size:small
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 80/100
RonaldHensbergen/composable-data-stack#1222 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug python
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
pvlib/pvlib-python#2939 ·
Maintainer thường phản hồi trong vòng 1 ngày