4

I'm working on a QuantumCircuit which measures the fidelity of one point (my "test vector") and two other points (my "data set", containing of states phi_1 and phi_2) at once. I'm using Afham; Basheer, Afrad; Goyal, Sandeep (2020) to reproduce their circuit. My circuit right now looks as follows:

                                          ░ ┌───┐                    ┌───┐ ░ ┌─┐   
          control_0: ─────────────────────░─┤ H ├────────────■──■──■─┤ H ├─░─┤M├───
                     ┌──────────────────┐ ░ └───┘            │  │  │ └───┘ ░ └╥┘   
state_to_classify_0: ┤0                 ├─░──────────────────X──┼──┼───────░──╫────
                     │                  │ ░                  │  │  │       ░  ║    
state_to_classify_1: ┤1 INIT TEST STATE ├─░──────────────────┼──X──┼───────░──╫────
                     │                  │ ░                  │  │  │       ░  ║    
state_to_classify_2: ┤2                 ├─░──────────────────┼──┼──X───────░──╫────
                     └──────────────────┘ ░      ┌─────────┐ │  │  │       ░  ║    
     train_states_0: ─────────────────────░──────┤0        ├─X──┼──┼───────░──╫────
                                          ░      │         │    │  │       ░  ║    
     train_states_1: ─────────────────────░──────┤1        ├────X──┼───────░──╫────
                                          ░      │  oracle │       │       ░  ║    
     train_states_2: ─────────────────────░──────┤2        ├───────X───────░──╫────
                                          ░ ┌───┐│         │               ░  ║ ┌─┐
       comp_basis_0: ─────────────────────░─┤ H ├┤3        ├───────────────░──╫─┤M├
                                          ░ └───┘└─────────┘               ░  ║ └╥┘
     meas_control_0: ═════════════════════════════════════════════════════════╩══╬═
                                                                                 ║ 
  meas_comp_basis_0: ════════════════════════════════════════════════════════════╩═

Where the INIT TEST STATE is used to initialise my test state on a 3-qubit register, and my oracle is defined as follows:

                     ┌────────┐     ┌────────┐
train_states_0: ─────┤0       ├─────┤0       ├
                     │        │     │        │
train_states_1: ─────┤1 phi_0 ├─────┤1 phi_1 ├
                     │        │     │        │
train_states_2: ─────┤2       ├─────┤2       ├
                ┌───┐└───┬────┘┌───┐└───┬────┘
  comp_basis_0: ┤ X ├────■─────┤ X ├────■─────
                └───┘          └───┘          

So that my train_states register is in a superposition of my full data set. I want to be able to measure the fidelity between multiple points, so what I'm doing right now is just create my circuit where I call qiskit.extensions.quantum_initializer.Isometry to initialize my registers into the desired state. If I want to test another test state, I reproduce my entire circuit.

For now this works, but eventually I want to move onto larger datasets with thousands of points, I can imagine that recreating a QuantumCircuit from scratch for every data point can become a bottleneck. Hence my question: can I make INIT TEST STATE in such a way that I can define an example function like:

def apply_new_datapoint(new_init_gate, old_circuit):
    old_circuit.data.replace(0, new_init_gate)

I have no idea if the above works, but this is what I'm trying to reach eventually.

GroenteLepel
  • 55
  • 1
  • 5

2 Answers2

2

There is no replace() method, but you can do the trick by means of pop() and insert().

Example:

from qiskit import QuantumCircuit, Aer, execute
from qiskit.extensions.standard import XGate

simulator = Aer.get_backend("qasm_simulator")

qc = QuantumCircuit(4,4)
qc.h([0,1,2,3])
qc.measure([0,1,2,3], [0,1,2,3])
print(qc.draw())
result = execute(qc, backend=simulator, shots=1000).result()
counts = result.get_counts(qc)
print("\nTotal counts:",counts)

qc.data.pop(0)
qc.data.insert(0,(XGate(),[qc.qregs[0][0]],[]))
print(qc.draw())
result = execute(qc, backend=simulator, shots=1000).result()
counts = result.get_counts(qc)
print("\nTotal counts:",counts)
Michele Amoretti
  • 1,594
  • 8
  • 11
1

John Preskill identified the bottleneck you described as a fundamental problem in quantum deep learning (section 6.5, here). In particular,

But typical proposals for quantum machine learning applications are confounded by severe input/output bottlenecks. For applications to large classical data sets one should take into account the cost of encoding the input into QRAM, which can nullify the potential advantages.... These bottlenecks arise when we try to train a quantum network to learn about correlations in classical data.

Although he is somewhat skeptical of the value of quantum annealing in other parts of the paper, Preskill hints at the end of this section that quantum annealers might ultimately be a solution to overcoming these bottlenecks.

Jonathan Trousdale
  • 3,452
  • 9
  • 20