GPU numerical accuracy: compensated sums, norm-aware results, optional f64

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

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
rust

調査の方向性

Start with qubit_probability.wgsl, src/backend.rs around measure_qubit, and src/pauli.rs to trace probability and expectation calculations. Check how shaders are compiled and how the GPU adapter requests features before assessing the optional f64 path. Done means branch renormalisation uses each branch's measured norm, expectation values account for state norm, and f64 remains optional on supported adapters.

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

説明

enhancement
What you want to do

The GPU backend works in f32. Three things make its error bigger than it needs to be:

  1. qubit_probability.wgsl adds up to about 32 thousand terms per thread one after another in f32
    (at 30 qubits), and measure_qubit (src/backend.rs:153) renormalises by 1/√p from that sum.
    Errors add up over many mid-circuit measurements in one shot.
  2. The outcome-0 branch is scaled by 1/√(1 − p1), which is only right if the state's norm is
    exactly 1.
  3. Pauli::expectation (src/pauli.rs) assumes ‖ψ‖ = 1 and does not divide by the norm, so norm
    drift becomes a bias in the expectation value.
Implementation notes
  • Use Kahan (compensated) summation in each thread's loop in qubit_probability.wgsl. Return both
    the probability of 1 and the total norm from the same pass, and renormalise each branch by its
    own sum.
  • Divide expectation values by Σ|a|², which is a cheap extra sum in the same loop.
  • f64: request wgpu::Features::SHADER_F64 when the adapter offers it and compile a second
    shader. Most consumer GPUs run f64 at 1/16–1/64 of f32 speed, so it should only be opt-in.
What it could look like
No API change for 1–3. Optionally `backend="gpu64"` on adapters that support `SHADER_F64`.
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 を短くまとめたダイジェスト。