Graph Generation for Quantum States Using Qiskit and Its Application for Quantum Neural Networks
Abstract
:1. Introduction
2. Materials and Methods
2.1. Project Description
- Each node holds the information corresponding to a quantum circuit: number of qubits, used gates, and amplitudes for each state;
- Each transition is represented by a quantum gate acting on one or more qubits;
- Each intermediate state is analyzed even if a single gate was applied as part of a sequence of gates;
- The newly-obtained state after applying a quantum gate is first verified through the already existing states before deciding if it should be added as a new node in the graph, not as circuit design (applied quantum gates) but by using the Statevector amplitudes (represented in Qiskit using a list containing the amplitudes for the possible states).
2.2. IBM’s Framework Presentation
2.3. Implementation Details
2.3.1. Statevector Example
- —amplitude approximately 0.707 (, so the probability is );
- —amplitude 0 (and probability 0);
- —amplitude 0 (and probability 0);
- —amplitude approximately 0.707 (, so the probability is ).
2.3.2. Class Diagram
- The QuantumGate class with the following fields:
- The type of gate used (a simple string);
- The cost;
- The QuantumState class with the following fields:
- A unique state ID;
- The minimum cost of reaching that state with the selected gates;
- The size of the quantum register on which we apply different gates (number of qubits);
- The quantum circuit, which is an instance of the QuantumCircuit class (from Qiskit; see [18] for details);
- The quantum register, which is an instance of the QuantumRegister class (see [19]);
- The statevector, which is an instance of the Statevector class (see [20]);
- The QuantumTransition class with the following fields:
- The current state, which is an instance of the QuantumState class;
- The next state, which is an instance of the QuantumState class;
- The used gate, which is an instance of the QuantumGate class;
- A list of indices showing the qubits from the quantum register on which the gate is applied;
- The QuantumGraph class with only one field as follows:
- The data structure for the actual graph is a dictionary, where the keys are represented by QuantumState objects, and the values are represented by lists of QuantumTransition instances; the idea is to group all the transitions that have the same starting state as values for the same key. A list containing QuantumTransition objects could also be used to directly represent the graph, but in this case, each transition would have to be interrogated in order to filter the transitions by the starting state.
- Single-qubit gates: X (NOT), Z, and H;
- Multiple-qubit gates: CNOT and CCNOT.
- The number of qubits for the register;
- The initial state—either by setting the statevector or by applying a different number of gates;
- The cost of the initial state;
- The cost of the quantum gates—depending on the architecture of the used device, these parameters have different values, and by updating them, the actual minimum cost can be found;
- The quantum gates that should be used for the exploration.
3. Results
- The register size is set to 1 qubit;
- The initial state is set to ;
- The cost of the initial state is set to 0 (the default value);
- The default cost of each gate is set to 1 (for testing purposes);
- The selected quantum gates are the X (NOT), Z, and Hadamard gates.
- For the state with ID = 0: ;
- For the state with ID = 1: ;
- For the state with ID = 2: ;
- For the state with ID = 3: ;
- For the state with ID = 4: ;
- For the state with ID = 5: ;
- For the state with ID = 6: ;
- For the state with ID = 7: .
4. Potential Applications and Future Ideas
4.1. General Use Case
- State <ID = 0>—previous state: none/initial state;
- State <ID = 1>—previous state <ID = 0>;
- State <ID = 2>—previous state <ID = 0>;
- State <ID = 3>—previous state <ID = 2>;
- State <ID = 4>—previous state <ID = 1>;
- State <ID = 5>—previous state <ID = 4>;
- State <ID = 6>—previous state <ID = 4>;
- State <ID = 7>—previous state <ID = 6>.
- State <ID = 0>—adding a X gate on qubit [0] => state <ID = 1>;
- State <ID = 1>—adding a Z gate on qubit [0] => state <ID = 4>;
- State <ID = 4>—adding a X gate on qubit [0] => state <ID = 5>;
- State <ID = 5>—adding a H gate on qubit [0] => state <ID = 7>.
4.2. Application in Neural Networks
- The first step consists of generating the exploration graph, using a starting state as close to the one desired (if this is possible by using a heuristic function; otherwise, we can use a default or a random state); if the exploration graph becomes too large, or the processing power exceeds the available resources, multiple solutions could be employed, such as a circuit depth limit or by stopping the program after running for a limited time. We also accept this as a compromise, as not building all quantum states could imply missing the target one;
- The second step is the design of the neural network on top of the built graph; in other words, we can use the graph as a potential solution for the inner neuron layers. This kind of solution means that we are able to not only detect the desired quantum state but also have available the gate route to reach it. Combining this architecture with the cost concept would result in an optimized solution. (The cost concept can also be replaced with other ideas, as discussed.)
- First of all, a set of parameters is considered in order to generate the graph according to the constraints of the available quantum processor;
- The graph needs to be analyzed, at different depths, in order to identify and build the corresponding quantum circuits for the superposition states, starting with the obtained Statevector values (if possible, in order to ensure that the quantum properties are used to accelerate the search); otherwise, a neural network such as the one presented is recommended for more complex cases;
- Depending on the problem that needs to be solved, the validation function is designed, and then, a quantum oracle is created (); this component answers to the question of whether the candidate state is a potential solution—multiple solutions are possible for certain problems. In case of a higher complexity, multiple quantum oracles should be proposed and sequentially applied, each filtering the solutions and mapping to a validation function. A separate qubit, , is used to indicate that a solution has been found (for an oracle); an extension of the CCNOT gate can be used to chain together multiple validation qubits;
- The neural network block (or quantum circuit architecture using entangled states) is connected to the input of the oracle;
- At last, as in every quantum circuit, the simulation should take place multiple times using the selected device or simulator, and then, the measurement results should be interpreted.
5. Conclusions
Funding
Data Availability Statement
Conflicts of Interest
Appendix A
- 1.
- State <ID = 0>
- Statevector: [1 + 0j 0 + 0j]
- Min cost: 0
- Next state <ID = 1>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [0 + 0j 1 + 0j]
- Min cost: 1
- Next state <ID = 0>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [1 + 0j 0 + 0j]
- Min cost: 0
- Next state <ID = 2>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 1
- 2.
- State <ID = 1>
- Statevector: [0 + 0j 1 + 0j]
- Min cost: 1
- Next state <ID = 0>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [1 + 0j 0 + 0j]
- Min cost: 0
- Next state <ID = 4>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [ 0 + 0j −1 + 0j]
- Min cost: 2
- Next state <ID = 3>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 2
- 3.
- State <ID = 2>
- Statevector: [0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 1
- Next state <ID = 2>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 1
- Next state <ID = 3>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 2
- Next state <ID = 0>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [1 + 0j 0 + 0j]
- Min cost: 0
- 4.
- State <ID = 3>
- Statevector: [0.70710678 + 0j —0.70710678 + 0j]
- Min cost: 2
- Next state <ID = 6>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 3
- Next state <ID = 2>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 1
- Next state <ID = 1>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [0 + 0j 1 + 0j]
- Min cost: 1
- 5.
- State <ID = 4>
- Statevector: [0 + 0j −1 + 0j]
- Min cost: 2
- Next state <ID = 5>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [−1 + 0j 0 + 0j]
- Min cost: 3
- Next state <ID = 1>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [0 + 0j 1 + 0j]
- Min cost: 1
- Next state <ID = 6>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 3
- 6.
- State <ID = 5>
- Statevector: [−1 + 0j 0 + 0j]
- Min cost: 3
- Next state <ID = 4>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [0 + 0j −1 + 0j]
- Min cost: 2
- Next state <ID = 5>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [−1 + 0j 0 + 0j]
- Min cost: 3
- Next state <ID = 7>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 4
- 7.
- State <ID = 6>
- Statevector: [−0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 3
- Next state <ID = 3> —adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 2
- Next state <ID = 7>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 4
- Next state <ID = 4>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [0 + 0j −1 + 0j]
- Min cost: 2
- 8.
- State <ID = 7>
- Statevector: [−0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 4
- Next state <ID = 7>—adding a x gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j −0.70710678 + 0j]
- Min cost: 4
- Next state <ID = 6>—adding a z gate (cost = 1) on qubit(s) [0]
- Statevector: [−0.70710678 + 0j 0.70710678 + 0j]
- Min cost: 3
- Next state <ID = 5>—adding a h gate (cost = 1) on qubit(s) [0]
- Statevector: [−1 + 0j 0 + 0j]
- Min cost: 3
References
- IBM Unveils 400 Qubit-Plus Quantum Processor and Next-Generation IBM Quantum System Two. Available online: https://newsroom.ibm.com/2022-11-09-IBM-Unveils-400-Qubit-Plus-Quantum-Processor-and-Next-Generation-IBM-Quantum-System-Two (accessed on 23 January 2023).
- Hello, Many Worlds|TensorFlow Quantum. Available online: https://www.tensorflow.org/quantum/tutorials/hello_many_worlds (accessed on 23 January 2023).
- Schuld, M.; Sinayskiy, I.; Petruccione, F. The quest for a Quantum Neural Network. Quantum Inf. Process. 2014, 13, 2567–2586. [Google Scholar] [CrossRef] [Green Version]
- Li, P.; Xiao, H.; Shang, F.; Tong, X.; Li, X.; Cao, M. A hybrid quantum-inspired neural networks with sequence inputs. Neurocomputing 2013, 117, 81–90. [Google Scholar] [CrossRef]
- Lazzarin, M.; Galli, D.E.; Prati, E. Multi-class quantum classifiers with tensor network circuits for quantum phase recognition. Phys. Lett. A 2022, 434, 128056. [Google Scholar] [CrossRef]
- Situ, H.; He, Z.; Wang, Y.; Li, L.; Zheng, S. Quantum generative adversarial network for generating discrete distribution. Inf. Sci. 2020, 538, 193–208. [Google Scholar] [CrossRef]
- Zhou, N.-R.; Zhang, T.-F.; Xie, X.-W.; Wu, J.-Y. Hybrid quantum–classical generative adversarial networks for image generation via learning discrete distribution. Signal Process. Image Commun. 2023, 110, 116891. [Google Scholar] [CrossRef]
- Liu, L.; Song, T.; Sun, Z.; Lei, J. Quantum generative adversarial networks based on Rényi divergences. Phys. A 2022, 607, 128169. [Google Scholar] [CrossRef]
- Zheng, J.; Gao, Q.; Lü, J.; Ogorzałek, M.; Pan, Y.; Lü, Y. Design of a quantum convolutional neural network on quantum circuits. J. Franklin Inst. 2022. [Google Scholar] [CrossRef]
- Dias, E.D.M.; Vellasco, M.M.B.R.; da Cruz, A.V.A. Quantum-inspired neuro coevolution model applied to coordination problems. Expert Syst. Appl. 2021, 167, 114133. [Google Scholar] [CrossRef]
- Mojrian, M.; Mirroshandel, S.A. A novel extractive multi-document text summarization system using quantum-inspired genetic algorithm: MTSQIGA. Expert Syst. Appl. 2021, 171, 114555. [Google Scholar] [CrossRef]
- Cui, Y.; Shi, J.; Wang, Z. Complex Rotation Quantum Dynamic Neural Networks (CRQDNN) using Complex Quantum Neuron (CQN): Applications to time series prediction. Neural Netw. 2015, 71, 11–26. [Google Scholar] [CrossRef] [PubMed]
- Paquet, E.; Soleymani, F. QuantumLeap: Hybrid quantum neural network for financial predictions. Expert Syst. Appl. 2022, 195, 116583. [Google Scholar] [CrossRef]
- Ajagekar, A.; You, F. Quantum computing based hybrid deep learning for fault diagnosis in electrical power systems. Appl. Energy 2021, 303, 117628. [Google Scholar] [CrossRef]
- Huang, D.; Wang, M.; Wang, J.; Yan, J. A survey of quantum computing hybrid applications with brain-computer interface. Cognit. Rob. 2022, 2, 164–176. [Google Scholar] [CrossRef]
- Konar, D.; Bhattacharyya, S.; Gandhi, T.K.; Panigrahi, B.K. A Quantum-Inspired Self-Supervised Network model for automatic segmentation of brain MR images. Appl. Soft Comput. 2020, 93, 106348. [Google Scholar] [CrossRef]
- Qiskit. Open-Source Quantum Development. Available online: https://qiskit.org (accessed on 23 January 2022).
- Qiskit. QuantumCircuit. Available online: https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumCircuit.html (accessed on 23 January 2023).
- Qiskit. QuantumRegister. Available online: https://qiskit.org/documentation/stubs/qiskit.circuit.QuantumRegister.html (accessed on 23 January 2023).
- Qiskit. Statevector. Available online: https://qiskit.org/documentation/stubs/qiskit.quantum_info.Statevector.html (accessed on 23 January 2023).
- itertools—Functions Creating Iterators for Efficient Looping–Python 3.11.1 Documentation. Available online: https://docs.python.org/3/library/itertools.html (accessed on 23 January 2023).
- PlantUML Integration-IntelliJ IDEs Plugin|Marketplace. Available online: https://plugins.jetbrains.com/plugin/7017-plantuml-integration (accessed on 23 January 2023).
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the author. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Tudorache, A.-G. Graph Generation for Quantum States Using Qiskit and Its Application for Quantum Neural Networks. Mathematics 2023, 11, 1484. https://doi.org/10.3390/math11061484
Tudorache A-G. Graph Generation for Quantum States Using Qiskit and Its Application for Quantum Neural Networks. Mathematics. 2023; 11(6):1484. https://doi.org/10.3390/math11061484
Chicago/Turabian StyleTudorache, Alexandru-Gabriel. 2023. "Graph Generation for Quantum States Using Qiskit and Its Application for Quantum Neural Networks" Mathematics 11, no. 6: 1484. https://doi.org/10.3390/math11061484
APA StyleTudorache, A. -G. (2023). Graph Generation for Quantum States Using Qiskit and Its Application for Quantum Neural Networks. Mathematics, 11(6), 1484. https://doi.org/10.3390/math11061484