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

Qiskit-Extensions / qiskit-experiments / 6099303896
88%
main: 88%

Build:
Build:
LAST BUILD BRANCH: gh-readonly-queue/main/pr-1267-60655bb7aa78fd8f27a3a0be3c19f1e89e483305
DEFAULT BRANCH: main
Ran 06 Sep 2023 05:06PM UTC
Jobs 4
Files 168
Run time 6s
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

06 Sep 2023 03:39PM UTC coverage: 88.271%. Remained the same
6099303896

push

github

web-flow
Improve performance of RB circuit generation (#1263)

### Summary

The circuit generation for RB experiments is slow due to the use of
indexing on sparse matrices (`_CLIFFORD_COMPOSE_2Q` from
`qiskit_experiments.library.randomized_benchmarking.clifford_utils`).
Since indexing is the only operation used on `_CLIFFORD_COMPOSE_2Q` we
can improve performance by using the `lil_matrix` format.

### Details and comments

Improve performance of RB circuit generation by changing the format of
`_CLIFFORD_COMPOSE_2Q` to `lil_matrix`.

Micro benchmark:
```
import scipy.sparse
from qiskit_experiments.library.randomized_benchmarking.clifford_utils import _CLIFFORD_COMPOSE_2Q

_CLIFFORD_COMPOSE_2Q_lil =  scipy.sparse.lil_matrix(_CLIFFORD_COMPOSE_2Q)

%timeit _CLIFFORD_COMPOSE_2Q[2,3]
%timeit _CLIFFORD_COMPOSE_2Q_lil[2,3]
```
Result:
```
29.4 µs ± 4.01 µs per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
2.64 µs ± 777 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
```

Application benchmark:
```
import time
import qiskit
from qiskit_experiments.library import InterleavedRB

gate=qiskit.circuit.library.CXGate()
rb=InterleavedRB(gate, physical_qubits= (0,1),lengths= [1,10,50,100,200], num_samples= 10)

t0=time.time()
c=rb.circuits()
dt=time.time()-t0
```
results in a speedup from 2.1419544219970703 to 1.154689073562622
seconds.



### PR checklist (delete when all criteria are met)

- [x] I have read the contributing guide `CONTRIBUTING.md`.
- [x] I have added the tests to cover my changes.
- [x] I have updated the documentation accordingly.
- [x] I have added a release note file using `reno` if this change needs
to be documented in the release notes. (no release note required)

---------

Co-authored-by: Helena Zhang <Helena.Zhang@ibm.com>

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

12387 of 14033 relevant lines covered (88.27%)

3.53 hits per line

Jobs
ID Job ID Ran Files Coverage
1 unit-tests_python3.10-macOS-latest - 6099303896.1 06 Sep 2023 05:06PM UTC 168
88.27
GitHub Action Run
2 unit-tests_python3.11-macOS-latest - 6099303896.2 06 Sep 2023 05:09PM UTC 168
88.27
GitHub Action Run
3 unit-tests_python3.9-macOS-latest - 6099303896.3 06 Sep 2023 05:30PM UTC 168
88.24
GitHub Action Run
4 unit-tests_python3.8-macOS-latest - 6099303896.4 06 Sep 2023 05:44PM UTC 168
88.24
GitHub Action Run
Source Files on build 6099303896
  • Tree
  • List 168
  • Changed 1
  • Source Changed 1
  • Coverage Changed 1
Coverage ∆ File Lines Relevant Covered Missed Hits/Line
  • Back to Repo
  • Github Actions Build #6099303896
  • 60655bb7 on github
  • Prev Build on gh-readonly-queue/main/pr-1259-e9abdc45d52411091c707006ec6cd0d26f6f3f23 (#6098114747)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc