`pow(k) @` modifier rejects non-integer exponents
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 42/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- python
- Lĩnh vực
- quantum-computing
Hướng nghiên cứu
Start with the power-modifier check near src/pyqasm/visitor.py:1627, where the integer-only validation and the existing negative-integer inversion live. Then look at src/pyqasm/linalg.py and src/pyqasm/decomposer.py to see how a single-qubit matrix is turned into U(θ, φ, λ). Done means pow(0.5) @ x matches the sx matrix, pow(0.25) @ x and pow(1.5) @ z work, and unsupported multi-qubit or runtime-valued exponents raise a named ValidationError, with tests in tests/qasm3/test_gate.py.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Limitation
The power modifier is defined as: "The modifier
pow(k) @ replaces its gate argument U by its kth power U^k for some positive integer
or floating point number k (not necessarily constant)."
pyqasm requires k to be an integer and rejects everything else.
Example QASM failure
OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
pow(0.5) @ x q[0];
ValidationError: Power modifier argument must be an integer in gate operation QuantumGate(...)
Integer exponents, including negative ones, work today:
pow(2) @ x q[0]; // OK
pow(-1) @ x q[0]; // OK
so the restriction is specifically on the fractional case — which is the interesting one, since
pow(0.5) @ x is the square root of X.
Change Requested
- Accept a floating-point
kinpow(k) @. - For a fractional
k, the repeat-the-gate expansion used for integers does not apply. The
unrolled result must be computed from the gate's matrix as U^k via matrix power — the
principal branch, matching the spec's definition. - Where a fractional power of a gate has a known closed form in the standard library, prefer
emitting that named gate over a synthesisedU(θ, φ, λ). For examplepow(0.5) @ xis
sx. - If a fractional power cannot be realised for a given gate, raise a
ValidationErrornaming
the gate and the exponent — not the current blanket "must be an integer".
Implementation Details
- The rejection is at
src/pyqasm/visitor.py:1627. The surrounding block already handles
negative integers by inverting and repeating, so the integer path is a useful reference for
where the fractional branch belongs. src/pyqasm/linalg.pyand the Cythonsrc/pyqasm/accelerate/linalg.pyxalready provide the
matrix machinery used by the decomposer; a matrix power via eigendecomposition fits there
rather than in the visitor.- The single-qubit result can be routed through the existing ZYZ /
U(θ, φ, λ)decomposition
insrc/pyqasm/decomposer.py, so the fractional case reduces to "compute the matrix, then
decompose" and reuses tested code. - Decide the multi-qubit policy explicitly. A fractional power of a two-qubit gate is well
defined mathematically but expensive to synthesise; rejecting it with a clear message is a
reasonable first increment, provided the message says so. - The spec's "not necessarily constant" clause implies a runtime-valued exponent. That cannot
be resolved during unrolling and is out of scope here — reject it with a specific message. - Tests:
tests/qasm3/test_gate.py—pow(0.5) @ xagainst thesxmatrix,pow(0.25) @ x,
pow(1.5) @ z, a fractional power underctrl @, and a clear error for the unsupported
multi-qubit case.
- Ngôn ngữ chính
- Python
- Star
- 29
- Fork
- 33
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 15
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- 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 qBraid/pyqasm
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement error-handling program-validation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.pyCó thể đã có người làm @danielgaskins đã nhận 8 ngày trước. Đang mởenhancement qasm2
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 22/100
qBraid/pyqasm#447 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASMCó thể đã có người làm @Jah-yee đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
qBraid/pyqasm#438 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lostCó thể đã có người làm @tonycoder-hub đã nhận 10 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 22/100
qBraid/pyqasm#436 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của qBraid/pyqasm
Issue tương tự
-
Validate non-divisible effective batch sizes in the Unsloth LoRA backendCó thể đã có người làm @debesh-biswas đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
`rx.Model` event arguments emit `PydanticDeprecatedSince20` once per payload keyCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
reflex-dev/reflex#7634 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 82/100
topoteretes/cognee#6239 ·
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
ranaroussi/yfinance#3009 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Test discovery aborts on GPU builds without cuStateVec: check_cuStateVec expects a failed result but set_config() now raises RuntimeErrorCó thể đã có người làm @dmeliksetian đã nhận hôm nay. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Qiskit/qiskit-aer#2495 ·
Maintainer thường phản hồi trong vòng 1 ngày