Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Add user-facing option to retrieve IR instead of API object #15

Open
dominikandreasseitz opened this issue Jul 16, 2024 · 0 comments
Assignees
Labels

Comments

@dominikandreasseitz
Copy link
Collaborator


from qadence2_expressions.core import compile, irc

phi = symbol("phi")
expr = RX(phi / 2)(1) * RY(phi / 2)(2)

# this compiles into IR and then into the native backend
api = compile(expr, backend='pyqtorch') 
wf = api.run()
expval = api.expectation()

#in case the user wants to debug or inspect the IR which is used to compile into the API object
ir_repr = irc(expr)

print(ir_repr)
>>>Model(
  register=AllocQubits(
    num_qubits=3,
    qubit_positions=[],
    grid_type=None,
    grid_scale=1.0,
    options={},
  ),
  inputs={},
  instructions=[
    Assign('%0', Call('mul', 0.5, Load('phi'))),
    QuInstruct('rx', Support(target=(1,)), Load('%0')),
    QuInstruct('ry', Support(target=(2,)), Load('%0')),
  ],
  directives={},
  settings={},
)

tagging @Roland-djee @Doomsk too

For debugging purposes
https://jax.readthedocs.io/en/latest/_autosummary/jax.make_jaxpr.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants