Skip to content

Commit

Permalink
fix: update batch circuit to limit repeat calls (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
math411 committed Jan 30, 2024
1 parent 6f20c32 commit 058108c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/braket/aws/aws_quantum_task_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,27 +150,36 @@ def _tasks_and_inputs(
]:
inputs = inputs or {}

max_inputs_tasks = 1
single_task = isinstance(
task_specifications,
(Circuit, Problem, OpenQasmProgram, BlackbirdProgram, AnalogHamiltonianSimulation),
)
single_input = isinstance(inputs, dict)

max_inputs_tasks = (
max(max_inputs_tasks, len(task_specifications)) if not single_task else max_inputs_tasks
)
max_inputs_tasks = (
max(max_inputs_tasks, len(inputs)) if not single_input else max_inputs_tasks
)

if not single_task and not single_input:
if len(task_specifications) != len(inputs):
raise ValueError(
"Multiple inputs and task specifications must " "be equal in number."
)

if single_task:
task_specifications = repeat(task_specifications)
task_specifications = repeat(task_specifications, times=max_inputs_tasks)

if single_input:
inputs = repeat(inputs)
inputs = repeat(inputs, times=max_inputs_tasks)

tasks_and_inputs = zip(task_specifications, inputs)

if single_task and single_input:
tasks_and_inputs = [next(tasks_and_inputs)]
tasks_and_inputs = list(tasks_and_inputs)

tasks_and_inputs = list(tasks_and_inputs)

Expand Down

0 comments on commit 058108c

Please sign in to comment.