-
Notifications
You must be signed in to change notification settings - Fork 9
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
Copy args #142
Comments
I think it makes no sense when one copies a started task and tries to re-initialize its arguments. We can give an error when one tries to do this. |
@FredericWantiez I agree with @KDr2 that this is a strange use case. Is any reason why we want to do it?
It sounds good to throw an error on this. |
That would happen when we split a particle halfway through the program simulation. If we define the function like: function (model::Model) (rng::AbstractRNG)
...
end when we |
You can do it by overloading
This is the way we manipulate data while a fork is occurring. |
Nice ! but in this case the reference in the Lines 167 to 172 in 1cecf7d
|
|
We don't check that the task is running or not, as long as That's an issue for something like: Libtask.tape_copy(x::XRNG) = deepcopy(XRNG) This is very similar to what we do in AdvancedPS to update the rng streams during the sampling procedure. |
In the latest code, we do the check, if the task is running and new args are provided, we throw an error. About the issue you mentioned, I didn't get it, could you please provide an example to describe it? Thank you. |
That's true but if we just ttask = Libtask.TapedTask(func, XRNG)
consume(ttask)
ttask2 = copy(ttask) # Here, we call both copy(t.tf) and tape_copy.(t.args) For the reference part, the issue I'm facing in AdvancedPS is we often have something that looks like this: mutable struct XRNG
rng::AbstractRNG
end
tape_copy(rng::XRNG) = deepcopy(rng)
function (model::Model) (rng::XRNG)
...
end
rng1 = XRNG()
particle = TapedTask(model, rng1)
consume(particle)
sub_part1 = copy(particle)
sub_part2 = copy(particle)
Random.seed!(sub_part1.args.rng, 1) # Simplifying here, we should do it in tape_copy
Random.seed!(sub_part2.args.rng, 2) # Otherwise, they're both generating the same numbers
consume(sub_part1)
consume(sub_part2) but the problem here is that the |
Oh, you are right, could you try this fix #144 to see if it works well? |
Seems like #141 has a small issue with copying the
args
around. From the last update:but this runs fine
The text was updated successfully, but these errors were encountered: