Repository navigation
Gridpacks: in-memory event streaming API (bin/event_stream.py) - #253
theoheimel wants to merge 5 commits into
Conversation
…_max_weight gridpacks New madspace EventStream: a coordinator thread keeps generation jobs running, buffers each channel's unweighted events in launch order and picks the channel of every event from the current cross-section estimates. Reproducible from the seed, nothing written to disk. Shared helpers factored out of EventGenerator (event_utils) and gridpack.py (gridpack_setup.py).
|
The two Build wheels jobs (ubuntu-latest, macos-14) fail at the stub-generation step: This comes from this PR, not from an outdated base. Wheels build fine on Cause: in py::arg("event_file") = "",
py::arg("weight_file") = "",
py::arg("config"), // no default after defaulted argspybind11 accepts this at runtime, but the generated Suggested fix: add py::arg("channel_json"),
py::arg("contexts"),
py::kw_only(),
py::arg("event_file") = "",
py::arg("weight_file") = "",
py::arg("config"),The stub then becomes You can check this locally with |
…(valid .pyi stub), gridpack section in launch test run card
…t-streaming-event-gen # Conflicts: # madgraph/interface/tutorials/mg7.py # madgraph/iolibs/template_files/mg7/run_card.toml
# Conflicts: # madgraph/iolibs/template_files/mg7/gridpack.py
…and the EventStream API reference
This implements the idea discussed at the Heidelberg MadGraph meeting to have an in-memory API for event generation, for instance to pass events directly to Pythia without having to go through an intermediate LHE file.
Summary
Gridpacks made with
[gridpack] run_mode = "fix_max_weight"now shipbin/event_stream.py. It is a Python API that generates events in memory, with no survey, no combine pass and nothing written to disk.device,seed,cpu_batch_size,gpu_batch_size,thread_pool_sizeand the cut-repetition settings. Anything left asNonecomes fromgrid_run_card.toml.batches()yields anEventBatchdataclass of LHE fields:(n,);(n, max_particle_count);particle_countandparticle_maskare included;How it works
madspace::EventStream(driver/event_stream.{hpp,cpp}):ChannelEventGenerator::start_job/start_unweight_job.ChannelEventGeneratorcan be created without event/weight files (empty path). The tensor→EventBufferpacking is split out intofill_event_buffers.fill_lhe_event, the per-event record copy, writing LHE particles, the integral sum over channels and the unweighted-weight formula moved intodriver/event_utils.{hpp,cpp}.EventGeneratornow uses these.gridpack.pyintogridpack_setup.py, which is always copied tobin/: locating madspace, contexts, matrix elements, channels, systematics and the LHE meta. Its paths are relative to the gridpack, so it can be imported from any directory.Testing
madspace/tests/test_event_stream.py(8 tests) checks:next_eventsmatchesnext_batch;fix_max_weightgridpack:bin/generate_eventsstill runs;Known limitations / open points
fix_max_weightgridpack fore+ e- > u u~ gfailed infix_max_weights()with a NaN integral in channel0.0, after the survey had passed. These changes don't touch that code path, but I have not checked whether main shows the same failure.