You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running a workload using both Catalyst's autograph and PennyLane capture the performance is on-par with both options disabled. Enabling either of the options individually gives an improvement to the runtime.
fromtimeitimportdefault_timerastimerimportpennylaneasqmlfromcatalystimportaccelerateimportjaxfromjaximportnumpyasjnpimportsys@accelerate(dev=jax.devices("cpu")[0])defclassical_fn(x):
returnjnp.sin(x) **2defprogram(r1, r2, op, **kwargs):
@qml.qjit(autograph=kwargs["use_ag"])deffunc(r1, r2):
dev=qml.device("lightning.qubit", wires=12)
@qml.qnode(dev)defcircuit(r1, r2):
forjinrange(1):
foriinrange(10):
op(wires=i)
qml.Rot(*r1, wires=i)
qml.Rot(*r2, wires=i)
qml.Hadamard(wires=i)
return [qml.expval(qml.PauliZ(i)) foriinrange(1)]
returncircuit(r1, r2)
returnclassical_fn(jnp.sum(jnp.array(func(r1, r2))))
if__name__=="__main__":
iflen(sys.argv) <3:
print("Run the script as: `python script.py X Y`, where X=0/1 disables/enables program capture and Y=0/1 enables/disables QJIT autograph")
ifint(sys.argv[1])==1:
use_capture=Trueqml.capture.enable()
else:
use_capture=Falseifint(sys.argv[2])==1:
use_ag=Trueelse:
use_ag=False# Number of indpendent job runsnum_batches=140r1= [jnp.array([0.4, 0.5, 0.6])]*num_batchesr2= [jnp.array([0.4, 0.5, 0.6])]*num_batchesops= [qml.PauliX, qml.PauliY, qml.PauliZ, qml.Hadamard]*(num_batches//4)
# Create the executor with the given backend, and map the data batches to the functionresults= []
kwargs= {"use_capture" : use_capture, "use_ag" : use_ag}
start=timer()
forr1a,r2a,opainzip(r1,r2,ops):
results.append(jnp.array(program(r1a, r2a, opa, **kwargs)))
end=timer()
print(jnp.sum(jnp.array(results), axis=0), end-start)
Run the script as: python script.py X Y, where X=0/1 disables/enables program capture and Y=0/1 enables/disables QJIT autograph.
The above workload uses an example that should offer better performance with autograph and capture, which is observed by enabling either option individually.
Locally, I see the following runtime and potential locations for investigation:
It is likely the issue could also be upstream in PennyLane, but as the profiling indicated the above as the main candidates, I think investigation can start there.
The text was updated successfully, but these errors were encountered:
If this implies what I think it does then it is actually a bug. My reading is that using qml.capture prevents autograph from being applied?
Especially with the data you mentioned this morning, which if I remember correctly you said the IR size is the same when autograph is disabled as when autograph and plxpr are both enabled, but smaller when only autograph is enabled.
Uh oh!
There was an error while loading. Please reload this page.
When running a workload using both Catalyst's autograph and PennyLane capture the performance is on-par with both options disabled. Enabling either of the options individually gives an improvement to the runtime.
Run the script as:
python script.py X Y
, where X=0/1 disables/enables program capture and Y=0/1 enables/disables QJIT autograph.The above workload uses an example that should offer better performance with autograph and capture, which is observed by enabling either option individually.
Locally, I see the following runtime and potential locations for investigation:
QJIT.compile
: Entry-point="catalyst/jit.py:778".QJIT.capture
: Entry-point="catalyst/jit.py:695".QJIT.generate_ir
: Entry-point="catalyst/jit.py:762".It is likely the issue could also be upstream in PennyLane, but as the profiling indicated the above as the main candidates, I think investigation can start there.
The text was updated successfully, but these errors were encountered: