Skip to content

Commit

Permalink
Keep na arch alive 2 (#474)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsschmid authored Jun 14, 2024
1 parent cdc8caf commit cb55d55
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/python/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,8 @@ PYBIND11_MODULE(pyqmap, m) {
"Neutral Atom Hybrid Mapper that can use both SWAP gates and AOD "
"movements to map a quantum circuit to a neutral atom quantum computer.")
.def(py::init<const na::NeutralAtomArchitecture&, na::MapperParameters>(),
"Create Hybrid NA Mapper with mapper parameters", "arch"_a,
"Create Hybrid NA Mapper with mapper parameters",
py::keep_alive<1, 2>(), py::keep_alive<1, 3>(), "arch"_a,
"params"_a = na::MapperParameters())
.def("set_parameters", &na::NeutralAtomMapper::setParameters,
"Set the parameters for the Hybrid NA Mapper", "params"_a)
Expand Down
21 changes: 21 additions & 0 deletions test/python/test_hybridmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,24 @@ def test_hybrid_na_mapper(
assert results["totalExecutionTime"] > 0
assert results["totalIdleTime"] > 0
assert results["totalFidelities"] > 0


def _nested_mapper_create() -> HybridNAMapper:
"""Create a nested Neutral Atom hybrid architecture."""
arch = NeutralAtomHybridArchitecture(str(arch_dir / "rubidium.json"))
params = HybridMapperParameters()
return HybridNAMapper(arch, params=params)


def test_keep_alive() -> None:
"""Test the keep alive feature of the python bindings."""
mapper = _nested_mapper_create()

qc = QuantumCircuit.from_qasm_file(str(circuit_dir / "dj_nativegates_rigetti_qiskit_opt3_10.qasm"))

mapper.map(qc)
results = mapper.schedule(create_animation_csv=False)

assert results["totalExecutionTime"] > 0
assert results["totalIdleTime"] > 0
assert results["totalFidelities"] > 0

0 comments on commit cb55d55

Please sign in to comment.