-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add flag to filter faulty qubits and gates to BackendV2Converter #9911
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
Conversation
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the the following people are requested to review this:
|
Pull Request Test Coverage Report for Build 4618888219
💛 - Coveralls |
This commit adds a flag to filter faulty qubits or gates from the created target when using `BackendV2Converter`. The BackendProperties object had a rarely used feature to annotate qubits or gates as being non-operational and previously the BackendV2Converter would unconditionally include qubits and gates with this flag set in the output Target and BackendV2 instance. This new flag will enable users to filter these if that is more desireable behavior. When filtering is set the backend will still be listed as full width but any faulty qubits will just not include any operations. Fixes Qiskit#9910
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.
This looks relatively straightforwards to me. Transpilation can't succeed on faulty qubits in this form until we have #9840 as well, but I checked that this produces backends that are correctly handled end-to-end in transpile
if there's faulty gates but the coupling map is still connected.
For example (Yorktown is a 5q bowtie with qubit 2 at the centre):
import datetime
import itertools
from qiskit import QuantumCircuit, transpile
from qiskit.providers.fake_provider import FakeYorktown
from qiskit.providers.models import BackendProperties
from qiskit.providers import BackendV2Converter
non_operational = {
"date": datetime.datetime.now(),
"name": "operational",
"unit": "",
"value": 0,
}
def remove_gate(backend):
props = backend.properties().to_dict()
for gate in props["gates"]:
if tuple(sorted(gate["qubits"])) == (0, 1):
gate["parameters"].append(non_operational)
backend._properties = BackendProperties.from_dict(props)
return backend
def connected(n):
out = QuantumCircuit(n)
for x, y in itertools.product(range(n), range(n)):
if x == y:
continue
out.cx(x, y)
return out
transpiled = transpile(
connected(5),
BackendV2Converter(remove_gate(FakeYorktown()), filter_faulty=True),
initial_layout=[0, 1, 2, 3, 4],
)
connections = [tuple(sorted(transpiled.find_bit(q).index for q in x.qubits)) for x in transpiled.data]
assert (0, 1) not in connections
It might be nice to add an integration test to that effect, since we're anticipating this kind of thing being useful to providers. We could also potentially look to merge #9840 ahead of this, and then also add a similar test that a faulty qubit isn't assigned any operations, etc.
I don't feel super strongly, though, so I'd be ok merging as-is if there's a better PR ordering.
I'll add a test based on your code here. It's good to test that. We can expand the testing further after #9840 merges to test with disconnected faulty qubits. I left out the full path testing because I was waiting for #9840 but I hadn't considered having a connected coupling graph with a faulty edge like that. |
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
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.
Looks good to me. As you say, we can add more tests after we've got proper disjoint-map support.
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
…kit#9911) * Add flag to filter faulty qubits and gates to BackendV2Converter This commit adds a flag to filter faulty qubits or gates from the created target when using `BackendV2Converter`. The BackendProperties object had a rarely used feature to annotate qubits or gates as being non-operational and previously the BackendV2Converter would unconditionally include qubits and gates with this flag set in the output Target and BackendV2 instance. This new flag will enable users to filter these if that is more desireable behavior. When filtering is set the backend will still be listed as full width but any faulty qubits will just not include any operations. Fixes Qiskit#9910 * Add full path transpile tests Co-authored-by: Jake Lishman <jake.lishman@ibm.com> --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes.
* Filter/ignore qubits in Target without any operations Building off #9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from #9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes. * Expand testing * Make filtered qubit coupling map a Target.build_coupling_map option This commit reworks the logic to construct a filtered coupling map as an optional argument on `Target.build_coupling_map()`. This makes the filtering a function of the Target object itself, which is where the context/data about which qubits support operations or not lives. The previous versions of this PR had a weird mix of responsibilities where the target would generate a coupling map and then we'd pass the target to that coupling map to do an additional round of filtering on it. * Apply suggestions from code review Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix incorrect set construction * Expand docstring on build_coupling_map argument * Rework logic in vf2 passes for filtering * Update argument name in disjoint_utils.py * Inline second argument for require_layout_isolated_to_component Co-authored-by: Kevin Hartman <kevin@hart.mn> * Update qiskit/transpiler/passes/layout/vf2_post_layout.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> * Remove unnecessary len() * Inline second arg for dense_layout too --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Kevin Hartman <kevin@hart.mn>
…kit#9911) * Add flag to filter faulty qubits and gates to BackendV2Converter This commit adds a flag to filter faulty qubits or gates from the created target when using `BackendV2Converter`. The BackendProperties object had a rarely used feature to annotate qubits or gates as being non-operational and previously the BackendV2Converter would unconditionally include qubits and gates with this flag set in the output Target and BackendV2 instance. This new flag will enable users to filter these if that is more desireable behavior. When filtering is set the backend will still be listed as full width but any faulty qubits will just not include any operations. Fixes Qiskit#9910 * Add full path transpile tests Co-authored-by: Jake Lishman <jake.lishman@ibm.com> --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
* Filter/ignore qubits in Target without any operations Building off Qiskit#9840 which adds full path support in all the preset pass managers for targetting backends with a disconnected coupling graph, this commit adds support for ignoring qubits that do not support any operations. When a Target is generated from Qiskit#9911 with `filter_faulty` set to `True` this will potentially result in qubits being present in the `Target` without any supported operations. In these cases the layout passes in the transpiler might inadvertently use these qubits only to fail in the basis translator because there are no instructions available. This commit adds filtering of connected components from the list of output connected components if the `Target` does have any supported instructions on a qubit. This works by building a copy of the coupling map's internal graph that removes the nodes which do not have any supported operations. Then when we compute the connected components of this graph it will exclude any components of isolated qubits without any operations supported. A similar change is made to the coupling graph we pass to rustworkx.vf2_mapping() inside the vf2 layout family of passes. * Expand testing * Make filtered qubit coupling map a Target.build_coupling_map option This commit reworks the logic to construct a filtered coupling map as an optional argument on `Target.build_coupling_map()`. This makes the filtering a function of the Target object itself, which is where the context/data about which qubits support operations or not lives. The previous versions of this PR had a weird mix of responsibilities where the target would generate a coupling map and then we'd pass the target to that coupling map to do an additional round of filtering on it. * Apply suggestions from code review Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> * Fix incorrect set construction * Expand docstring on build_coupling_map argument * Rework logic in vf2 passes for filtering * Update argument name in disjoint_utils.py * Inline second argument for require_layout_isolated_to_component Co-authored-by: Kevin Hartman <kevin@hart.mn> * Update qiskit/transpiler/passes/layout/vf2_post_layout.py Co-authored-by: Kevin Hartman <kevin@hart.mn> * Apply suggestions from code review Co-authored-by: Kevin Hartman <kevin@hart.mn> * Remove unnecessary len() * Inline second arg for dense_layout too --------- Co-authored-by: John Lapeyre <jlapeyre@users.noreply.github.com> Co-authored-by: Kevin Hartman <kevin@hart.mn>
…kit/qiskit#9911) * Add flag to filter faulty qubits and gates to BackendV2Converter This commit adds a flag to filter faulty qubits or gates from the created target when using `BackendV2Converter`. The BackendProperties object had a rarely used feature to annotate qubits or gates as being non-operational and previously the BackendV2Converter would unconditionally include qubits and gates with this flag set in the output Target and BackendV2 instance. This new flag will enable users to filter these if that is more desireable behavior. When filtering is set the backend will still be listed as full width but any faulty qubits will just not include any operations. Fixes Qiskit/qiskit#9910 * Add full path transpile tests Co-authored-by: Jake Lishman <jake.lishman@ibm.com> --------- Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Summary
Add flag to filter faulty qubits and gates to BackendV2Converter
This commit adds a flag to filter faulty qubits or gates from the
created target when using
BackendV2Converter
. The BackendPropertiesobject had a rarely used feature to annotate qubits or gates as being
non-operational and previously the BackendV2Converter would
unconditionally include qubits and gates with this flag set in the
output Target and BackendV2 instance. This new flag will enable users to
filter these if that is more desireable behavior. When filtering is set
the backend will still be listed as full width but any faulty qubits
will just not include any operations.
Details and comments
Fixes #9910