This computational essay is part of work that focuses on quantum state preparation, an essential subroutine for quantum computing using the Wolfram quantum framework paclet . A high - level circuit model has been proposed [reference] that generates probability results in line with a random probability generator . Addressing the challenges in quantum computation’ logic model, a generic method is introduced for synthesizing quantum circuits capable of producing any desired quantum state from a given basis state, enabling both theoretical determination of upper bounds and experimental assessment of the required number of quantum gates [ref: Logic Synthesis for Quantum State Generation (2016 IEEE 46th International Symposium on Multiple-Valued Logic]. The work outlines a three step process for synthesizing the desired quantum circuit from a basis state, followed by a generalized method for generating n - qubit systems using a multiplexer function with controlled rotation gates and swap operations, aiming to provide a robust framework for the design and implementation of quantum circuits .
Methodology
Methodology
Quantum systems are composed of qubits. Qubits can be in one of the computational basis state |0> and |1>. More formally, a qubit can be described by a two-dimensional Hilbert space where its (quantum) state is given by unit vector so called state vector.
By inverting the resulting circuit , the desired quantum circuit transforming a basis state is synthesized. More precisely three steps are performed:
(a) Unify Phases: transformation of potentially different phases amplitudes to a single (global) phase.
(b) Unify probabilities: transformation of the potentially different moduli of amplitudes to an equal probability distribution.
(c) Remove superposition: transformation of unified amplitudes to a state with a single non-zero amplitude and, by this, generating a basis state (potentially with a negligible global phase).
By inverting the resulting circuit , the desired quantum circuit transforming a basis state is synthesized. More precisely three steps are performed:
(a) Unify Phases: transformation of potentially different phases amplitudes to a single (global) phase.
(b) Unify probabilities: transformation of the potentially different moduli of amplitudes to an equal probability distribution.
(c) Remove superposition: transformation of unified amplitudes to a state with a single non-zero amplitude and, by this, generating a basis state (potentially with a negligible global phase).
Multiplexer function is used in our module to map various quantum circuits at one place (in this case controlled rotation gates)
Generalizing methods for generating n-qubit system is as follows:
(a) Multiplexer function followed by swapping {n,n-1}
(b) Multiplexer function followed by swapping {n,n-2}
(c) Multiplexer function followed by swapping {n,n-3}
.
.
.
.
(d) Multiplexer function followed by swapping {n,1}
(e) Finally apply Hadamard for realizing non-zero amplitude
(a) Multiplexer function followed by swapping {n,n-1}
(b) Multiplexer function followed by swapping {n,n-2}
(c) Multiplexer function followed by swapping {n,n-3}
.
.
.
.
(d) Multiplexer function followed by swapping {n,1}
(e) Finally apply Hadamard for realizing non-zero amplitude
QPU setup
QPU setup
Wolfram quantum framework now comes with the IBM-Q service. We are utilizing it to access results from IBM Quantum processors. We have mainly used two quantum processors namely: ibm_nairobi and ibmq_belem.
In[]:=
ibm=ServiceConnect["IBMQ","New"]
Out[]=
ServiceObject
Extract ‘total qubits available’, ‘quantum_volume’ and ‘type of processor ‘ information of ibmq_belem and ibm_nairobi QPUs.
In[]:=
conf=ibm["Backend","ID"->"ibmq_belem","Property"->"Configuration"];conf[{"n_qubits","processor_type","quantum_volume"}]
Out[]=
In[]:=
conf2=ibm["Backend","ID"->"ibm_nairobi","Property"->"Configuration"];conf2[{"n_qubits","processor_type","quantum_volume"}]
Out[]=
You can find more information about handling of IBM quantum processors on Wolfram Quantum Framework here: https://community.wolfram.com/groups/-/m/t/2846060
About
About
In this computational essay, we aim to explore examples of different number of qubits namely Right state, Bell state and GHZ state on wolfram quantum framework. These states are measured in different basis(Pauli-Z, Pauli-X and Pauli-Y) state and their probabilities are extracted. The results show the robustness of the framework. Further, the circuits in different basis are encoded in qiskit model and sent to a real IBM quantum processor units(QPU) through query which is a recently introduced feature (‘ServiceConnect’) of the paclet. The result from the QPU is further analyzed and compared with the theoretical upper-bound. The result confirms the impact of noises as we scale the number of qubits in quantum circuit.
Right State
Right State
A right state, also known as the state, is a specific quantum state that is a balanced superposition of the basis states and . Mathematically, the right state is represented as: The amplitudes of the basis states, for both and , represent the probability amplitudes of finding the qubit in either the or state upon measurement.
|+〉
|0〉
|1〉
|0〉+|1〉
2
1
2
|0〉
|1〉
|0〉
|1〉
Define state
Define state
Define the right state.
In[]:=
ψ1=QuantumState["Right"];
Build the quantum circuit from above state and measure in different basis namely: Pauli-Z(Computational), Pauli-Y and Pauli-X
In[]:=
qcZ=QuantumCircuitOperator[ψ1]/*QuantumMeasurementOperator["Computational",{1}];qcX=QuantumCircuitOperator[{"H"->{1},{1}}]@*QuantumCircuitOperator[ψ1];qcY=QuantumCircuitOperator[{QuantumOperator["S"]["Dagger"]->1,"H"->1,{1}}]@*QuantumCircuitOperator[ψ1];
Decompose the above quantum circuit and convert in Qiskit format.
In[]:=
qiskitex1a=qcZ["Qiskit"]["Decompose"];qiskitex1b=qcX["Qiskit"]["Decompose"];qiskitex1c=qcY["Qiskit"]["Decompose"];
QPU
QPU
Encode the converted circuit.(in this case PauliZ basis circuit)
In[]:=
qpyex1a=BaseEncode@qiskitex1a["QPY","Provider"->"IBMProvider","Backend"->"ibmq_belem"];
Send the query on backend and get its information.
In[]:=
idex1a=ibm["RunCircuit",{"QPY"->qpyex1a,"Backend"->"ibmq_belem"}];
Check the job status.
In[]:=
ibm["JobStatus",{"JobID"->Values[Normal[idex1a]][[1]]}]
Out[]=
Only when the job status gets completed, results can be obtained from below code.
Extract the QPU and WQF results.
In[]:=
dsex1a=ibm["JobResults",{"JobID"->Values[Normal[idex1a]][[1]]}];dssex1a=Normal[dsex1a["results",All,"data","counts"]][[1]]qpuResultsex1a=N@Normalize[Values@%,Total]resultsex1a=qcZ[]["Probabilities"]
Out[]=
0x02099,0x11901
Out[]=
{0.52475,0.47525}
Out[]=
0,1
1
2
1
2
Similar approach is taken for Pauli-X and Pauli-Y circuits below.
In[]:=
qpyex1b=BaseEncode@qiskitex1b["QPY","Provider"->"IBMProvider","Backend"->"ibmq_belem"];
In[]:=
idex1b=ibm["RunCircuit",{"QPY"->qpyex1b,"Backend"->"ibmq_belem"}];
In[]:=
ibm["JobStatus",{"JobID"->Values[Normal[idex1b]][[1]]}]
Out[]=
In[]:=
dsex1b=ibm["JobResults",{"JobID"->Values[Normal[idex1b]][[1]]}];dssex1b=Normal[dsex1b["results",All,"data","counts"]][[1]]qpuResultsex1b=N@Normalize[Values@dssex1b,Total]resultsex1b=qcX[]["Probabilities"]
Out[]=
0x02067,0x11933
Out[]=
{0.51675,0.48325}
Out[]=
0,1
1
2
1
2
In[]:=
qpyex1c=BaseEncode@qiskitex1c["QPY","Provider"->"IBMProvider","Backend"->"ibmq_belem"];
In[]:=
idex1c=ibm["RunCircuit",{"QPY"->qpyex1c,"Backend"->"ibmq_belem"}];
In[]:=
ibm["JobStatus",{"JobID"->Values[Normal[idex1c]][[1]]}]
Out[]=
Results
Results
Plot the result (WQF and IBM QPU) in form of Bar chart and compare them side-by-side.
PauliZ
PauliZ
PauliX
PauliX
PauliY
PauliY
The result of WQF and IBM QPU matches to greater extent . The presence of noise in quantum processor (in this case ibm_nairobi) cause the mismatch in the result, however small here.
Quantum State Estimate
Quantum State Estimate
Simulate measurement results in different basis state and find the corresponding quantum state estimation.
Generate 100 states using the corresponding Bayesian sampling function.
Show histogram of fidelity with respect to the original quantum state.
KS Test
KS Test
KolmogorovSmirnovTest performs the Kolmogorov–Smirnov goodness-of-fit test with null hypothesis that data(in this case measurement of right state in x, y and z basis) was drawn from a population with distribution(here simulated measurement in corresponding basis) and alternative hypothesis that it was not.
List the qpu result of different basis.
Generate the simulated measurement on right state in X, Y and Z basis.
Extract the X basis result
Perform the KS test.
Extract the Y basis result and check the KS test.
Extract the Z basis result.
Apply KS test.
Define state
Define state
Create quantum circuit in different basis (Pauli-Z, Pauli-X and Pauli-Y basis respectively)
Decompose the above quantum circuit and convert in Qiskit format.
QPU
QPU
Encode the converted circuit (in this case PauliZ basis circuit).
Send the query on backend and get its information.
Check the job status.
Extract the QPU and WQF results respectively.
Encode the above converted circuit, send the query on backend, get its information and extract the QPU results.(in this case PauliX basis circuit)
Encode the above converted circuit again, send the query on backend, get its information and extract the QPU results . (in this case PauliY basis circuit)
Results
Results
Plot the result (WQF and IBM QPU) in form of graphics(Bar Chart here) and compare them side-by-side.
PauliZ
PauliZ
PauliX
PauliX
PauliY
PauliY
The above comparison shows similar trend between WQF and IBM QPU.
Quantum State Estimate
Quantum State Estimate
Simulate measurement results in different basis state and find the corresponding quantum state estimation.
Generate 100 states using the corresponding Bayesian sampling function.
Show histogram of fidelity with respect to the original quantum state.
KS Test
KS Test
Perform the KS test on the 2-qubit bell state in different basis and test the fit of qpu data(generated above) to a SimulatedMeasurement distribution.
List all qpu results.
GHZ state
GHZ state
Define state
Define state
Define GHZ state
Create quantum circuit using the above state in different basis.
Extract the parameters.
Note that qiskit conversion fallbacks to unitaries, which is not good for transpiling on QPU, therefore different treatment compared to example cases.
QPU
QPU
We use the similar approach to run above GHZ quantum circuit:
(i) Encode the converted circuit (PauliZ, PauliX, PauliY basis circuit)
(ii) Send the query on backend and get its information.
(iii) Check the job status. Run below steps only when the status is completed.
(iv) Extract the QPU and WQF results respectively.
(v) Plot the results on bar graph and compare.
(i) Encode the converted circuit (PauliZ, PauliX, PauliY basis circuit)
(ii) Send the query on backend and get its information.
(iii) Check the job status. Run below steps only when the status is completed.
(iv) Extract the QPU and WQF results respectively.
(v) Plot the results on bar graph and compare.
Results
Results
Plot the result (WQF and IBM QPU) on Bar Chart and compare them side - by - side .
PauliZ
PauliZ
PauliX
PauliX
PauliY
PauliY
The above comparison shows very different trend between WQF and IBM QPU result mainly for Pauli-Z and Paulli-X basis measurement circuit. It most certainly affirms impact of noise in quantum circuit which utilises higher number of qubits. This can be reduced by doing optimization or similar methods. The impact of noised can further be studied by fidelity and decoherence in the circuit.
Quantum State Estimate
Quantum State Estimate
Simulate measurement results in different basis state and find the corresponding quantum state estimation.
Generate 100 states using the corresponding Bayesian sampling function.
Show histogram of fidelity with respect to the original quantum state.
KS Test
KS Test
Perform the KS test on the GHZ state in different basis and test the fit of qpu data to a SimulatedMeasurement distribution.
List all qpu counts generated above.
References
References
◼
Logic Synthesis for Quantum State Generation paper by Philipp Niemann, Rhitam Datta,Robert Wille (2016 IEEE 46th International Symposium on Multiple-Valued Logic)
◼
Quantum state preparation with optimal circuits depth: Implementations and Applications by Xiao-Ming Zhang, Tongyang Li and Xiao Yuan (arXiv:2201.11495v3 [quant-ph] 5 Dec 2022
◼
Circuits for measurement based quantum state preparation paper by Niels Gleinig and Torsten Hoefler
Initialization cells
Initialization cells
CITE THIS NOTEBOOK
CITE THIS NOTEBOOK
Target probabilities with quantum circuits
by Shivam Sawarn
Wolfram Community, STAFF PICKS, May 3 2023
https://community.wolfram.com/groups/-/m/t/2913983
by Shivam Sawarn
Wolfram Community, STAFF PICKS, May 3 2023
https://community.wolfram.com/groups/-/m/t/2913983