-
-
Notifications
You must be signed in to change notification settings - Fork 43
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
Support prob_func in ensembles #123
Comments
Works but then is not perturbing the initial problem... I fell on this while looking for a method to generate ensemble on GPUs. Examplefrom diffeqpy import de
import random
def f(u,p,t):
x, y, z = u
sigma, rho, beta = p
return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
u0 = [1.0,0.0,0.0]
tspan = (0., 100.)
p = [10.0,28.0,8/3]
prob = de.ODEProblem(f, u0, tspan, p)
fast_prob = de.jit32(prob)
sol = de.solve(fast_prob,saveat=0.01)
def prob_func(prob,i,rep):
de.remake(prob,u0=[random.uniform(0, 1)*u0[i] for i in range(0,3)],
p=[random.uniform(0, 1)*p[i] for i in range(0,3)])
ensembleprob = de.EnsembleProblem(fast_prob, safetycopy=False)
sol = de.solve(ensembleprob,de.Tsit5(),de.EnsembleSerial(),trajectories=10,saveat=0.01) then: and so all the members are the same because they are all given the same problem (default How to make it worksThis works for me: from diffeqpy import de
import random
def f(u,p,t):
x, y, z = u
sigma, rho, beta = p
return [sigma * (y - x), x * (rho - z) - y, x * y - beta * z]
u0 = [1.0,0.0,0.0]
tspan = (0., 100.)
p = [10.0,28.0,8/3]
prob = de.ODEProblem(f, u0, tspan, p)
fast_prob = de.jit32(prob)
sol = de.solve(fast_prob,saveat=0.01)
def prob_func(prob,i,rep):
new_prob = de.remake(prob,u0=[random.uniform(0, 1)*u0[i] for i in range(0,3)],
p=[random.uniform(0, 1)*p[i] for i in range(0,3)])
return new_prob
ensembleprob = de.EnsembleProblem(fast_prob, prob_func=prob_func, safetycopy=False)
sol = de.solve(ensembleprob,de.Tsit5(),de.EnsembleSerial(),trajectories=10,saveat=0.01) then I get : and which are indeed different ensemble members. Bottom line: I think you should update the README file. |
Please also note that when sol = de.solve(ensembleprob,cuda.GPUTsit5(),cuda.EnsembleGPUKernel(cuda.CUDABackend()),trajectories=10000,saveat=0.01) or sol = de.solve(ensembleprob,de.Tsit5(),cuda.EnsembleGPUArray(cuda.CUDABackend()),trajectories=10000,saveat=0.01) does not work ! I get for the first one:
and
for the second. Note that if I use ensembleprob = de.EnsembleProblem(fast_prob, safetycopy=False) like you did, then GPU works, but again all the members are the same. |
@LilithHafner can you look into this one? |
@utkarsh530 don't the prob_funcs resolve before the kernel? The error looks like it's trying to use it in the kernel. |
I don't have a cuda machine to reproduce @jodemaey's latest example, but fwiw, when I run sol = de.solve(ensembleprob,metal.GPUTsit5(),metal.EnsembleGPUKernel(metal.MetalBackend()),trajectories=100,saveat=0.01) I get
If the metal issue and the cuda issue are related it is probably best to debug the cuda one first as it has amore actionable error message. |
Works:
Fails:
The text was updated successfully, but these errors were encountered: