SampledExpectation layer seems to recompute the same circuits for different measurement ops

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

メンテナーはふだん 21 日以内に返信

@MichaelBroughton がすでに取り組んでいます。

2020年6月20日 から。

評価

この issue はまだ評価されていません。

説明

area/circuits area/docs kind/bug-report

Example

c = cirq.Circuit()
qubits = cirq.GridQubit.rect(2, 1)
c.append(cirq.rz(0.)(qubits[0]))
c.append(cirq.H(qubits[1]))
sampled_expectation_layer = tfq.layers.SampledExpectation()
output = sampled_expectation_layer(
    [c],
    operators=[cirq.Z(qubits[0]), cirq.Z(qubits[1]), cirq.Z(qubits[0]) * cirq.Z(qubits[1])],
    repetitions=1)
print(output) # we have [1, -1, 1] sometimes
assert output[0,0]*output[0,1] == output[0,2] # and this may fail

It is unnatural to me that, when repetitions=1 (1 sample), we have inconsistent measurement results between Z1, Z2 and Z1*Z2.

And from code here https://github.com/tensorflow/quantum/blob/db2eac4e598f614a8c0e157c56313a23ef1943fb/tensorflow_quantum/core/ops/batch_util.py#L554-L561, this may be due to that each circuit, batch, measurement ops combination is simulated separately on backends. If it is so, it is not only unnatural but also inefficient since one can measure all ops for one circuit simulation.

My understanding may be wrong somewhere, any ideas on this?

主要言語
Python
スター
2.2k
フォーク
675
平均マージ
15日 11時間
マージ済み PR(30日)
3

環境構築

はじめの一歩

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

tensorflow/quantum のほかの issue

tensorflow/quantum の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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