Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Add option to no pad idle qubits in scheduling passes #725

Merged
merged 11 commits into from
Sep 22, 2023

Conversation

mtreinish
Copy link
Member

Summary

This commit adds a new flag to the scheduling padding passes, schedule_idle_qubits, which is used to opt-in to scheduling idle qubits. By default these passes will only schedule qubits which are active. This is a change in behavior from before where the previous default is all qubits were scheduled. This was undesirable because it's adding unnecessary instructions to the job payload which will need to be processed which are effectively a no-op. The only real use case for adding delays to idle wires is visualization, so it's left as an option to re-enable the previous default.

Details and comments

Fixes #723

This commit adds a new flag to the scheduling padding passes,
schedule_idle_qubits, which is used to opt-in to scheduling idle qubits.
By default these passes will only schedule qubits which are active. This
is a change in behavior from before where the previous default is all
qubits were scheduled. This was undesireable because it's adding
uneceesary instructions to the job payload which will need to be
processed which are effectively a no-op. The only real use case for
adding delays to idle wires is visualization, so it's left as an option
to re-enable the previous default.

Fixes Qiskit#723

Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>
@mtreinish mtreinish force-pushed the pad-idle-qubits-at-your-own-risk branch from 1eb804c to ba5e587 Compare September 12, 2023 19:24
@dieris
Copy link
Contributor

dieris commented Sep 12, 2023

This is great, thank you!

@@ -420,7 +437,7 @@ def _visit_control_flow_op(self, node: DAGNode) -> None:
self._add_block_terminating_barrier(block_idx, t0, node)

# Only pad non-fast path nodes
fast_path_node = node in self._fast_path_nodes
fast_path_node = node in self._fast_path_nodes or not self._schedule_idle_qubits
Copy link
Contributor

Choose a reason for hiding this comment

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

only nitpicking here, perhaps rename fast_path_node to skip_padding or something like that, as there are two different conditions for that to happen

Copy link
Contributor

@dieris dieris Sep 20, 2023

Choose a reason for hiding this comment

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

On a second thought, I'm not sure we want to disable padding within the control flow here. As a result of this (and related changes at L163-169), this circuit will miss padding (and potentially DD) in the conditional block:

creg = ClassicalRegister(1)
qreg = QuantumRegister(3)
circ = QuantumCircuit(qreg,creg)
circ.sx(qreg[0])
circ.x(qreg[1])
circ.sx(qreg[2])
circ.barrier()
circ.measure(0,creg[0])
with circ.if_test((creg[0], 0)):
    circ.x(qreg[1])

missing_padding

Whereas the expected behavior should be (reverting those changes):
correct_padding

@dieris
Copy link
Contributor

dieris commented Sep 20, 2023

I think

is missing the schedule_idle_qubits argument for the parent constructor

@dieris
Copy link
Contributor

dieris commented Sep 21, 2023

Linked PR: mtreinish#1

@kt474 kt474 requested a review from dieris September 22, 2023 13:40
@kt474 kt474 merged commit 84818f9 into Qiskit:main Sep 22, 2023
18 checks passed
kt474 added a commit that referenced this pull request Oct 25, 2023
* Update main 0.7.1 (#719)

* Fix typing in `DAGCircuit.apply_operation_back` (#721)

It is not valid typing (per the documentation) to pass `None` to
`DAGCircuit.apply_operation_back` in either the `qargs` or `cargs`
field, though this has been silently accepted previously to support
mistaken code in the Terra schedulers, which this repository has
inherited.

* Update serialization for non-basic types (#715)

* Update json.py

* Update json.py

* Added test for metadata serialization

* added release notes

* Moved test here from qiskit-ibm-runtime (#722)

* Moved here from qiskit-ibm-runtime

* Fixed imports

* Removed code related to Schedule (#724)

* Removed code related to Schedule, qubit_lo_freq, mea_lo_freq, schedule_los

* black and lint

* Returned lines in documentation that were removed by mistake

* Fixed documentation

* Put back range parameters

* Removed auth parameter and migrate method (#727)

* Removed auth parameter and migrate method

* Updated documentation

* black

* Remove `qiskit-ibmq-provider` from `requirements-dev.txt` (#729)

* Remove qiskit-ibmq-provider from requirements-dev.txt

* Remove IBMQ

* Breaking change in Qiskit 0.45 - Gate.duration setting (#732)

* breaking change in Qiskit 0.45

* black

* Bit.index is deprecated since Apr 2021 (#733)

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Update hms_to_seconds to support times greater than 1 day (#731)

* Update hms_to_seconds

* add reno

* Add option to no pad idle qubits in scheduling passes (#725)

* Add option to no pad idle qubits in scheduling passes

This commit adds a new flag to the scheduling padding passes,
schedule_idle_qubits, which is used to opt-in to scheduling idle qubits.
By default these passes will only schedule qubits which are active. This
is a change in behavior from before where the previous default is all
qubits were scheduled. This was undesireable because it's adding
uneceesary instructions to the job payload which will need to be
processed which are effectively a no-op. The only real use case for
adding delays to idle wires is visualization, so it's left as an option
to re-enable the previous default.

Fixes #723

Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>

* Add missing inline type hint

* Don't put barriers on idle qubits either

* Fix formatting

* Add schedule_idle_qubits to parent constructor

* Reneable padding in control flow

* Omit idle qubits in control flow

* Run black

---------

Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>
Co-authored-by: Diego Ristè <10402430+dieris@users.noreply.github.com>
Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Update test_jobs_filter (#738)

* readjust test_convert_id_to_delay (#739)

* readjust test_convert_id_to_delay

* disable not-context-manager

* duplicated entry

* Exceptions should inherit from Terra where suitable (#741)

* Changed inheritance of exception classes

* Changed error type

* Support method job.properties() (#742)

* Implemented job.properties() method

* release note

* Updated documentation

* Improved the tests

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* Use job creation date when returning backend properties in `job.properties()` (#746)

* use job creation date in properties

* add reno

* remove datetime param

* update test_job_backend_properties (#747)

* Support shots as np.int64 (#744)

* Fixed bug where shots defined as np.number

* Added test

* black

* add reno

---------

Co-authored-by: Kevin Tian <kevin.tian@ibm.com>

* use qpy.load from terra (#751)

* remove print statement in test (#752)

* Prepare release 0.7.1 (#753)

* Update main branch 0.7.2 (#754)

* migrate pypi trusted publisher (#750)

---------

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: ItamarGoldman <51112651+ItamarGoldman@users.noreply.github.com>
Co-authored-by: merav-aharoni <merav@il.ibm.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Thomas Alexander <thomas.a.alexander@ibm.com>
Co-authored-by: Diego Ristè <10402430+dieris@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Omit delays on unused qubits when padding with delays
3 participants