This week marks the halfway point of GSOC 2024, and the project has successfully met its midway goal of completing the development of the Matplotlib Renderer: MatRenderer
. Moving forward, my primary focus will be on the Text Based Renderer
, which is the major goal for the second half of the project, along with some additional functionalities.
It has been an amazing experience contributing to GSOC'24 at QuTiP so far, and I am excited to continue making progress.
What did I do this week?
Moving LaTeX plotting
Most of my effort week-6 went into understanding and moving the LaTeX code to its separate file from
circuit.py
totexrenderer.py
. A separate class,TeXRenderer
, was also created to further organize the code.Updating the Wire Rendering of MatRenderer
In Week-6, I also updated the
extende_wire()
function for wire rendering. This change eliminated overlaping wire renderings and calls for extension of wires after each layer rendering. Now, the entire wire is only drawn at the end, after all the gates are rendered.Built a proof of Concept for Text Rendering
As previously mentioned, using functions from the MatRenderer class for the text renderer is the best approach for future code maintenance. During week-7, I developed a basic prototype to show how this concept works. At the moment, this prototype is implemented for the Single Qubit Gate. It effectively reuses the layer management functions in MatRenderer, specifically the
manage_layers()
andx_skip()
functions.
Circuit Representation Example
{: [render for the top of the 1st wire, 2nd wire, 3rd wire ...],
top: [render for the middle of the 1st wire, 2nd wire, 3rd wire ...],
mid: [render for the bottom of the 1st wire, 2nd wire, 3rd wire ...],
bot }
Better Examples
Example-1
= QubitCircuit(2)
qc qc.add_gate("H", targets=[0])
qc.add_gate("RZ", targets=[1], arg_value=0.1)
┌───┐ :───┤ H ├───
q0
└───┘
┌────┐ :───┤ RZ ├──
q2 └────┘
This would be stored as
{: [" ┌───┐ ", " ┌────┐ "],
top: ["q0 :───┤ H ├───", "q2 :───┤ RZ ├──"],
mid: [" └───┘ ", " └────┘ "],
bot }
Example 2
= QubitCircuit(1)
qc qc.add_gate("H", targets=[0])
qc.add_gate("H", targets=[0])
┌───┐ ┌───┐ :───┤ H ├──┤ H ├─
q0 └───┘ └───┘
The layer increment would look like,
# STEP 1
{: [" "],
top: ["q0 :──"],
mid: [" "]
bot
}
# STEP 2
{: [" ┌───┐ "],
top: ["q0 :───┤ H ├─"],
mid: [" └───┘ "]
bot
} # STEP 1
{: [" ┌───┐ ┌───┐ "],
top: ["q0 :───┤ H ├──┤ H ├─"],
mid: [" └───┘ └───┘ "]
bot }
Plan for Next Week
- Develop the base class for both
MatRenderer
andTextRenderer
. - Implement tests for
MatRenderer
. - Add alignment options for gate layers to ensure gates in a layer are centered relative to each other.
- Investigate and implement multi-qubit gate support in the text renderer.
- Finalize moving code from
latex_circuit.py
totexrenderer.py
. - Organize fixed constants in
MatRenderer
using a style dictionary or data class.