common.title

Docs
Quantum Circuit
TYTAN CLOUD

QUANTUM GAMING


Overview
Contact
Event
Project
Research

Terms of service (Web service)

Terms of service (Quantum and ML Cloud service)

Privacy policy


Sign in
Sign up
common.title

ChatGPTを使えば量子プログラミングは不要になるのか?量子アニーリングと量子ゲートのコードを書かせてみた。

Yuichiro Minato

2023/01/30 05:14

1

こんにちは、ChatGPTというAIすごいですよね。実際に使ってみたところ、結構いろんな計算をしてくれるので、もう人間いらないのでは?と思ってしまいました。いくつか量子系のプログラミングを試してみたいと思います。

結論から言うと結構いいと思います。

「量子アニーリングのQUBOで、巡回セールスマンのコードをpythonで書いて、d-wave nealで解いてください。」

というお題に対して、

import numpy as np
import neal

def tsp_qubo(distances):
  n = distances.shape[0]
  Q = np.zeros((n, n))

# Set diagonal elements to 0
  for i in range(n):
    Q[i][i] = 0

# Set off-diagonal elements
  for i in range(n):
    for j in range(i+1, n):
      Q[i][j] = distances[i][j]
      Q[j][i] = distances[i][j]

# Set quadratic bias
  q = np.ones(n) * -1

return Q, q

Example distances matrix

distances = np.array([[0, 10, 20, 30], [10, 0, 25, 35], [20, 25, 0, 15], [30, 35, 15, 0]])
Q, q = tsp_qubo(distances)

Solve the problem using the D-Wave system

solver = neal.SimulatedAnnealingSampler()
response = solver.sample_qubo(Q, q)

Print the solution

for sample in response.samples():
  print(sample)

いくつか間違いがありますが、コードを書く時間がなくなるのと、今後改善されることを考えるとかなり作業量は減ると思います。

上記のコードでは制約条件が考慮されていませんので、今後の改善に期待です。

なんとなく量子アニーリングはChatGPTを使えば人間がいらなくなることがわかりました。次は量子ゲートを見てみたいと思います。

from blueqat import Circuit

Create a quantum circuit with 2 qubits

qc = Circuit().h[0].cx[0,1].m[:].run()

Apply a Hadamard gate to the first qubit

Apply a controlled-not (CX) gate between the first and second qubits

Measure both qubits

result = qc.result()

Print the result

print(result)

見事量子もつれカイロを作ってくれました。最後のちょっと修正が必要で、量子回路にrun()がついてるので、qcだけで可能です。

計算結果は、

Counter({'11': 1})

となりました。

結論

人間の量子プログラマーが不要になる時代が近づいてきました。AIの発展の方が絶対早いので、現段階でこれだと今後どうなるのか心配になりました。業種転換します。以上です。

© 2025, blueqat Inc. All rights reserved