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] Using Bloqade together with EnsembleDistributed() #586

Open
benmcdonough20 opened this issue Jun 28, 2023 · 3 comments
Open

[BUG] Using Bloqade together with EnsembleDistributed() #586

benmcdonough20 opened this issue Jun 28, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@benmcdonough20
Copy link
Collaborator

benmcdonough20 commented Jun 28, 2023

Describe the bug
When constructing an EnsembleProblem with a SchrodingerProblem and using the EnsembleDistributed algorithm to parallelize the simulations, several workers cannot run simultaneously due to a lock on .CondaPkg. The error message produced is the following:

From worker 3:    ┌ Info: CondaPkg: Waiting for lock to be freed. You may delete this file if no other process is resolving.
From worker 3:    └   lock_file = "/Users/queraintern/.julia/environments/v1.9/.CondaPkg/lock"

To Reproduce
Here is a minimum working example:

using Bloqade
using OrdinaryDiffEq

atoms = generate_sites(ChainLattice(), 1, scale = 1)
h = rydberg_h(atoms; Ω = 2π)
reg = zero_state(1)

problem = SchrodingerProblem(reg, 1.0, h)

ep = EnsembleProblem(problem)

sim = solve(ep, DP8(), EnsembleDistributed(); trajectories = 2)

Running this code with julia -p 2 minimum_working_example.jl produces the issue.

Version Info

  • Julia: v1.9
  • Bloqade: v0.1.23
  • OrdinaryDiffEq: v6.11.2
@benmcdonough20 benmcdonough20 added the bug Something isn't working label Jun 28, 2023
@benmcdonough20
Copy link
Collaborator Author

benmcdonough20 commented Jul 6, 2023

Update: I think that PythonCall is the issue. The bug can be fixed by avoiding the Bloqade init through replacing using Bloqade with using BloqadeExpr, BloqadeODE, BloqadeLattices.

@kaihsin
Copy link
Collaborator

kaihsin commented Jul 6, 2023

A quick fix is to only let the master process import Python Call, and only allow master proc to plot

So if we modify the following part in src/Bloqade.jl :

using PythonCall
const plt = PythonCall.pynew()

function __init__()
    # copied from PyPlotCall.jl
    PythonCall.pycopy!(plt, pyimport("matplotlib.pyplot"))
    return
end

to

using Distributed
const plt = nothing
@spawnat 1 :(using PythonCall)
@spawnat 1 :(const plt = PythonCall.pynew())

function __init__()
    if getpid()==1
        # copied from PyPlotCall.jl
        PythonCall.pycopy!(plt, pyimport("matplotlib.pyplot"))
    end
    return
end

@weinbe58 @Roger-luo

@kaihsin
Copy link
Collaborator

kaihsin commented Jul 6, 2023

Also might related to #554

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

2 participants