Skip to content
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
5 changes: 3 additions & 2 deletions qoolqit/execution/compilation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
class CompilerProfile(Enum):
"""Enum for the different compilation profiles."""

WORKING_POINT = "working_point"
DEFAULT = "default"
MAX_ENERGY = "max_energy"
WORKING_POINT = DEFAULT # deprecated alias for DEFAULT


def _build_register(register: Register, device: Device, distance: float) -> PulserRegister:
Expand Down Expand Up @@ -94,7 +95,7 @@ def basic_compilation(
maximum allowed amplitude.
- If the device requires a layout, it is automatically generated.
"""
if profile == CompilerProfile.WORKING_POINT:
if profile == CompilerProfile.DEFAULT:
TIME, ENERGY, DISTANCE = device.converter.factors
_validate_program_default_profile(register, drive, device, device_max_duration_ratio)
elif profile == CompilerProfile.MAX_ENERGY:
Expand Down
13 changes: 6 additions & 7 deletions qoolqit/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ def __repr__(self) -> str:
def compile_to(
self,
device: Device,
profile: (
Literal["max_energy", "working_point"] | CompilerProfile
) = CompilerProfile.MAX_ENERGY,
profile: Literal["default", "max_energy"] | CompilerProfile = CompilerProfile.DEFAULT,
device_max_duration_ratio: float | None = None,
) -> None:
"""Compiles the quantum program for execution on a specific device.
Expand All @@ -102,13 +100,14 @@ def compile_to(

There are two compilation profiles:

- "default": Compile the program as it is. The drive and the register positions
must respect the hardware constraints of the device which can be inspected
using `device.specs()`. The `CompilerProfile.WORKING_POINT` is deprecated
aliases for this profile.
- "max_energy": Scale the program to utilize the device's
maximum capabilities. The drive amplitude and the register positions are rescaled
to achieve respectively the maximum amplitude and the minimum pairwise distance
compatible with the input program and the device's constraints.
- "working_point": Compile the program as it is. The drive and the register positions
must respect the hardware constraints of the device which can be inspected
using `device.specs()`.

The following option does NOT preserve the input program, but rather adapts the program
to the device's constraints. Programs compiled this way are not portable across devices.
Expand All @@ -120,7 +119,7 @@ def compile_to(
Args:
device: The target device for compilation. Must be a QoolQit Device.
profile: The compilation profile used to translate the program.
Defaults to CompilerProfile.MAX_ENERGY.
Defaults to CompilerProfile.DEFAULT.
device_max_duration_ratio: The fraction of the device's maximum allowed duration
to set the program duration to, or None to leave it unset. Must be a number
in the range (0, 1]. Can only be set if the device has a maximum allowed
Expand Down
17 changes: 14 additions & 3 deletions tests/test_compilation/test_compile_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@

@pytest.mark.parametrize(
"profile",
[CompilerProfile.MAX_ENERGY, CompilerProfile.WORKING_POINT, "max_energy", "working_point"],
[
CompilerProfile.MAX_ENERGY,
CompilerProfile.DEFAULT,
"max_energy",
"default",
],
)
def test_compilation_single_qubit(
profile: Literal["max_energy", "working_point"] | CompilerProfile,
profile: Literal["max_energy", "default"] | CompilerProfile,
) -> None:
"""Test compilation of a single-qubit program."""
register = Register(qubits={"q0": (0.0, 0.0)})
Expand All @@ -33,6 +38,12 @@ def test_compilation_single_qubit(
assert program.is_compiled


def test_compiler_profile_deprecated_working_point_alias() -> None:
"""Test that WORKING_POINT is aliases of DEFAULT."""
assert CompilerProfile.WORKING_POINT is CompilerProfile.DEFAULT
assert CompilerProfile("default") is CompilerProfile.DEFAULT


def test_compile_to_invalid_profile_string() -> None:
"""Test compilation with an invalid profile string alias."""
register = Register(qubits={"q0": (0.0, 0.0)})
Expand All @@ -53,7 +64,7 @@ def test_dmm_not_supported() -> None:
program.compile_to(device=AnalogDevice())


@pytest.mark.parametrize("profile", [CompilerProfile.MAX_ENERGY, CompilerProfile.WORKING_POINT])
@pytest.mark.parametrize("profile", [CompilerProfile.MAX_ENERGY, CompilerProfile.DEFAULT])
def test_compilation_with_dmm(profile: CompilerProfile) -> None:
"""Test compilation of a program with a DMM."""
register = Register(qubits={"q0": (0.0, 0.7), "q1": (-0.5, -0.5), "q2": (0.5, -0.5)})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Test the WORKING_POINT compilation profile."""
"""Test the DEFAULT compilation profile."""

from __future__ import annotations

Expand All @@ -23,7 +23,7 @@


class TestWorkingPointCompilerProfile:
profile = CompilerProfile.WORKING_POINT
profile = CompilerProfile.DEFAULT

@pytest.fixture(autouse=True)
def program_factory(
Expand Down
Loading