common.title

Docs
Quantum Circuit
TYTAN CLOUD

QUANTUM GAMING


autoQAOA
Desktop RAG

Overview
Terms of service

Privacy policy

Contact
Research

Sign in
Sign up
common.title

Rigettiで量子振幅増幅回路(グローバーの一般化)の計算

Yuichiro Minato

2021/04/22 17:07

#量子ゲート #量子コンピュータ

今回はRigettiで振幅増幅回路を実行してみます。

from blueqat import Circuit
from bqcloud import load_api, Device

#キーの読み込み
api = load_api()

今回は、こちらの回路を利用し、10のデータを増幅するような回路を作ります。下記はマーキング回路です。

'''
#marking on |01>
 
----S--*--S---
-------Z-------
'''

Circuit(2).s[0].cz[0,1].s[0].run_with_sympy_unitary()
Matrix([
[1,  0, 0, 0],
[0, -1, 0, 0],
[0,  0, 1, 0],
[0,  0, 0, 1]])

こちらの回路に下記のような増幅反転回路を実行します。

'''
--H-X-*-X-H--
--H-X-Z-X-H--
'''

Circuit(2).h[:].x[:].cz[0,1].x[:].h[:].run_with_sympy_unitary()
Matrix([
[ 1/2, -1/2, -1/2, -1/2],
[-1/2,  1/2, -1/2, -1/2],
[-1/2, -1/2,  1/2, -1/2],
[-1/2, -1/2, -1/2,  1/2]])
a = Circuit(2).h[:].x[:].cz[0,1].x[:].h[:]

こちらをまとめて実行です。

task = api.execute(Circuit(2).h[:].s[0].cz[0,1].s[0] + a, Device.Aspen9, 100)
result = task.wait(timeout=100)
if result:
    print(result.shots())
else:
    print("timeout")
Counter({'10': 94, '11': 5, '00': 1})

今回はうまい感じに振幅増幅できました。10のビット列が増幅されて出てきています。以上です。

© 2025, blueqat Inc. All rights reserved