amazon-braket / Braket.jl

Experimental Julia implementation of the Amazon Braket SDK
Apache License 2.0
97 stars 6 forks source link

ITensor-based MPS local simulator #81

Open kshyatt-aws opened 1 month ago

kshyatt-aws commented 1 month ago

Describe the feature you'd like Now that we support LocalSimulators, we can hook into ITensor's support for DMRG-based evolution methods to implement tensor network circuit simulation.

Is this feature already present in the Python SDK? No.

How would this feature be used? Please describe. It would make sense to implement this as a package extension, which could be loaded on newer Julia versions once ITensors.jl is installed.

Describe alternatives you've considered This could also be a standalone package.

Additional context It would be useful to offer users some control over how the simulation is run (e.g. TDVP vs TEBD, maximum bond dimension). Offering a version that supports the GPU implementations of ITensors.jl would be a good stretch goal.

Fe-r-oz commented 2 weeks ago

Hi, I am interested to work on this issue.

I tested the pseudocode. For our new simulator, lets say MPSITensorSimulator, I am not sure how to use the Braket.GateModelQuantumTaskResult (if this is needed) to return the output of energy and psi values.

Suppose the following pseudocode:

func simulate(args: `MPSITensorSimulator`)
.
.
.
return LocalQuantumTask("dmrg_task", GateModelQuantumTaskResult(energy, psi))
ERROR: MethodError: no method matching Braket.GateModelQuantumTaskResult(::Float64, ::MPS)`
Closest candidates are:
  Braket.GateModelQuantumTaskResult(::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any, ::Any)

I checked out the tests for Braket.GateModelQuantumTaskResult, it seems that it requires many inputs, most of the being nothing.

Findings of how Braket.GateModelQuantumTaskResult is used. It seems to me that since we are not defining a circuit, this might not be appropriate to return the results for MPS problem.

https://github.com/amazon-braket/Braket.jl/blob/1d05da02807487a83a0f83dc88272ceda3d54465/test/gate_model_task_result.jl#L31-L51

ITensor example output

After sweep 1 energy=-138.81402684467096  maxlinkdim=10 maxerr=1.12E-02 time=19.409
After sweep 2 energy=-138.93722855380113  maxlinkdim=20 maxerr=5.24E-06 time=0.331
After sweep 3 energy=-138.94008445416316  maxlinkdim=89 maxerr=1.00E-10 time=3.257
After sweep 4 energy=-138.94008605426893  maxlinkdim=100 maxerr=1.00E-10 time=6.988
After sweep 5 energy=-138.9400860534953  maxlinkdim=95 maxerr=1.00E-10 time=6.537