jcmgray / cotengra

Hyper optimized contraction trees for large tensor networks and einsums
https://cotengra.readthedocs.io
Apache License 2.0
174 stars 32 forks source link

Performance improvement from 2002.01935 #24

Closed sss441803 closed 7 months ago

sss441803 commented 11 months ago

Hi!

Thank you for creating a very important research tool for quantum tensor network simulation. I am very curious about the cotengra performance in your paper 2002.01935. I am using circuit_n53_m20_s0_e0_pABCDCDAB.qsim with slicing, and I am getting a cost of $10^{19}$ with largest intermediate size $2^{30}$. This is significantly better than what is reported in Fig. 10. I haven’t tried swapped sycamore and I don’t know if that will improve things further. Is it the case that the software is significantly improved since the paper, or am I missing something?

Regards, Henry

sss441803 commented 11 months ago

For example,

opt = ctg.HyperOptimizer(slicing_reconf_opts={'target_size': 2**30})
# circ is a quimb circuit created with quimb.tensor.Circuit
rehs = circ.amplitude_rehearse(optimize=opt)
tn, info = rehs['tn'], rehs['info']
tree = ctg.ContractionTree.from_info(info)
print('Unsliced cost and width: ', tree.contraction_cost(), tree.contraction_width())
tree_s = tree.slice(target_size=2**30)
print('Sliced cost and width: ', tree_s.contraction_cost(), tree_s.contraction_width())

I get $10^{19}$ for tree_s.contraction_cost. Is this the cost of all slices or only a single slice?

jcmgray commented 11 months ago

Hi @sss441803, yes the performance has been continually improving since then, there's some more information on the main docs page https://cotengra.readthedocs.io/en/latest/ in case you missed it.

The most notable improvement is dynamic slicing, if you use a simply slicing_opts rather than slicing_reconf_opts then you should get more similar to the performance in 2002.01935.

sss441803 commented 6 months ago

Hi Johnnie,

Thank you so much for the help! I do have a related question.

I cannot seem to understand how the gate sequence corresponds to sycamore. As far as I can tell, for the ABCD sequence, the number of (two qubit) gates should be 23, 20, 19, 24. The qsim file shows 24, 19, 23, 20, which seems like DCAB to me. Where is the sycamore 2019 m20 qsim file is obtained?

Sincerely, Henry

jcmgray commented 6 months ago

Hi Henry, I think the file is taken straight from the original Sycamore paper's supplementary material, so should be accurate.