Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pipy: solving the images problem #15

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
![doc status badge](https://img.shields.io/github/actions/workflow/status/ColibrITD-SAS/mpqp/doc.yml?label=doc)
![pipy deployment status badge](https://img.shields.io/github/actions/workflow/status/ColibrITD-SAS/mpqp/pipy.yml?label=pipy)

![[alt:mpqp logo]](resources/dark-logo.png)
![[alt:mpqp logo]](resources/dark-logo.svg)

# The MPQP library

Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
# `html_theme` is not needed since we use a plugin to have the dark theme RTD,
# so `html_theme` is overridden anyway.
# html_theme = "alabaster"
# html_theme = "furo" # pip install furo
# html_theme = "sphinx_rtd_theme" # pip install sphinx-rtd-theme
html_context = {
"github_user": "ColibrITD",
"github_repo": "mpqp",
Expand Down
14 changes: 11 additions & 3 deletions mpqp/core/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
from matplotlib.figure import Figure
from qiskit.circuit import QuantumCircuit, Operation
from qiskit.circuit.quantumcircuit import CircuitInstruction

from qat.core.wrappers.circuit import Circuit as myQLM_Circuit
from braket.circuits import Circuit as braket_Circuit
from qiskit.quantum_info import Operator
from sympy import Basic, Expr
from typeguard import typechecked, TypeCheckError

Expand Down Expand Up @@ -643,17 +645,23 @@ def to_other_language(
Language.QISKIT, qiskit_parameters
)
assert isinstance(qiskit_inst, CircuitInstruction) or isinstance(
qiskit_inst, Operation
)
qiskit_inst, Operation) or isinstance(qiskit_inst, Operator)
cargs = []

if isinstance(instruction, ControlledGate):
if isinstance(instruction, CustomGate):
new_circ.unitary(instruction.to_other_language(), instruction.targets, instruction.label)
# FIXME: minus sign appearing when it should not, seems there a phase added somewhere, check u gate
# in OpenQASM translation.
continue
elif isinstance(instruction, ControlledGate):
qargs = instruction.controls + instruction.targets
elif isinstance(instruction, Gate):
qargs = instruction.targets
elif isinstance(instruction, BasisMeasure) and isinstance(
instruction.basis, ComputationalBasis
):
#TODO muhammad/henri, for custom basis, check if something should be changed here, otherwise remove
# the condition to have only computational basis
assert instruction.c_targets is not None
qargs = [instruction.targets]
cargs = [instruction.c_targets]
Expand Down
3 changes: 2 additions & 1 deletion mpqp/core/instruction/gates/custom_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)
from mpqp.core.languages import Language
from qiskit.circuit import Parameter
from qiskit.quantum_info.operators import Operator as QiskitOperator


@typechecked
Expand Down Expand Up @@ -39,7 +40,7 @@ def to_other_language(
):
if qiskit_parameters is None:
qiskit_parameters = set()
return super().to_other_language(language, qiskit_parameters)
return QiskitOperator(self.matrix)

def decompose(self):
"""Returns the circuit made of native gates equivalent to this gate.
Expand Down
14 changes: 13 additions & 1 deletion mpqp/core/instruction/gates/native_gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
from mpqp.tools.generics import Matrix
from mpqp.tools.maths import cos, sin, exp


@typechecked
def _qiskit_parameter_adder(param: Expr | float, qiskit_parameters: set[Parameter]):
"""To avoid having several parameters in qiskit for the same value we keep
Expand Down Expand Up @@ -194,6 +193,14 @@ def __init__(self, target: int):
SingleQubitGate.__init__(self, target, type(self).__name__)


class Id(OneQubitNoParamGate, InvolutionGate):
"""TODO hamza/muhammad
"""

qiskit_gate = ...
matrix = ...


class X(OneQubitNoParamGate, InvolutionGate):
"""One qubit X (NOT) Pauli gate.

Expand Down Expand Up @@ -625,3 +632,8 @@ def to_matrix(self) -> Matrix:
m = np.identity(8, dtype=complex)
m[-2:, -2:] = np.ones(2) - np.identity(2)
return m


NATIVE_GATES = [CNOT, CRk, CZ, H, Id, P, Rk, Rx, Ry, Rz, S, SWAP, T, TOF, U, X, Y, Z]
# TODO : check the possibility to detect when a custom gate can be defined as a native gate, problem with
# parametrized gates maybe
Binary file added resources/mpqp-usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
with open("README.md", "r") as f:
long_description = f.read()

long_description = long_description.replace(".svg", ".png").replace(".gif", ".png")

with open("LICENSE", "r") as f:
license = f.readline()

Expand Down
Loading