Skip to content

Conversation

@josephleekl
Copy link
Contributor

@josephleekl josephleekl commented Oct 21, 2025

Context:
This is the first of 2 PRs to implement the 'Gridsynth' pass in Catalyst. (Second PR). This PR only contains the MLIR pass itself, and a dummy implementation of the actual runtime discretization function in order to test the data transfer between the MLIR and the C++ runtime. The actual discretization runtime, along with python tests, will be part of the next PR.

This branch needs to be used in conjunction with the rs-decomp branch in PennyLane.

To test this:

import pennylane as qml
from functools import partial

qml.capture.enable()

@qml.qjit(verbose=True, keep_intermediate=True)
@partial(qml.transforms.gridsynth, epsilon=0.12345, ppr_basis=False)
@qml.qnode(qml.device("null.qubit", wires=1))
def circuit(x):
    qml.RZ(x, 0)
    return qml.expval(qml.Z(0))

x = 1.1
print(circuit(x))

Description of the Change:

Benefits:

Possible Drawbacks:

Related GitHub Issues:

[sc-102150]

@josephleekl josephleekl changed the title RS decomposition [WIP] Gridsynth decomposition Oct 29, 2025
@josephleekl josephleekl changed the title [WIP] Gridsynth decomposition [WIP - Gridsynth 1] Gridsynth decomposition Oct 30, 2025
Copy link
Contributor

@sengthai sengthai left a comment

Choose a reason for hiding this comment

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

Nice~ I have a few comments. 🚀

paul0403 added a commit that referenced this pull request Dec 4, 2025
**Context:**
One of the first steps in the compilation pipeline is
`--inline-nested-modules`. This pass lifts the per-qnode module up into
the global module of the qjit.

Because (usually) the symbol table of a module is isolated from above,
multiple modules in parallel may contain the same names inside.
Therefore when inlining child modules into the global module, we need to
rename them to unique names.

However, there's a small problem. Each qnode module has their own
specific transform sequence, so the quantum passes (applied during
`--apply-transform-sequence`) have to be resolved before
`--inline-nested-module`. If a pass generates a function declaration to
an external API (e.g. runtime functions), that name must not be altered.

**Description of the Change:**
Do not perform renaming on external function declarations from within
the qnode modules during `--inline-nested-modules`.
Only inline the first occurrence of such func decls from the qnode
modules into the global qjit module.

**Benefits:**
Quantum passes that generate calls to other APIs can work.  
The flipside is also true! API developers do not have to maintain
multiple aliases for their API functions (e.g. gridsynth pass #2140 )

[sc-105020]

---------

Co-authored-by: Joseph Lee <[email protected]>
Copy link
Contributor

@sengthai sengthai left a comment

Choose a reason for hiding this comment

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

Thanks @josephleekl for this PR~ 🔥✨

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants