Investigate pyqir.SimpleModule
as return type instead of pyqir.Module
#187
Labels
discussion
Needs further discussion
enhancement
New feature or request
pyqir
Interfacing with QIR python bindings
In our functions
cirq_to_qir
andqasm3_to_qir
, we currently return apyqir.Module
, which takes a "context" of typepyqir.Context
and a "name" of typestr
. However, it might be worth considering whether we should return apyqir.SimpleModule
instead.The
pyqir.SimpleModule
accepts a "context" object and "name," but it also requires an integer number of qubits, an integer number of results, and an optional entrypoint name (which defaults to "main"). Unlikepyqir.SimpleModule
, thepyqir.Module
does not store any entrypoint name. The qiskit_qir.to_qir_module() function returns a list of tuples containing entrypoint name strings andpyqir.Module
objects. However, they could have instead just return a list ofpyqir.SimpleModule
objects, each of which would already have a.entry_point
property.Through our Cirq and OpenQASM 3 to QIR conversions, we can easily derive the values needed for the additional fields required to create a
pyqir.SimpleModule
. Furthermore, all the examples I’ve encountered (e.g., thepyqir
README) indicate thatpyqir.SimpleModule
is the intended user-facing class, whilepyqir.Module
appears to be more of a low-level construct.For instance,
pyqir.SimpleModule.bitcode()
supports Python type hints, whereaspyqir.Module.bitcode
does not. Thepyqir.SimpleModule
also provides several user-facing methods that are not present inpyqir.Module
. Furthermore, thepyqir.SimpleModule._module
property ultimately returns apyqir.Module
, meaning that adoptingSimpleModule
would not lose any information.Given these points, returning a
SimpleModule
instead of a plainModule
seems like it would be a meaningful enhancement with minimal cost, aligning better with the intended usage patterns and providing additional functionality to users.The text was updated successfully, but these errors were encountered: