• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 32874632752
88%

Build:
DEFAULT BRANCH: main
Ran 25 Aug 2026 05:25PM UTC
Jobs 1
Files 956
Run time 4min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

25 Aug 2026 04:27PM UTC coverage: 87.751% (+0.006%) from 87.745%
32874632752

push

github

web-flow
Allow `calloc`-like optimisations in `SparsePauliOp` allocations (#16830)

* Allow `calloc`-like optimisations in `SparsePauliOp` allocations

As of Rust 1.98, `vec![0.0; 2 * len]` lowers to OS/kernel-level
"allocate zero-filled" functions, but using a non-primitive type in the
`Vec` (like `Complex64`) doesn't permit this optimisation.  We want to
use `calloc` instead of manually writing zeros into the vector because
it often gets kernel-level support to have zero impact on pages that are
never written to, whereas manually issuing write calls across each row
guarantees that we have to page in everything.

This has a larger performance impact for large dense matrices with high
sparsity factors.

Using a benchmark script:

```python
import timeit
import numpy as np
from qiskit.quantum_info import SparsePauliOp

def make_sparse_list(num_qubits, num_terms, locality, rng):
    terms = []
    for _ in range(num_terms):
        indices = rng.choice(num_qubits, size=locality, replace=False)
        label = "".join(rng.choice(tuple("XYZ")) for _ in indices)
        coeff = complex(rng.normal(), rng.normal())
        terms.append((label, indices, coeff))
    return terms

rng = np.random.default_rng(42)
print(f"{'n':>3} {'terms':>6} {'locality':>8} {'time (s)':>10}")
configs = [
    (6, 10, 2),
    (10, 10, 2),
    (10, 50, 2),
    (10, 100, 4),
    (14, 10, 2),
    (14, 50, 2),
    (14, 100, 4),
]
for num_qubits, num_terms, locality in configs:
    terms = make_sparse_list(num_qubits, num_terms, locality, rng)
    op = SparsePauliOp.from_sparse_list(terms, num_qubits=num_qubits)
    reps, tot = timeit.Timer(op.to_matrix).autorange()
    print(f"{num_qubits:>3} {num_terms:>6} {locality:>8} {tot / reps:>10.4f}")
```

On main (as of aae0d80eaf), on a Macbook Pro M4 Max using 16 threads,
the timings were:
```text
  n  terms locality   time (s)
  6     10        2     0.0000
 10     10        2     0.0003
 10     50        2     0.0003
 10    100        4     0.000... (continued)

1 of 1 new or added line in 1 file covered. (100.0%)

4 existing lines in 2 files now uncovered.

114177 of 130115 relevant lines covered (87.75%)

988587.21 hits per line

Coverage Regressions

Lines Coverage ∆ File
3
92.8
0.77% crates/qasm2/src/lex.rs
1
77.96
-0.04% crates/circuit/src/parameter/symbol_expr.rs
Jobs
ID Job ID Ran Files Coverage
1 32874632752.1 25 Aug 2026 05:25PM UTC 956
87.75
GitHub Action Run
Source Files on build 32874632752
  • Tree
  • List 956
  • Changed 4
  • Source Changed 1
  • Coverage Changed 4
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #32874632752
  • 4e0f21ad on github
  • Prev Build on gh-readonly-queue/main/pr-16828-87b988a395d8cb614c2a66b8b1cd66f7082ee9f9 (#32853599859)
  • Next Build on main (#33055821275)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc