Skip to content

Add ability to lower None as a compilable attribute value - #3196

Open
albi3ro wants to merge 5 commits into
mainfrom
lower-none
Open

Add ability to lower None as a compilable attribute value#3196
albi3ro wants to merge 5 commits into
mainfrom
lower-none

Conversation

@albi3ro

@albi3ro albi3ro commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

[sc-129640]

Context:

Changes performed by cursor.

The compilable argument indices to SumOfSlatersPrep can be tricky to find the right values for. We are going to want to be able to perform resource analysis on SumOfSlatersPrep with unknown values for indices. We don't have the ability yet to perform resource analysis without a truly valid decomposition rule, but we will probably add this support soon,.

In the meantime, we want to be able to at least capture and lower SumOfSlatersPrep with unknown indices, even if we can't do anything with it yet.

Description of the Change:

Adds the ability to lower None to a null value in MLIR.

Benefits:

Unblocks resource estimation on ops with unknown attributes in the future.

Together with changes in PL, I am able to do:

gate_set = {"QROM", "TemporaryAND", "Adjoint(TemporaryAND)", "MultiplexerStatePreparation", "CNOT", "X"}

@qp.qjit(capture=True)
@qp.qnode(qp.device("lightning.qubit", wires=21))
def circuit():
    qp.SumOfSlatersPrep(Float[8], Wire[7], indices=None)
    return qp.state()

print(circuit.mlir)
...
      qref.operator "SumOfSlatersPrep"(%1: tensor<8xcomplex<f64>>) qubits(%9, %10, %11, %12, %13, %14, %15)
        static_data = {indices = none}
        param_map = {coefficients = [0]} qubit_map = {wires = [0, 1, 2, 3, 4, 5, 6]}
...

Possible Drawbacks:

We could also represent "missing" attributes by just omitting them from the mlir. This is another way of dealing with null valued attributes in MLIR. But I think I prefer explicilty having it for now.

I'm trying to find a good discussion around using NoneType versus omitting the attribute versus something else, but I can't seem to find anything besides what Gemini is telling me.

Related GitHub Issues:

Comment thread doc/releases/changelog-dev.md
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.64%. Comparing base (cd27370) to head (9cbd634).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3196      +/-   ##
==========================================
+ Coverage   95.61%   95.64%   +0.02%     
==========================================
  Files         177      177              
  Lines       20854    20856       +2     
  Branches     2100     2101       +1     
==========================================
+ Hits        19939    19947       +8     
+ Misses        726      722       -4     
+ Partials      189      187       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants