spdl.pipeline.defs.PlacementConfig¶
- class PlacementConfig(target: ProcessPoolExecutorConfig | InterpreterPoolExecutorConfig | _MainProcess, name: str = 'placement', buffer_size: int = 1)[source]¶
[Experimental] A region marker designating where the subsequent stages execute.
Sits among the stage configs in
PipelineConfig.pipes: every stage after this marker (until the nextPlacementConfig) runs ontarget.spdl.pipeline.PipelineBuilder.to()appends one of these. A pipeline implicitly starts on the main process, so a marker is needed only to enter a worker-pool region and (withMAIN_PROCESS) to leave it.Added in version 0.6.0.
Attributes
At most this many items are buffered into one transfer at this marker.
Name of the marker (used only for display).
Where the stages following this marker execute.
- buffer_size: int = 1¶
At most this many items are buffered into one transfer at this marker.
Crossing a process boundary costs a fixed amount per transfer — the pickle and unpickle calls, the queue feeder-thread handoff and the pipe write — no matter how small the item is.
1(the default) passes one item at a time; a larger value amortizes that over several items. Per-item costs are unaffected: a tensor still needs its own shared-memory segment whether or not it shares a transfer.Each marker sizes the handoff that happens where it sits, so a region’s entry and exit are configured independently: the marker that opens a region sizes data flowing into its workers, and the marker that closes it sizes results flowing back. That separation matters because the two directions rarely carry comparable items — a region ending in
Aggregate()takes single rows in and returns whole batches.It is an upper bound rather than a fixed grouping: a partial buffer is flushed at the end of a stream and at every epoch boundary, so the last transfer is usually short.
The buffering is transparent — stages on both sides still see individual items, so this is independent of any
Aggregate()inside or outside the region.Added in version 0.7.0.
- target: ProcessPoolExecutorConfig | InterpreterPoolExecutorConfig | _MainProcess¶
Where the stages following this marker execute.