Skip to content

Commit

Permalink
Merge pull request #220 from oqc-community/fix/ker/post_processing_fix
Browse files Browse the repository at this point in the history
Fix post-processing missing from map and add test.
  • Loading branch information
keriksson-rosenqvist authored Oct 14, 2024
2 parents 2d01bfc + f3d74e8 commit c8c272e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"Daria Van Hende <dvanhende@oxfordquantumcircuits.com>, "
"Luke Causer <lcauser@oxfordquantumcircuits.com>"
)
release = version = "2.2.0"
release = version = "2.2.1"
add_module_names = False
autoclass_content = "both"
smv_remote_whitelist = None
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name = "qat-compiler"
# This name has the -compiler suffix in order to use the poetry and twine tools to build and publish to PyPI
# witout having to manually adjust the dist file names.
version = "2.2.0"
version = "2.2.1"
description = "A low-level quantum compiler and runtime which facilitates executing quantum IRs."
readme = "README.rst"
documentation = "https://oqc-community.github.io/qat"
Expand Down
5 changes: 2 additions & 3 deletions src/qat/purr/compiler/instructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ class PostProcessing(QuantumInstruction):
"""

def __init__(self, acquire: Acquire, process, axes=None, args=None):
super().__init__()
super().__init__(acquire)
if axes is not None and not isinstance(axes, List):
axes = [axes]

Expand All @@ -412,11 +412,10 @@ def __init__(self, acquire: Acquire, process, axes=None, args=None):
self.axes: List[ProcessAxis] = axes or []
self.output_variable = acquire.output_variable
self.result_needed = False
self._acquire = acquire

@property
def acquire(self) -> Acquire:
return self._acquire
return self.quantum_targets[0]

def __repr__(self):
axis = ",".join([axi.value for axi in self.axes])
Expand Down
38 changes: 38 additions & 0 deletions tests/qat/test_quantum_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@
from qat.purr.compiler.emitter import InstructionEmitter, QatFile
from qat.purr.compiler.hardware_models import QuantumHardwareModel
from qat.purr.compiler.instructions import (
Acquire,
Delay,
DrivePulse,
MeasurePulse,
PhaseReset,
PhaseShift,
PostProcessing,
SweepValue,
Variable,
)
Expand Down Expand Up @@ -677,3 +681,37 @@ def test_empty_channels_removed(self):
for p in positions
]
)

def test_create_duration_timeline_mapping(self):
"""Test that instructions are correctly mapped to expected channels."""
hw = get_test_model()
qubit = hw.get_qubit(0)

builder = (
get_builder(hw).X(qubit, np.pi / 2.0).measure_mean_z(qubit).synchronize(qubit)
)
engine = get_test_execution_engine(hw)
qat_file = InstructionEmitter().emit(builder.instructions, hw)

position_map = engine.create_duration_timeline(qat_file.instructions)

drive_data = position_map[qubit.get_drive_channel()]
measure_data = position_map[qubit.get_measure_channel()]
acquire_data = position_map[qubit.get_acquire_channel()]

assert [type(pos.instruction) for pos in drive_data] == [
DrivePulse,
Delay,
PhaseReset,
]
assert [type(pos.instruction) for pos in measure_data] == [
Delay,
MeasurePulse,
PhaseReset,
]
assert [type(pos.instruction) for pos in acquire_data] == [
Delay,
Acquire,
PhaseReset,
*[PostProcessing] * 4,
]

0 comments on commit c8c272e

Please sign in to comment.