diff --git a/qoolqit/execution/compilation_functions.py b/qoolqit/execution/compilation_functions.py index dff4ba245..457d857d8 100644 --- a/qoolqit/execution/compilation_functions.py +++ b/qoolqit/execution/compilation_functions.py @@ -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: @@ -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: diff --git a/qoolqit/program.py b/qoolqit/program.py index a8235f66c..4946dd613 100644 --- a/qoolqit/program.py +++ b/qoolqit/program.py @@ -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. @@ -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. @@ -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 diff --git a/tests/test_compilation/test_compile_to.py b/tests/test_compilation/test_compile_to.py index 593e270b0..2c6323c80 100644 --- a/tests/test_compilation/test_compile_to.py +++ b/tests/test_compilation/test_compile_to.py @@ -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)}) @@ -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)}) @@ -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)}) diff --git a/tests/test_compilation/test_working_point.py b/tests/test_compilation/test_default.py similarity index 98% rename from tests/test_compilation/test_working_point.py rename to tests/test_compilation/test_default.py index e1864d09f..61424c34d 100644 --- a/tests/test_compilation/test_working_point.py +++ b/tests/test_compilation/test_default.py @@ -1,4 +1,4 @@ -"""Test the WORKING_POINT compilation profile.""" +"""Test the DEFAULT compilation profile.""" from __future__ import annotations @@ -23,7 +23,7 @@ class TestWorkingPointCompilerProfile: - profile = CompilerProfile.WORKING_POINT + profile = CompilerProfile.DEFAULT @pytest.fixture(autouse=True) def program_factory(