When converting wires (null_wire) to wire sets (borrow_wire), we are mapping from the domain of an unlimited number of qubits to the domain of a finite (and small) number of qubits. At this point, the circuit is no longer target agnostic. The number of qubits, their interconnect, etc. ought to be defined by the target.
At present, it is assumed that this sort of mapping from the virtual domain to the actual target is done very late in the compilation process. It is further assumed that it must be done exhaustively and that the quantum program must consist of exactly 1 function. None of these assumptions need to be true and each may unjustifiably limit the general applicability and solution space of the IR.
For example, it may be the case that we want the quantum program to consist of separate functions. Or we may want to incrementally map some functions or phases of functions from the virtual/infinite qubit domain but not others. Or CUDA-Q may want to allow the programmer to explicitly map a qubit variable to a target qubit in the source code.
These considerations can and may change the implementation of passes such as wires to wire sets.
When converting wires (null_wire) to wire sets (borrow_wire), we are mapping from the domain of an unlimited number of qubits to the domain of a finite (and small) number of qubits. At this point, the circuit is no longer target agnostic. The number of qubits, their interconnect, etc. ought to be defined by the target.
At present, it is assumed that this sort of mapping from the virtual domain to the actual target is done very late in the compilation process. It is further assumed that it must be done exhaustively and that the quantum program must consist of exactly 1 function. None of these assumptions need to be true and each may unjustifiably limit the general applicability and solution space of the IR.
For example, it may be the case that we want the quantum program to consist of separate functions. Or we may want to incrementally map some functions or phases of functions from the virtual/infinite qubit domain but not others. Or CUDA-Q may want to allow the programmer to explicitly map a qubit variable to a target qubit in the source code.
These considerations can and may change the implementation of passes such as wires to wire sets.
_Originally posted by @schweitzpgi in https://github.com/NVIDIA/cuda-quantum/pull/2163#discussion_r1733529671_