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

[Feature] Diagonal operation handling #277

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Merge remote-tracking branch 'origin/main' into cm/opti_diagonal
Charles MOUSSA committed Sep 5, 2024

Verified

This commit was signed with the committer’s verified signature.
snyk-bot Snyk bot
commit 7d3f1724efe0da4a8213dd9367f31935c7240169
6 changes: 3 additions & 3 deletions pyqtorch/primitives/parametric.py
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ def __init__(
generator: str | Tensor,
qubit_support: int | tuple[int, ...] | Support,
param_name: str | int | float | torch.Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
):
"""Initializes Parametric.
@@ -224,7 +224,7 @@ def __init__(
control: int | Tuple[int, ...],
target: int | Tuple[int, ...],
param_name: str | int | float | torch.Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
):
"""Initializes a ControlledParametric.
@@ -311,7 +311,7 @@ def __init__(
control: int | Tuple[int, ...],
target: int,
param_name: str | int | float | torch.Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
):
"""Initializes a ControlledRotationGate.
8 changes: 4 additions & 4 deletions pyqtorch/primitives/parametric_gates.py
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ def __init__(
self,
target: int,
param_name: str | int | float | torch.Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
"""Initializes RZ.
@@ -167,7 +167,7 @@ def __init__(
self,
target: int,
param_name: str | int | float | torch.Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
):
"""Initializes PHASE.
@@ -336,7 +336,7 @@ def __init__(
control: int | tuple[int, ...],
target: int,
param_name: str | int | float | Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
"""Initializes controlled RZ.
@@ -392,7 +392,7 @@ def __init__(
control: int | tuple[int, ...],
target: int,
param_name: str | int | float | Tensor = "",
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
"""Initializes controlled PHASE.
4 changes: 2 additions & 2 deletions pyqtorch/primitives/primitive.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ def __init__(
operation: Tensor,
qubit_support: int | tuple[int, ...] | Support,
generator: Tensor | None = None,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
) -> None:
super().__init__(
@@ -80,7 +80,7 @@ def __init__(
operation: str | Tensor,
control: int | tuple[int, ...],
target: int | tuple[int, ...],
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
):
support = Support(target, control)
14 changes: 7 additions & 7 deletions pyqtorch/primitives/primitive_gates.py
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ class Z(Primitive):
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -56,7 +56,7 @@ class I(Primitive): # noqa: E742
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -80,7 +80,7 @@ class T(Primitive):
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -95,7 +95,7 @@ class S(Primitive):
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -111,7 +111,7 @@ class SDagger(Primitive):
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -150,7 +150,7 @@ class N(Primitive):
def __init__(
self,
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
@@ -212,7 +212,7 @@ def __init__(
self,
control: int | tuple[int, ...],
target: int,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = True,
):
super().__init__(
2 changes: 1 addition & 1 deletion pyqtorch/quantum_operation.py
Original file line number Diff line number Diff line change
@@ -120,7 +120,7 @@ def __init__(
operation: Tensor,
qubit_support: int | tuple[int, ...] | Support,
operator_function: Callable | None = None,
noise: NoiseProtocol | dict[str, NoiseProtocol] | None = None,
noise: NoiseProtocol | None = None,
diagonal: bool = False,
) -> None:
"""Initializes QuantumOperation
You are viewing a condensed version of this merge commit. You can view the full changes here.