Skip to content

[Bug] QdpBenchmark does not validate documented builder argument ranges #1469

Description

@viiccwen

What

QdpBenchmark does not validate several builder values when they are configured. Invalid values are accepted and either produce meaningless measurements or fail later with unrelated runtime exceptions.

Steps to reproduce representative failures:

from qumat_qdp import QdpBenchmark

print(
    QdpBenchmark()
    .backend("pytorch")
    .qubits(2)
    .batches(0, size=2)
    .run_throughput()
)

print(
    QdpBenchmark()
    .backend("pytorch")
    .qubits(0)
    .batches(1, size=2)
    .run_throughput()
)

(
    QdpBenchmark()
    .backend("pytorch")
    .qubits(2)
    .batches(1, size=2)
    .warmup(-1)
    .run_throughput()
)

Actual result: Invalid builder values are accepted and produce inconsistent downstream behavior, including:

  • Zero batches are accepted and return a result with zero throughput.
  • Zero qubits are accepted even though QDP supports qubit counts from 1 through 30.
  • A negative warmup value fails later with ZeroDivisionError: integer modulo by zero.
  • Invalid batch sizes can reach PyTorch and fail with a negative tensor-dimension error.
  • Invalid device IDs and unknown encoding names are not consistently rejected by the builder methods.

Expected result: The builder rejects values outside its documented ranges with actionable ValueError messages. Qubit counts are in [1, 30], batch counts and sizes are positive, prefetch and warmup counts are non-negative, device IDs are non-negative, and encoding names are supported by the benchmark API.

Environment

  • OS: Linux
  • Python version: 3.12.12
  • Qumat version: 0.7.0.dev0 (qumat-qdp 0.3.0.dev0)
  • PyTorch version: 2.9.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions