-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Primitives support the dynamic circuits with control flow #9231
Changes from 2 commits
ce4df59
83b9158
e82577a
3b9e5f9
aaacaa2
eaa5f4b
b7e3ebc
6623b99
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
features: | ||
- | | ||
Primitives support the dynamic circuits with control flow. | ||
If backend supports it, users can run the circuits using :class:`~BackendSampler` | ||
and :class:`~BackendEstimator`. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
|
||
"""Tests for Sampler.""" | ||
|
||
import json | ||
import unittest | ||
from test import combine | ||
|
||
|
@@ -783,6 +784,19 @@ def test_circuit_with_unitary(self): | |
sampler_result = sampler.run([circuit]).result() | ||
self.assertDictAlmostEqual(sampler_result.quasi_dists[0], {0: 1, 1: 0}) | ||
|
||
def test_circuit_key_controlflow(self): | ||
"""Test for a circuit with control flow.""" | ||
qc = QuantumCircuit(2, 1) | ||
|
||
with qc.for_loop(range(5)): | ||
qc.h(0) | ||
qc.cx(0, 1) | ||
qc.measure(0, 0) | ||
qc.break_loop().c_if(0, True) | ||
|
||
self.assertIsInstance(hash(_circuit_key(qc)), int) | ||
self.assertIsInstance(json.dumps(_circuit_key(qc)), str) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aer supports control flow - would it be possible to try executing a simple There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks. I'll try it. |
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change apply to only the
BackendSampler
andBackendEstimator
, or is this a general improvement that affects allBaseSampler
andBaseEstimator
subclasses?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. When I wrote this document, I thought that if a backend did not support control flow, primitives also did not support, but I was wrong.