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

[BUG] SchodingerProblem does not support ForwardDiff #561

Open
hongyehu opened this issue May 26, 2023 · 2 comments
Open

[BUG] SchodingerProblem does not support ForwardDiff #561

hongyehu opened this issue May 26, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@hongyehu
Copy link

In simulation with Bloqade, one can use ForwardDiff.jl to do forward AD of parameters. This works with KrylovEvolution. But if one wants to simulate time-dependent Hamiltonian with Waveform, and SchodingerProblem. The ForwardDiff.gradient and ForwardDiff.jacobian breaks down and outputs NAN.

@hongyehu hongyehu added the bug Something isn't working label May 26, 2023
@Roger-luo
Copy link
Member

do you have a minimum-not-working example to demonstrate this bug?

@ChenZhao44
Copy link
Collaborator

using Bloqade
using ForwardDiff

nsites = 5
scale = 5.0

function loss_detuning(Δ)
    atoms = generate_sites(ChainLattice(), nsites; scale = scale)
    reg = zero_state(Complex{typeof(Δ[1])}, nsites)
    rh = rydberg_h(atoms; Δ, Ω = 1)
    prob = SchrodingerProblem(reg, (0,1), rh)
    emulate!(prob)
    return real.(state(reg))
end
ForwardDiff.jacobian(loss_detuning, rand(nsites)) # Returns a matrix containing all NaNs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants