Cirqmon Devlog #7
So, I am posting this Devlog after interval of Almost 20 days since last Posted.
Why delay?
During this time I learnt a Lot about Quantum computing. Infact, I was planning to ship the Project with Single qubit gates only, but after I joined Qiskit Global Summer School, then I realised that main game in Quantum computing is about entanglement, that comes with multi Qubit gates like CX, CZ, SWAP etc.
The Media attached is Demo is of a GHZ circuit is made by combination of H gate and CNOT gates. Basically a GHZ state is larger version of Bell state. For N qubits, only two possible states shows Up with equal probability i.e 1/root2 (000…n + 111…n).
So here is What I made Changes and How :
1) 2 Qubit Gates Implementation -
So Earlier Version was for Only 1 Qubit Gates, and it used Tensor product. Where it used to tensor Each step and then Multiply each step to StateVector in successive manner.
But for 2 Qubit gates, tensor method gets problematic because multi qubit gates need to have dependence on other qubits too, meanwhile tensor assumes every gate on that step is independent and it builds large matrix.
This loses dependence and relation as demanded by multi qubit gates.
So then I got to know of approach called Embedding or Inflation where we first create Temporary matrix of 2^n rows and 2^n Columns with each entry initially as 0, then we start looping through columns of that Matrix (which represent possibility, like iteration for 0 is actually 00 in binary) and then, matching it with rows and columns in Gate matrix, after that we force the bit in Temporary Matrix’s respective column and row to align with what Gate’s matrix bit has? Either 0 or 1.
Finally we get Result of application in that Temporary matrix which we multiply with StateVector later on. That’s how This Inflation Approach works.
2) Applied Phase angle Indicator
Now, Quantum State’s node’s color in Q sphere shows its phase Angle, which can be from PI to -PI, calculated using formula tan2a(y,x), then we constraint it from 0 to 2PI, later convert to degrees, then feeding that value as HUE value in HSL colour format keeping lightness as 50% and Saturation 100% and then it corresponds to Phase Angle with color that degree, like 0deg is red, 90deg is green etc.
So this was Major Changes I did along with some Style changes and Minor error fixing that appeared during changing the Simulator’s Approach.
And to be very Honest at when I started to Write code for 2 qubit Gates, I earlier thought I would Do something that I dont have to change Simulator, but those were still just making me cry.
So finally I gone to AI to learn and for almost 2 days new experiments were going out of head and that way almost I wasted Hours and then to experiment more and Stop Tracking Hackatime since I knew It would track more hours for Experiments too, So I coded in Cursor (Without Any AI, Just as Other Editor) Untracked. At the End it worked :)
Now Finally Majority part is Done, after few More Edits, Will Ship it soon!