Quforge

Latest version: v0.3.4

Safety actively analyzes 723217 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 2

0.3.4

This version fixes some bugs, updates the docs and the readability of the code.

Additionally, we added a function to each gate where users can extract the matrix representation of the gate directly with gate.matrix(), for instance:


H = qf.H() creates the Hadamard gate
matrix = H.matrix()
print(matrix)

0.3.3

We're excited to announce a major update: **multidimensional qudit support** is now fully integrated into QuForge!

With this new feature, you can mix qudits of different dimensions in a single circuit. All functions and classes that use the dim argument now accept either a single integer (for uniform qudit dimensions) or a list of integers (to specify individual qudit dimensions). This flexibility allows you to build smaller, more efficient Hilbert spaces by assigning only the dimensions you actually need.

Example Usage:

Below is an example of how to create a circuit and a state with qudit dimensions 2, 3, and 2, respectively:


import quforge.quforge as qf
circuit = qf.Circuit(dim=[2,3,2], wires=3)
circuit.H(index=[0])
circuit.CNOT(index=[0, 1])
state = qf.State('0-1-0', dim=[2,3,2])
result = circuit(state)
print(result)


This update enables you to tailor the Hilbert space to your specific needs without being constrained to qudits of the same dimension. Enjoy the new flexibility and efficiency in your quantum circuits!

0.3.1

As we prepare the QuForge for new features, we made some changes to the structure of the library. Instead of having almost everything into a single python file, version 0.3.0 separates the features of the library into distinct files:

- aux.py: some auxilar functions to help the library work properly
- circuit.py: contains everything related to the circuit class
- cml.py: contains functions related to classical machine learning
- gates.py: this is the most important file, it contains all quantum gates the library has
- optimizer.py: functions for optimizing gates and circuits
- quforge.py: this file puts the most important things into a single nomenclature
- statevector.py: eveything related to state vectors

With this, if you want to create a state you can do it in two ways: using the quforge or statevector file:

bash
import quforge.quforge as qf
state = qf.State('0')


or

bash
import quforge.statevector as sv
state = sv.State('0')


And if you want to create and apply a gate, you can do it in three ways: using the quforge, gates or circuit file:

bash
import quforge.quforge as qf
H = qf.H()
output = H(state)


bash
import quforge.quforge as qf
circuit = qf.Circuit()
circuit.H()
output = circuit(state)


bash
import quforge.gates as gates
H = gates.H()
output = H(state)


bash
import quforge.circuit as circuit
circuit = circuit.Circuit()
circuit.H()
output = H(state)


All of them lead to the same results, so is up to user to choose which one is preferable.

0.2.1

This version adds a way to visualize vector states as a latex expression in a Jupyter notebook.

With a notebook open, you can visualize this as:

bash
import quforge.statevector as sv
from IPython.display import Math

Math(sv.show(state, dim=dim, wires=wires))


There are a few options in the show class that allows the user to have more control over showing the state:
- tol: Tolerance below which amplitudes are considered zero.
- use_floats: If True, display amplitudes as floating point numbers.
- float_precision: The number of significant digits for floats.
- emphasize_index: If an integer is provided, the specified index is factored out and emphasized.
- suppress_inner: If True (and emphasize_index is not None), the non-emphasized part is replaced by a placeholder ket (e.g. $|\phi_1\rangle, |\phi_2\rangle$, etc.) instead of showing its full expansion.

0.2.0

This version has the following changes:

- Bug fix in the controlled rotation gates where if the target index was smaller than the control index, it would throw an error.

- Now you do not need to specify anymore the number of wires of the custom gate using the circuit class:

Before:

bash
circuit = qf.Circuit(dim=qudit_dimension, wires=your_number_of_qudits)
circuit.Custom(matrix, wires=your_number_of_qudits)


After
bash
circuit = qf.Circuit(dim=qudit_dimension, wires=your_number_of_qudits)
circuit.Custom(matrix)


- Added the controlled universal gate. This gate is the controlled version of the universal gate, you need to specify which control states will be used in order to apply the universal gate on the target qudit. For instance:

bash
dim = 3
wires = 2
CU = qf.CU(dim=dim, index=[0,1], control_state=[1])
initial_state = qf.State('1-0', dim=dim)
output_state = CU(initial_state)
print(output_state)


In the code above, only when the control qudit has state |1> then the universal gate will be applied on the targert qudit.

or

bash
dim = 3
wires = 2
CU = qf.CU(dim=dim, index=[0,1], control_state=[1,2])
initial_state = qf.State('1-0', dim=dim)
output_state = CU(initial_state)
print(output_state)


Now, the universal gate will be applied on the target qudit if control qudit has either the states |1> or |2>.

0.1.13

This version fixes a problem when specifying manually the angle parameters of the rotation gates. Now these gates receives explicitly the number of qudits (wires) of the circuit.

Additionally, we have implemented a experimental gate called "Universal Gate", that parameterize the entire Hilbert space, allowing building highly expressive circuits. You can use it stand alone as:

bash
U = qf.U(dim=dim, wires=wires)


or inside a circuit, for instance:

bash
circuit = qf.Circuit(dim=2, wires=3)
circuit.U()
state = qf.State('0-0-0')
circuit(state)

Page 1 of 2

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.