[pipeline] Add batched routing to path_variants - #1595
Merged
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D112745035. (Because this pull request was imported automatically, there will not be any future comments.) |
Add a `batched` option to `PathVariants` and `PipelineBuilder.path_variants`. When set, the router receives a whole batch (a list) and returns one path index per element; the batch is partitioned into per-path sub-batches (order preserved), each path processes its sub-batch as a list, and the fan-in merge concatenates the sub-batches back into one batch. Per-item routing pays the router + fan-out/fan-in machinery once per element. For workloads that route in bulk -- e.g. a cache hit/miss split over an already-aggregated batch -- that fixed per-item cost dominates. Batched routing amortizes it over the whole batch: the router runs once per batch, each branch runs its ops once per batch, and one list (not one item) crosses each queue per batch. Semantics: - Each input batch contributes exactly one sub-batch (possibly empty) to every path queue, so the queues stay in lockstep and the merge recombines an input batch's sub-batches by reading one list from each path. - A branch may drop elements by returning a shorter list, and must tolerate an empty input list (a path that received no elements for a batch). - A batched router must return exactly one index per element; otherwise the stage fails. `batched` defaults to `False`, so existing per-item behavior is byte-identical (not backward-incompatible).
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.
Add a
batchedoption toPathVariantsandPipelineBuilder.path_variants.When set, the router receives a whole batch (a list) and returns one path index per element; the batch is partitioned into per-path sub-batches (order preserved), each path processes its sub-batch as a list, and the fan-in merge concatenates the sub-batches back into one batch.
Per-item routing pays the router + fan-out/fan-in machinery once per element. For workloads that route in bulk -- e.g. a cache hit/miss split over an already-aggregated batch -- that fixed per-item cost dominates. Batched routing amortizes it over the whole batch: the router runs once per batch, each branch runs its ops once per batch, and one list (not one item) crosses each queue per batch.
Semantics:
batcheddefaults toFalse, so existing per-item behavior is byte-identical (not backward-incompatible).