Commit a7bf4f3
fix: use a private task-local RNG for kernel launch seeds
Kernel launches were drawing seeds via `Random.rand(UInt32)`, which
consumed from Julia's task-global default RNG. This silently perturbed
the host random-number stream whenever user code interleaved `@cuda`
calls with `rand()` calls, making reproducibility impossible.
Fix: introduce `launch_rng()`, which lazily creates a `Random.Xoshiro`
in `task_local_storage()` (key `:CUDACore_launch_rng`) seeded from
`Random.RandomDevice()`. The private RNG is completely independent of
the default RNG and is task-local, so concurrent tasks each get their
own seeded RNG. `make_seed(::HostKernel)` now draws from this private
RNG instead. Device-side seeding (DeviceKernel / random.jl) is
unchanged.
Fixes #2417
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 81d7397 commit a7bf4f3
2 files changed
Lines changed: 41 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
473 | 473 | | |
474 | 474 | | |
475 | 475 | | |
476 | | - | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
477 | 488 | | |
478 | 489 | | |
479 | 490 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1222 | 1222 | | |
1223 | 1223 | | |
1224 | 1224 | | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
| 1249 | + | |
| 1250 | + | |
| 1251 | + | |
| 1252 | + | |
| 1253 | + | |
0 commit comments