Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`durationof({...})` is unsupported

Đang mở
#400 0 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 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
30/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

Hướng nghiên cứu

Start by reproducing the failing duration a = durationof({x q[0];}); snippet to see the validation error. The evaluator has no branch for the DurationOf expression, so look in src/pyqasm/expressions.py, then at QubitDepthNode in src/pyqasm/elements.py and DURATION_UNITS in src/pyqasm/maps/expressions.py. Done means durationof works inside delay[...] and box[...], round-trips through dumps() when the length is unknown, and raises ValidationError for an undeclared qubit, as the tests in tests/qasm3/test_timing.py check. The issue also depends on the stretch arithmetic design, so confirm that representation with maintainers first.

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

Mô tả

enhancement llm-assisted qasm3 qasm3-coverage

Limitation

Duration and stretch types defines
durationof(), which takes a block of quantum instructions and returns its duration. It is
how a program expresses a delay relative to the length of some other operation rather than as
an absolute time.

pyqasm does not evaluate it.

Example QASM failure

OPENQASM 3.0;
include "stdgates.inc";
qubit[1] q;
duration a = durationof({x q[0];});
ValidationError: Invalid initialization value for variable 'a'

Plain duration declarations, unit arithmetic, delay[...] and box[...] all work today, so
durationof is the isolated gap in the timing surface.

Change Requested

  1. Evaluate durationof({ ... }) to a duration value usable anywhere a duration literal is,
    in particular in delay[...] and box[...].
  2. Where the enclosed block's length is known — because the module was loaded with
    device_cycle_time / calibration information, or the block contains only explicit delay
    instructions — return the concrete value.
  3. Where it is not known, keep it symbolic and emit durationof({ ... }) unchanged through
    dumps(). Rejecting a valid program because a backend duration is unknown would be worse
    than passing it through.
  4. Validate the block itself: the enclosed statements must be legal quantum instructions, and
    any qubit they reference must be declared.

Implementation Details

  • openqasm3 parses this as a DurationOf expression whose target is a statement list.
    Qasm3ExprEvaluator (src/pyqasm/expressions.py) has no branch for it, which is why the
    value reaches the declaration check as unresolved.
  • pyqasm already tracks per-qubit depth via QubitDepthNode in src/pyqasm/elements.py. The
    duration of a block is the same walk over a smaller statement list, so the existing
    bookkeeping is largely reusable.
  • loads() already accepts device_cycle_time, and dt units are handled in
    DURATION_UNITS (src/pyqasm/maps/expressions.py). A cycle-count result converts to a
    concrete duration through that path when a cycle time is available.
  • This composes with the symbolic representation proposed in the stretch arithmetic issue —
    both need a duration value that is not necessarily a concrete number. Landing a single
    representation that serves both is preferable to two partial ones.
  • The block must be visited in a child scope so that any temporary state it creates does not
    leak, and its instructions must not be emitted into the unrolled output — durationof
    measures the block, it does not execute it.
  • Tests: tests/qasm3/test_timing.py — durationof of a single gate, of a multi-gate block,
    of a block containing an explicit delay, its use inside delay[...], a dumps()
    round-trip of the symbolic form, and an undeclared qubit inside the block raising a
    ValidationError.
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

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 qBraid/pyqasm

Tất cả issue của qBraid/pyqasm

Issue tương tự

Thêm issue về Python

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.