Logo Lanfrica

Congorico/Quantum-Qubit-Control-via-Reinforcement-Learning-Q-Learning-

Record type:

software
Creator:
Con
Host:
I am Wesley, a high school student from Mozambique passionate about Quantum Computing. This repository contains a custom-built environment and a Reinforcement Learning (RL) agent that learns how to control and manipulate a quantum state vector to reach a target state # Quantum-Qubit-Control-via-Reinforcement-Learning-Q-Learning- I am Wesley, a high school student from Mozambique passionate about Quantum Computing. This repository contains a custom-built environment and a Reinforcement Learning (RL) agent that learns how to control and manipulate a quantum state vector to reach a target state. PROJECT OVERVIEW In quantum computing, precise control over qubits is a major hurdle due to environmental noise and decoherence. This project models qubit gate operations as a Markov Decision Process (MDP). Instead of using pre-made packages, I built the quantum simulator environment from scratch using NumPy, modeling custom x and y quantum rotation matrices. A classical Q-Learning agent is then trained using the Bellman Equation to find the optimal sequence of actions to bring the qubit from the $|0\rangle$ state to the $|1\rangle$ state. How it Works * **The Environment (`QubitEnv`):** Represents a single qubit initialized at $|0\rangle = \begin{bmatrix} 1 \\ 0 \end{bmatrix}$. * **Actions:** * `0`: Rotate around the X-axis ($R_x$ gate by $\pi/4$). * `1`: Rotate around the Y-axis ($R_y$ gate by $\pi/4$). * `2`: Idle / Do nothing. * **State Representation:** The state space is currently discretized based on the measurement probability of finding the qubit in the $|1\rangle$ state ($P(|1\rangle) = |\beta|^2$). * **Reward Structure:** $+10.0$ for reaching the target $|1\rangle$ state (State 4); a $-1.0$ time penalty step cost for any other action to encourage the fastest path. ## 📊 Resulting Q-Table Strategy After training for 100 episodes, the agent successfully maps out the optimal path. Below is the learned policy: ```text Estado Qubit | Ação Rx | Ação Ry | Ação Esperar [ Estado 0 | 0.0324695 | 0.3118172 | -1.2448976 ] <-- Learns 'Idle' is bad [ Estado 1 | 1.1293062 | 1.4752965 | 0.4319453 ] [ Estado 2 | 3.0631197 | 2.8210319 | 2.0836904 ] [ Estado 3 | 5.1771489 | 5.7098559 | 4.5731829 ] <-- Prefers Ry rotation near ta …