amazon-braket / amazon-braket-sdk-python

A Python SDK for interacting with quantum devices on Amazon Braket
https://aws.amazon.com/braket/
Apache License 2.0
300 stars 118 forks source link

Consider allowing gates to be called with an empty list of target qubits #996

Open Manvi-Agrawal opened 3 months ago

Manvi-Agrawal commented 3 months ago

Describe the feature you'd like Currently a gate cannot be called with an empty list of target qubits. It might be nice for this to be allowed, but to generate no instructions in the resulting program.

How would this feature be used? Please describe. A circuit may be built programmatically, with gates added to lists of qubits that are determined dynamically. If some of these lists are empty, it may be convenient to still call the function to add the gate, rather than first checking to see if the list is empty.

Describe alternatives you've considered A user could work around this by ensuring that they do not call gates with an empty list of target qubits.

Additional context See comment thread here: https://github.com/amazon-braket/amazon-braket-sdk-python/pull/993#discussion_r1628310002

Manvi-Agrawal commented 3 months ago

@jcjaskula-aws created this issue for the edge case discovered by you here. https://github.com/amazon-braket/amazon-braket-sdk-python/pull/993#discussion_r1628310002