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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
* **Fixed** for any bug fixes.
* **Removed** for now removed features.

## [ M.m.P ] - [ YYYY-MM-DD ]

### Added

- The cycle time [seconds] can be set when instantiating the `QuantifySchedulerExporter` through the `cycle_time`
parameter.

## [ 0.9.0 ] - [ 2025-12-19 ]

### Added
Expand Down
15 changes: 10 additions & 5 deletions opensquirrel/passes/exporter/quantify_scheduler_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@


class QuantifySchedulerExporter(Exporter):
def __init__(self, operation_cycles: OperationCycles | None = None, **kwargs: Any) -> None:
def __init__(
self, cycle_time: float = CYCLE_TIME, operation_cycles: OperationCycles | None = None, **kwargs: Any
) -> None:
super().__init__(**kwargs)
self._cycle_time = cycle_time
self._operation_cycles = operation_cycles

def export(self, circuit: Circuit) -> quantify_scheduler.Schedule:
Expand All @@ -54,7 +57,7 @@ def export(self, circuit: Circuit) -> quantify_scheduler.Schedule:
# Obtain ALAP reference timing for schedulables
schedulables = list(schedule_creator.schedule.schedulables.values())
if schedulables:
scheduler = _Scheduler(circuit.register_manager, schedulables, self._operation_cycles)
scheduler = _Scheduler(circuit.register_manager, schedulables, self._cycle_time, self._operation_cycles)
circuit.ir.reverse().accept(scheduler)

# Update timing constraints of schedulables
Expand All @@ -79,9 +82,11 @@ def __init__(
self,
qubit_register_size: int,
schedulables: list[Schedulable],
cycle_time: float,
operation_cycles: OperationCycles | None,
) -> None:
self._schedulables = schedulables
self._cycle_time = cycle_time
self._operation_cycles = operation_cycles
self._cycles: list[int] = [0] * qubit_register_size
self._ref_index: list[int] = list(range(qubit_register_size))
Expand All @@ -106,7 +111,7 @@ def set_schedulable_timing_constraints(self, qubit_indices: list[int]) -> None:

operation_cycles = self._get_operation_cycles(schedulable) if ref_schedulable else 0
cycle = self._cycles[pertinent_qubit_index] + operation_cycles
waiting_time = -1.0 * ((cycle - operation_cycles) - ref_cycle) * CYCLE_TIME
waiting_time = -1.0 * ((cycle - operation_cycles) - ref_cycle) * self._cycle_time
self._set_timing_constraints(schedulable, ref_schedulable, waiting_time)

self._set_reference(qubit_indices, schedulable, cycle)
Expand Down Expand Up @@ -174,11 +179,11 @@ def __init__(
self,
register_manager: RegisterManager,
schedulables: list[Schedulable],
cycle_time: float,
operation_cycles: OperationCycles | None,
) -> None:
self._qubit_register_size = register_manager.qubit_register_size
self._operation_cycles = operation_cycles
self._operation_record = OperationRecord(self._qubit_register_size, schedulables, operation_cycles)
self._operation_record = OperationRecord(self._qubit_register_size, schedulables, cycle_time, operation_cycles)

@property
def operation_record(self) -> OperationRecord:
Expand Down
12 changes: 12 additions & 0 deletions tests/passes/exporter/test_quantify_scheduler_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,18 @@ def test_operation_timing(
_check_waiting_cycles(exported_schedule, expected_waiting_cycles)


def test_cycle_time(qs_is_installed: bool) -> None:
if qs_is_installed:
cycle_time = 10e-9
wait_cycles = 5
expected_relative_time = -1.0 * wait_cycles * cycle_time
circuit = Circuit.from_string(f"""version 3; qubit q; X q; wait({wait_cycles}) q; X q""")
exported_schedule = circuit.export(exporter=QuantifySchedulerExporter(cycle_time=cycle_time))
rel_time = next(iter(exported_schedule.schedulables.values()))["timing_constraints"][0].rel_time
assert cycle_time != CYCLE_TIME
assert rel_time == expected_relative_time


@pytest.fixture
def mock_qs() -> Generator[MagicMock, None, None]:
mock_qs = MagicMock()
Expand Down
Loading
Loading