Skip to content

Commit 23dfbf2

Browse files
committed
add cache switch
1 parent 4bc18a6 commit 23dfbf2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/CircuitBuild.jl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ rotorset(::Val{:Split}, nbit::Int, noleading::Bool=false, notrailing::Bool=false
8181
rotorset(mode::Symbol, nbit::Int, noleading::Bool=false, notrailing::Bool=false) = rotorset(Val(mode), nbit, noleading, notrailing)
8282

8383
"""
84-
qdiff_circuit(n, nlayer, pairs) -> ChainBlock
84+
random_diff_circuit(nbit, nlayer, pairs; mode=:Split, do_cache=false)
8585
8686
A kind of widely used differentiable quantum circuit, angles in the circuit is randomely initialized.
8787
@@ -90,10 +90,13 @@ ref:
9090
Hardware-efficient Quantum Optimizer for Small Molecules and Quantum Magnets. Nature Publishing Group, 549(7671), 242–246.
9191
https://doi.org/10.1038/nature23879.
9292
"""
93-
function random_diff_circuit(nbit, nlayer, pairs; mode=:Split)
93+
function random_diff_circuit(nbit, nlayer, pairs; mode=:Split, do_cache=false)
9494
circuit = chain(nbit)
9595

96-
ent = cnot_entangler(pairs) |> cache
96+
ent = cnot_entangler(pairs)
97+
if do_cache
98+
ent = ent |> cache
99+
end
97100
for i = 1:(nlayer + 1)
98101
i!=1 && push!(circuit, ent)
99102
push!(circuit, rotorset(mode, nbit, i==1, i==nlayer+1))

0 commit comments

Comments
 (0)