[Bug] QdpBenchmark does not validate documented builder argument ranges

Open
#1,469 3 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 2 days

@HScallop is already working on this.

Since Sep 24, 2026.

  • #1498 by @HScallop — open

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
64/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
python, pytorch

Research direction

Start at the QdpBenchmark builder methods named in the report: backend, qubits, batches, warmup, and the related prefetch, device, and encoding configuration. Add validation for the documented ranges and supported encodings, then run the supplied PyTorch reproductions to confirm invalid values raise actionable ValueError messages before execution.

Written by the indexing model from the issue text.

Description

bug docs good-first-issue
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
Dominant language
Rust
Stars
2.3k
Forks
1k
Avg merge
2d 20h
Merged PRs (30d)
7

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/mahout

All issues in apache/mahout

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.