| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Introduce a configurable RNG channel type and exercise both implementations in tests. Add Settings.rng_channel_type to choose between the new FastChannel (PCG64 vectorised) and legacy SimpleChannel for reproducibility. Random now accepts a channel_type on init and add_channel accepts fast=None to default to the global channel_type; existing code will pick up settings.rng_channel_type via State initialization and rng access. Implement FastChannel.extend_domain to allow adding new domain rows (initialising per-row PCG64 state when a step is active) and tighten index handling. Update many pipeline tests to parametrize over channel types, isolate per-channel output dirs, and include per-channel expected regression values and checks.
There was a problem hiding this comment.
Adds configurable vectorized RNG channels while retaining legacy reproducibility.
Changes:
Copilot reviewed 17 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file| File | Description |
|---|---|
| uv.lock | Locks the CFFI dependency. |
| pyproject.toml | Declares CFFI at runtime. |
| other_resources/scripts/random-performance.ipynb | Explores RNG performance. |
| other_resources/performance-checks/fast-channel-random.py | Adds a benchmark script. |
| activitysim/core/workflow/state.py | Configures RNG channel selection. |
| activitysim/core/test/test_random.py | Expands cross-channel contract tests. |
| activitysim/core/test/test_fast_random.py | Tests vectorized generators. |
| activitysim/core/test/test_fast_channel.py | Tests FastChannel. |
| activitysim/core/random.py | Integrates fast channels into the RNG API. |
| activitysim/core/fast_random/_fast_channel.py | Implements vectorized per-row streams. |
| activitysim/core/fast_random/_entropy.py | Implements accelerated reseeding. |
| activitysim/core/fast_random/__init__.py | Exports FastChannel. |
| activitysim/core/configuration/top.py | Documents RNG settings. |
| activitysim/abm/test/test_pipeline/test_pipeline.py | Adds pipeline regression coverage. |
| activitysim/abm/test/test_pipeline/output/trace/.gitignore | Removes redundant ignores. |
| activitysim/abm/test/test_pipeline/output/cache/.gitignore | Removes redundant ignores. |
| activitysim/abm/test/test_pipeline/output/.gitignore | Removes redundant ignores. |
| .github/workflows/performance-checks.yml | Adds manual benchmark automation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sorry, something went wrong.
| scalar_output = size is None | ||
| draw_shape = 1 if scalar_output else size | ||
|
|
||
| result = self._fast_generator.vector_random_standard_normal( | ||
| self._state_array, selected_positions=selected_positions, shape=draw_shape | ||
| ) | ||
|
|
||
| def broadcast_parameter(value, name): | ||
| """Align one scalar or one value per row to the generated draw shape.""" | ||
| value = np.asarray(value) | ||
| if value.ndim == 0: | ||
| return value | ||
| if value.shape != (len(df),): | ||
| raise ValueError( | ||
| f"{name} must be a scalar or a 1-D array with one value per row" | ||
| ) | ||
| return value.reshape((len(df),) + (1,) * (result.ndim - 1)) | ||
|
|
||
| result = result * broadcast_parameter(sigma, "sigma") + broadcast_parameter( | ||
| mu, "mu" | ||
| ) |
| Back | FazBrowse Home | New Git URL |
Summary
This PR adds high-performance, vectorized random-number channels while preserving ActivitySim’s legacy RNG behavior as an option.
Two accelerated modes are available through rng_channel_type:
Key changes
Note: this PR has advanced notably from the last time we looked at it, as the EET branch introduced several new variants of randomness. I have iterated this on a couple different AI models to get what I believe to be a good result.