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.