Faster CPU backend for large registers (≥ 20 qubits)

オープン
#9 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
48/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust
領域
performance

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

enhancement
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:

  1. 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.
  2. 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).
  3. 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.
  4. 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).
主要言語
Rust
スター
1
フォーク
0
平均マージ
12分
マージ済み PR(30日)
4

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

kaiwave/qsengine のほかの issue

kaiwave/qsengine の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。