Skip to content

Support explicit_chunk for mode-choice components#1088

Open
vincentgong7 wants to merge 1 commit into
ActivitySim:mainfrom
vincentgong7:feature/explicit-chunk-mode-choice
Open

Support explicit_chunk for mode-choice components#1088
vincentgong7 wants to merge 1 commit into
ActivitySim:mainfrom
vincentgong7:feature/explicit-chunk-mode-choice

Conversation

@vincentgong7

@vincentgong7 vincentgong7 commented Jul 14, 2026

Copy link
Copy Markdown

Description

What

Plumb the existing explicit_chunk setting through to the mode-choice components
(tour_mode_choice, trip_mode_choice), matching how location, destination, and scheduling
components already use it.

Why

explicit_chunk (a fixed per-chunk chooser count, active under chunk_training_mode: explicit) lets a
component run with a deterministic, bounded memory footprint. Location/destination/scheduling
components honor it via LocationComponentSettings.explicit_chunk, but mode-choice components never
received it — the field didn't exist on their settings class and mode_choice_simulate /
simple_simulate neither accepted nor forwarded it.

On memory-constrained machines the adaptive chunker grows each chunk toward its memory budget, so peak
RSS is roughly constant regardless of sample size — which can OOM large models even after subsampling.
Fixed explicit_chunk sizes bound the peak. This change makes that strategy usable for mode choice too;
for us it was the last unchunkable core step when fitting a full-sample run (8.1M trips, 7787 zones) onto
a 64 GB node.

What changed (backward-compatible — default 0 = unchanged behavior)

  • TemplatedLogitComponentSettings: new explicit_chunk: float = 0 field (the base for mode-choice
    settings; mirrors the field already on LocationComponentSettings).
  • mode_choice_simulate(...): new explicit_chunk_size parameter, forwarded to simple_simulate.
  • run_tour_mode_choice_simulate(...) and trip_mode_choice(...): pass
    explicit_chunk_size=model_settings.explicit_chunk.
  • simple_simulate(...): new explicit_chunk_size parameter, forwarded to
    chunk.adaptive_chunked_choosers.

4 files changed, 16 insertions(+), 1 deletion(-).

Usage

# settings.yaml
chunk_training_mode: explicit
# tour_mode_choice.yaml / trip_mode_choice.yaml
explicit_chunk: 5000

Testing

Verified on a full-sample run (8.1M trips, 7787 zones) on a 64 GB node: tour/trip mode choice ran with a
bounded per-chunk memory footprint under explicit_chunk: 5000; with the default (0) behavior is
identical to before.

Acknowledgement

This work was supported by the XCarcity project. https://xcarcity.nl

Location, destination, and scheduling components already honor the
`explicit_chunk` setting (a fixed chunk size, used when
chunk_training_mode: explicit), but mode-choice components did not:
the setting was never plumbed from the component settings into
simple_simulate's chunk loop.

This wires it through: add `explicit_chunk` to
TemplatedLogitComponentSettings (the base for mode-choice settings),
and pass it via mode_choice_simulate -> simple_simulate ->
adaptive_chunked_choosers. Defaults to 0 (unchanged behavior).

This lets tour_mode_choice and trip_mode_choice run with a fixed,
bounded per-chunk memory footprint, which is what makes large samples
fit on memory-constrained machines under chunk_training_mode: explicit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant