Skip to content

Conversation

kdk
Copy link
Member

@kdk kdk commented Dec 10, 2020

Summary

Following #5498 , updates converters, quantum_info, assembler, circuit library and scheduler to support optional registers, and to prefer inspecting bits over registers where possible.

Details and comments

on-hold until #5498 merges.

Commits in this PR (without #5498 and #5486 ): https://github.com/Qiskit/qiskit-terra/pull/5504/files/18c95db0f2daef7fe52674ca1ec7fb5e7f1eae3e..5c5ac703ff05a25bdea6ae57346440d15d45033f

Copy link
Contributor

@taalexander taalexander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scheduling sections look good to me.

@kdk kdk force-pushed the quantumcircuit-optional-registers-converters branch from 6a9408e to 4df285c Compare January 20, 2021 22:17
@kdk kdk force-pushed the quantumcircuit-optional-registers-converters branch from 4df285c to 31cf7a5 Compare February 24, 2021 20:30
@kdk kdk removed the on hold Can not fix yet label Feb 24, 2021
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, but the only thing that sticks out to me is a potential optimization, this PR is basically building a (qu)bit map dictionary everywhere things are accessed by bit. I'm wondering it makes more sense to stick that in the circuit itself so all these places can just access it instead of creating it on the fly everywhere.

I know that means we have 3 views of a the bits in a circuit which seems like a headache. But maybe we can combine _qubit_set and the map (like add a getter for qubit set that returns set(map)).

@@ -92,14 +81,13 @@ def find_bit_position(bit):
if gate.num_qubits > 0:
q = QuantumRegister(gate.num_qubits, 'q')

qubit_map = {bit: q[idx] for idx, bit in enumerate(circuit.qubits)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it makes sense to carry this around in the circuit object itself (maybe as a private). Pretty much anything that is going from a circuit to something else is now building this dict.

@kdk
Copy link
Member Author

kdk commented Feb 25, 2021

I know that means we have 3 views of a the bits in a circuit which seems like a headache. But maybe we can combine _qubit_set and the map (like add a getter for qubit set that returns set(map)).

I agree, and the cost of keeping these in sync was why I held off initially (this was before the addition of _qubit_set), assuming that if generating these dicts were impacting performance, they could be consolidated as a private attribute later. I can add a PR to the end of the set to clean these up (and consolidate with _qubit_set) unless you think its better to fix them now.

@mtreinish
Copy link
Member

I would probably just do it in this PR I feel like that'll be simpler unless it has implications for the next patches in the series.

@kdk
Copy link
Member Author

kdk commented Feb 26, 2021

I would probably just do it in this PR I feel like that'll be simpler unless it has implications for the next patches in the series.

I'm a little worried about introducing more conflicts with the remaining PRs, maybe as part of #5868 ?

@mtreinish
Copy link
Member

I would probably just do it in this PR I feel like that'll be simpler unless it has implications for the next patches in the series.

I'm a little worried about introducing more conflicts with the remaining PRs, maybe as part of #5868 ?

Ok sure sounds good, then this LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: None Do not include in changelog optional-registers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants