Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITensor-based MPS local simulator #81

Open
kshyatt-aws opened this issue May 8, 2024 · 1 comment
Open

ITensor-based MPS local simulator #81

kshyatt-aws opened this issue May 8, 2024 · 1 comment
Labels
good first issue Good for newcomers

Comments

@kshyatt-aws
Copy link
Member

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.

@kshyatt-aws kshyatt-aws added the good first issue Good for newcomers label May 14, 2024
@Fe-r-oz
Copy link

Fe-r-oz commented Jun 10, 2024

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.

@testset "GateModelQuantumTaskResult" begin
c = CNot(Circuit(), 0, 1)
action = Braket.Program(c)
@testset for (shots, result) in zip([0, 100], [zero_shots_result, non_zero_shots_result])
task_metadata = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", shots, "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
r = result(task_metadata, additional_metadata)
g = Braket.format_result(r)
@test g isa Braket.GateModelQuantumTaskResult
@test sprint(show, g) == "GateModelQuantumTaskResult\n"
if shots == 0
for er in exact_results
@test g[er[1]] == er[2]
end
end
end
task_metadata = Braket.TaskMetadata(Braket.header_dict[Braket.TaskMetadata], "task_arn", 0, "arn1", nothing, nothing, nothing, nothing, nothing)
additional_metadata = Braket.AdditionalMetadata(action, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
result = Braket.GateModelQuantumTaskResult(task_metadata, JSON3.read(JSON3.write(additional_metadata), Braket.AdditionalMetadata), nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing, nothing)
@test JSON3.read("{\"task_metadata\": $(JSON3.write(task_metadata)), \"additional_metadata\": $(JSON3.write(additional_metadata))}", Braket.GateModelQuantumTaskResult) == result
end

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants