JuliaLang / JuliaLang/Distributed.jl
Different remote copying behaviour with one process vs multiple
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 55
- Forks
- 19
- PR merge metrics
- No merged PRs in 30d
Description
using Base.Test
function main()
@testset begin
rng = MersenneTwister(3742)
numbers = pmap(1:1000) do _
rand(rng)
end
@test all(numbers .== numbers[1])
spawn_numbers = [(@fetch rand(rng)) for i = 1:1000]
@test all(spawn_numbers .== spawn_numbers[1])
pfor_numbers = @parallel vcat for i = 1:1000
[rand(rng)]
end
@test all(pfor_numbers .== pfor_numbers[1])
end
end
main()
There are three cases here to compare different behaviours with the different parallel methods but I really just care about the @fetch/@spawn case.
ericdavies@whitacre> julia -p 1 ~/rng_parallel_test.jl
test set: Test Failed
Expression: all(pfor_numbers .== pfor_numbers[1])
in record(::Base.Test.DefaultTestSet, ::Base.Test.Fail) at test.jl:431
in do_test(::Base.Test.Returned, ::Expr) at test.jl:281
in macro expansion at rng_parallel_test.jl:20 [inlined]
in macro expansion at test.jl:674 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
Test Summary: | Pass Fail Total
test set | 2 1 3
ERROR: LoadError: Some tests did not pass: 2 passed, 1 failed, 0 errored, 0 broken.
in finish(::Base.Test.DefaultTestSet) at test.jl:498
in macro expansion at test.jl:681 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
while loading /Users/ericdavies/rng_parallel_test.jl, in expression starting on line 24
ericdavies@whitacre> julia ~/rng_parallel_test.jl
test set: Test Failed
Expression: all(numbers .== numbers[1])
in record(::Base.Test.DefaultTestSet, ::Base.Test.Fail) at test.jl:431
in do_test(::Base.Test.Returned, ::Expr) at test.jl:281
in macro expansion at rng_parallel_test.jl:10 [inlined]
in macro expansion at test.jl:674 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
test set: Test Failed
Expression: all(spawn_numbers .== spawn_numbers[1])
in record(::Base.Test.DefaultTestSet, ::Base.Test.Fail) at test.jl:431
in do_test(::Base.Test.Returned, ::Expr) at test.jl:281
in macro expansion at rng_parallel_test.jl:14 [inlined]
in macro expansion at test.jl:674 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
test set: Test Failed
Expression: all(pfor_numbers .== pfor_numbers[1])
in record(::Base.Test.DefaultTestSet, ::Base.Test.Fail) at test.jl:431
in do_test(::Base.Test.Returned, ::Expr) at test.jl:281
in macro expansion at rng_parallel_test.jl:20 [inlined]
in macro expansion at test.jl:674 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
Test Summary: | Fail Total
test set | 3 3
ERROR: LoadError: Some tests did not pass: 0 passed, 3 failed, 0 errored, 0 broken.
in finish(::Base.Test.DefaultTestSet) at test.jl:498
in macro expansion at test.jl:681 [inlined]
in main() at rng_parallel_test.jl:4
in include_from_node1(::String) at loading.jl:488
in include_from_node1(::String) at sys.dylib:?
in process_options(::Base.JLOptions) at client.jl:265
in _start() at client.jl:321
in _start() at sys.dylib:?
while loading /Users/ericdavies/rng_parallel_test.jl, in expression starting on line 24
When there are one or more additional processes, rng is copied. When there is only one process, it is not.
The reason the @parallel for case fails both times is due to the use of CachingPool, which may also be used for pmap in the future via https://github.com/JuliaLang/julia/issues/21946.
Ideally I would like the behaviours to be consistent (though I don't need them to be deterministic).
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the rng_parallel_test.jl reproduction and run it both with julia -p 1 and without additional processes. Compare the copying behavior of pmap, @fetch/@spawn, and @parallel with CachingPool; done means the parallel methods have consistent RNG-copying behavior without requiring determinism.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- distributed-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100