From 5ddde161a422a0f8d8da17512614fc29622d9e94 Mon Sep 17 00:00:00 2001 From: Jon Donovan Date: Thu, 7 Apr 2022 14:43:38 -0700 Subject: [PATCH] Use run_batch in cirq.Sampler (#678) --- tensorflow_quantum/core/ops/cirq_ops.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tensorflow_quantum/core/ops/cirq_ops.py b/tensorflow_quantum/core/ops/cirq_ops.py index 8048582f9..2650e812b 100644 --- a/tensorflow_quantum/core/ops/cirq_ops.py +++ b/tensorflow_quantum/core/ops/cirq_ops.py @@ -529,10 +529,11 @@ def _no_grad(grad): else: # All other cirq.Samplers handled here. - #TODO(zaqqwerty): replace with run_batch once Cirq #3148 is resolved cirq_results = [] - for p, r in zip(programs, resolvers): - cirq_results.append(sampler.run(p, r, num_samples)) + for results in sampler.run_batch(programs, + params_list=resolvers, + repetitions=num_samples): + cirq_results.extend(results) results = [] for r in cirq_results: