`denormals_are_zeros` setting has unexpected side effects

Đang mở
#666 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@msoud2509 đang làm issue này rồi.

Từ ngày 13/9/2026.

  • #1111 của @msoud2509 — đã đóng, không merge
  • #1112 của @msoud2509 — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
cpp, python
Lĩnh vực
backend

Hướng nghiên cứu

Start by running the reproduction in the issue: it checks that ctypes.c_float(1e-40) keeps its value after QSimSimulator(qsim_options=QSimOptions(denormals_are_zeros=True)).simulate(cirq.Circuit()). The payload does not name the source files, so search the C++ simulator and its Python binding for where the flush-to-zero and denormals-are-zero flags are set. Done means the flags are restored after each simulate call, including when the simulation raises. The closed, unmerged pull request #1111 is a prior attempt worth reading first.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

a: health contributors welcome P2

qsim updates global flush-to-zero and denormals-are-zero control flags, but never resets them to their original values. This can lead to unexpected changes in the behavior of downstream code, e.g.:

import cirq
import ctypes

from qsimcirq import QSimOptions, QSimSimulator


orig_value = ctypes.c_float(1e-40).value

_ = QSimSimulator(qsim_options=QSimOptions(denormals_are_zeros=False)).simulate(cirq.Circuit())

assert ctypes.c_float(1e-40).value == orig_value  # passes

_ = QSimSimulator(qsim_options=QSimOptions(denormals_are_zeros=True)).simulate(cirq.Circuit())

assert ctypes.c_float(1e-40).value == orig_value  # fails

_ = QSimSimulator().simulate(cirq.Circuit())

assert ctypes.c_float(1e-40).value == orig_value  # passes

it would be nice if these flags were reset after the simulation (ideally even if the simulation itself fails)

Ngôn ngữ chính
C++
Star
702
Fork
219
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
8

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của quantumlib/qsim

Tất cả issue của quantumlib/qsim

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.