Repository navigation
feat(python): ensembles and burn probability (#172) - #228
Merged
Merged
Conversation
filippi
approved these changes
Oct 29, 2026
Contributor
|
hi @HugoFara still some trouble in the linux build, I thought runners were forks already ! but cool if it forks faster, and nice way to make ensembles in python |
…orefireAPI#172) fork() returns a new runner holding a copy of the simulation, so ensemble members can branch from one spin-up instead of rerunning it. The worker forks itself, not the caller: the worker has no threads, and the copy starts with the whole kernel state. The new socket is passed over the existing one, and the copy is double-forked so nobody has to reap it. A fork takes a few milliseconds, against about 80 ms for a new runner. Open files are shared with the copy, and an HTTP command server is not copied.
…PI#172) run_ensemble(setup, members, until, perturb) runs setup once, forks one runner per member, applies perturb to each and steps them in parallel to `until`. It returns the arrival-time maps, [member, y, x], and burn_probability() turns them into the fraction of members burnt by any time. With fork=False each member gets a fresh runner and perturb runs before setup, for parameters the kernel reads only at construction, such as windReductionFactor and propagationSpeedAdjustmentFactor. The maps are read through plot[parameter=arrival_time] into an ASCII grid, because the BMap layer is never filled outside coupled runs; bbox crops them on large domains. ForeFireRunner takes stdout and stderr like Popen, and ensemble members discard their output by default. A User Guide page runs a 32-member wind ensemble end to end, and test_ensemble.py runs in the Model Invariants workflow.
…PI#229) forefireAPI#229 makes plot[...;filename=*.asc] write a valid ESRI grid, one row per y from the north edge, so arrival_time flips it instead of transposing it.
HugoFara
force-pushed
the
feat/runner-fork
branch
from
October 29, 2026 08:28
53c137d to
167f5ba
Compare
Collaborator
Author
|
Hi, fixed the small issue with Forks: ForeFireRunner (#175) didn't fork. It starts a fresh interpreter (python -m pyforefire._worker), because forking a caller that may have threads is unsafe. fork() forks the worker instead, which has no threads. The copy starts with the whole simulation already in memory. So the gain isn't only process startup (~4 ms vs ~80 ms): members branch from one spin-up instead of each rerunning setup. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of #172: burn-probability maps from ensembles, all in Python.
setupruns once; each member is aForeFireRunner.fork()of it (~4 ms vs ~80 ms for a new runner), thenperturbchanges its wind or fuels.fork=Falsegives each member a fresh runner instead, for parameters read only at construction (windReductionFactor,propagationSpeedAdjustmentFactor).ForeFireRunner(stdout=..., stderr=...)redirects output; members are silent by default.plot[parameter=arrival_time], which can crop to abbox.Tested:
test_runner.py(forks) andtest_ensemble.py(members match the deterministic run, perturbations apply, probabilities in [0, 1] and non-decreasing in time), both in the invariants workflow. Also on therunffCorsica case: 16 wind members in 1.2 s.New User Guide page:
user_guide/ensembles.rst.Drafted with Claude Opus 5.5.