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
The expected behaviour is that the result of applying pattern_matching_optimization to go_circuit() should be temp_go.
Actual behavior
The actual behaviour is that applying pattern_matching_optimization to go_circuit() does not return the temp_go, instead it returns the original circuit go_circuit().
gideonuchehara
changed the title
[BUG] pattern_matching_optimization not working for some templates
[BUG] pattern_matching_optimization fails for some templates
Aug 23, 2024
Thanks for opening this issue @gideonuchehara . Hopefully I am understanding the problem correctly, but I think I understand what's happening.
In optimized_go_qnode, you are expecting the match for the first half of the template temp_go to be replaced by the second half of temp_go?
I think the problem is that replacing four cnots with a different four cnots doesn't actually optimize the circuit at all. We only replace the match if it results in a reduction in the size of the circuit.
If we update `go_circuit to have one additional CNOT:
The optimized circuit optimized_go_qnode = pattern_matching_optimization(go_circuit, pattern_tapes=[temp_go]) does end up with a circuit with three cnots.
Note that the template should not contain any measurements, and that pennylane now has a new syntax for applying transforms to qnodes.
Expected behavior
The above quantum tape is a matching template for the circuit below
The expected behaviour is that the result of applying
pattern_matching_optimization
togo_circuit()
should betemp_go
.Actual behavior
The actual behaviour is that applying
pattern_matching_optimization
togo_circuit()
does not return thetemp_go
, instead it returns the original circuitgo_circuit()
.Additional information
No response
Source code
Tracebacks
No response
System information
Existing GitHub issues
The text was updated successfully, but these errors were encountered: