Skip to content

Commit

Permalink
bubble up the API to QuantumComputer
Browse files Browse the repository at this point in the history
  • Loading branch information
MarquessV committed Mar 8, 2024
1 parent 72fccca commit 09f6ef4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
9 changes: 3 additions & 6 deletions docs/source/programs_and_gates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,10 @@ filled in for, say, 200 values between :math:`0` and :math:`2\pi`. We demonstrat
# Generate a memory map for each set of parameters we want to execute with
memory_maps = [{"theta": [theta] for theta in np.linspace(0, 2 * np.pi, 200)}]

# Begin batch execution of the program using each set of parameters.
# This returns a list of references to each job, the length and order of which correspond to the memory maps we
# Batch execute of the program using each set of parameters.
# This returns a list of results for each execution, the length and order of which correspond to the memory maps we
# pass in.
handles = qc.execute_with_memory_map_batch(executable, memory_maps)

# Use the handles to gather the results
parametric_measurements = [qc.get_result(handles) for handle in handles]
parametric_measurements = qc.run_with_memory_map_batch(executable, memory_maps)

.. note::

Expand Down
3 changes: 1 addition & 2 deletions pyquil/api/_qam.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@ def execute_with_memory_map_batch(
How these programs are batched and executed is determined by the executor. See their respective documentation
for details.
Returns a list of ``QAMExecutionResult``, which can be used to fetch
results in ``QAM#get_result``.
Returns a list of handles that can be used to fetch results with ``QAM#get_result``.
"""

@abstractmethod
Expand Down
17 changes: 17 additions & 0 deletions pyquil/api/_quantum_computer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
Any,
Tuple,
Iterator,
Iterable,
Optional,
Set,
Union,
Expand Down Expand Up @@ -141,6 +142,22 @@ def run(
"""
return self.qam.run(executable, memory_map, **kwargs)

def run_with_memory_map_batch(
self, executable: QuantumExecutable, memory_maps: Iterable[MemoryMap], **kwargs: Any
) -> List[QAMExecutionResult]:
"""
Run a QuantumExecutable with one or more memory_maps, returning a list of results corresponding to the length
and order of the given MemoryMaps.
How these programs are batched and executed is determined by the executor. See their respective documentation
for details.
Returns a list of ``QAMExecutionResult``, which can be used to fetch
results in ``QAM#get_result``.
"""
handles = self.qam.execute_with_memory_map_batch(executable, memory_maps, **kwargs)
return [self.qam.get_result(handle) for handle in handles]

def calibrate(self, experiment: Experiment) -> List[ExperimentResult]:
"""
Perform readout calibration on the various multi-qubit observables involved in the provided
Expand Down

0 comments on commit 09f6ef4

Please sign in to comment.