Faster CPU backend for large registers (≥ 20 qubits)
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 48/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- rust
- Domain
- performance
Research direction
Start with apply_gate_kernel in src/engine.rs around line 75 and compare its CPU benchmark with Qiskit Aer at 20 or more qubits. The issue lists gate special cases, controlled-gate indexing, cache blocking, and two-qubit fusion as possible optimization paths. Done means CPU circuits run faster without an API change; the issue names no benchmark file or test command.
Written by the indexing model from the issue text.
Description
What you want to do
In the benchmark the CPU backend falls behind Qiskit Aer from 20 qubits (1.17 s vs 431 ms at 22). Each extra qubit costs 3–4× instead of 2× once the 16 MiB state stops fitting in L3 cache. Users without a GPU hit this wall first.
Implementation notes
Ranked roughly by expected gain per line of code:
- Special-case permutation and diagonal gates.
apply_gate_kernel(src/engine.rs:75) runs a
full 2×2 complex multiply for X, CX, Z, CZ, S, T, P and RZ. X and CX only need to swap amplitudes.
Diagonal gates only need to multiply one half (or both halves by a phase). This halves the
arithmetic and the memory writes for diagonal gates. - Controlled gates should only visit pairs whose control bits are set. At the moment the kernel
visits every pair and skips non-matching ones with a branch. Enumerating only the indices that
match turns a full pass into half a pass (CX) or a quarter (CCX). - Cache blocking. Apply runs of gates whose targets are all below some qubit k to one
2^k-amplitude block at a time, so each block stays in L2/L3 while several gates hit it. - Two-qubit fusion. Merge consecutive gates on the same pair of qubits into one 4×4 matrix.
That needs a 4×4 kernel.
What it could look like
No API change: the same circuits just run faster on `backend="cpu"`.
Contributing
- I would like to open a pull request for this (see CONTRIBUTING.md).
- Dominant language
- Rust
- Stars
- 1
- Forks
- 0
- Avg merge
- 12m
- Merged PRs (30d)
- 4
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from kaiwave/qsengine
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 48/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 55/100
All issues in kaiwave/qsengine
Similar issues
-
bug order-flow studies ui
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
userFRM/egui-charts#2417 ·
Maintainers usually reply within 1 day
-
In a plain-text message, Font, Font Size, Font Color and Text Highlight Color stay livePossibly taken @ragelfundionctrumnar claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
UCS-Care-Group/mailcraft#862 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
smoltcp-rs/smoltcp#1243 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day