Getting specs using catalyst

Hi,

I am trying to get the specs for a catalyst program but i am getting an error when i try to get the specs. Here is the code. What could be causing this?:

from catalyst import qjit, measure
import pennylane as qml
from jax import numpy as jnp
@qjit
@qml.qnode(qml.device("lightning.qubit", wires=5))
def circuit():
  qml.CNOT([0,1])
  measure(0)
  return qml.expval(qml.PauliZ(0))

qml.specs(circuit)()

AttributeError Traceback (most recent call last)
in <cell line: 12>()
10 return qml.expval(qml.PauliZ(0))
11
—> 12 qml.specs(circuit)()

/usr/local/lib/python3.10/dist-packages/pennylane/transforms/specs.py in specs_qnode(*args, **kwargs)
112 qnode.max_expansion = initial_max_expansion if max_expansion is None else max_expansion
113 qnode.expansion_strategy = expansion_strategy or initial_expansion_strategy
→ 114 qnode.construct(args, kwargs)
115 finally:
116 qnode.max_expansion = initial_max_expansion

AttributeError: ‘QJIT’ object has no attribute ‘construct’

Hey, @Mushahid_Khan. So qjit gives you a QJIT object, but qml.specs needs to be run on a QNode.
I think the best you can do to get the specs is to forgo the qjit-ing on the circuit you’re looking at. With the most recent (this week’s) PennyLane and Catalyst versions (v0.34 and v0.4), you can do this:

import pennylane as qml
from catalyst import measure

@qml.qnode(qml.device("lightning.qubit", wires=5))
def circuit():
  qml.CNOT([0,1])
  qml.measure(0)
  return qml.expval(qml.PauliZ(0))

qml.specs(circuit)()

But if you’d want to qjit without getting to the specs, your circuit would look like this:

@qml.qjit
@qml.qnode(qml.device("lightning.qubit", wires=5))
def circuit():
  qml.CNOT([0,1])
  measure(0)
  return qml.expval(qml.PauliZ(0))

Is there a specific reason you’d want to have the specs while running qjit?