Fix layer collisions in circuit drawer for nested BoxOp instructions#16568
Fix layer collisions in circuit drawer for nested BoxOp instructions#16568Prashik123 wants to merge 5 commits into
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 following people are relevant to this code:
|
|
|
There was a problem hiding this comment.
This PR pipes through a new qubit_mapping argument. But I am wondering:
Why not use the existing wire_map, which I think is exactly the same thing?
I'm also wondering if you checked whether this PR fixes the issue that was posted? Reading the diff, I don't see how it would.
Eventually, this PR will need a changelog and tests.

Description
Hello Team Qiskit! This PR addresses the visual collision bug in the circuit drawer where nested instructions inside block operations (like
BoxOp) would incorrectly overlap into a single layer.What was happening:
When the text drawer (and by extension, the MPL drawer) processed the body of a
BoxOpvia_get_layered_instructions, it calculated the instruction's span based entirely on the inner virtual qubits (e.g., 0, 1, 2). It didn't account for how those qubits were permuted or mapped to the parent circuit's physical wires, causing overlapping gates to mistakenly share the same visual layer.How it was fixed:
I updated the layout resolution logic to make it context-aware:
qubit_mappingparameter to_get_layered_instructions._LayerSpooler, allowing theinsertableand_any_crossoverchecks to evaluate the true physical span of nested operations based on the outer circuit.add_control_flowintext.pyto generate and pass this dictionary mapping when it recursively calls_get_layered_instructions.Fixes #16510
Use of AI Tools
_utils.pyandtext.py) and to troubleshoot local Rust environment compilation issues on Windows. All code changes submitted in this PR are my own original work. I have fully reviewed, tested, and understood the resulting fix, and it complies with the Qiskit license and CLA obligations.Pull Request Author Checklist
tox -elint/black/ruff).qubit_mappingparameter.Fixes #16510syntax to link it.