Skip to content

pl.optimizations

The optimization entries a pl.at(..., optimizations=[...]) list accepts — pl.split, pl.cross_core_slot and friends. See Runtime overhead.

Optimization config entries for pl.at(..., optimizations=[...]).

Each entry is an orthogonal optimization hint applied to the enclosing scope. The entries can be combined freely in the optimizations= list.

Available entries
  • pl.split(mode) — Cross-core data-transfer split hint, consumed by the ExpandMixedKernel pass. Lowers the scope to InCore with split_=mode::

    with pl.at(level=pl.Level.CORE_GROUP, optimizations=[pl.split(pl.SplitMode.UP_DOWN)]): ...

  • pl.cross_core_slot(slot_num=N) — Slot count (ring depth) for the automatic cross-core pipe. Orthogonal to splitting; combine freely::

    with pl.at(level=pl.Level.CORE_GROUP, optimizations=[pl.split(pl.SplitMode.UP_DOWN), pl.cross_core_slot(slot_num=4)]): ...

CrossCoreSlot dataclass

Bases: Optimization

Slot count (ring depth) for the automatic cross-core pipe.

Orthogonal to splitting — it sizes a data channel, it does not partition work. Sets the slot_num scope attr, which OutlineIncoreScopes propagates to the outlined function and ExpandMixedKernel reads to size both the reserved buffer (slot_size * slot_num) and the emitted initialize_pipe slot_num attribute, in whichever directions the scope actually uses (cube→vector, vector→cube, or both).

Omitting the entry keeps the default depth of 2 per live direction — enough to double-buffer the handoff while leaving on-chip room for the tiles. The value is ignored when the outlined scope ends up with no cross-core ops.

Parameters:

Name Type Description Default
slot_num int

Ring depth. Must be a positive integer.

required

slot_num instance-attribute

Optimization

Base class for pl.at(..., optimizations=[...]) entries.

Split dataclass

Bases: Optimization

Cross-core data-transfer split hint.

Sets ScopeStmt::split_ on the enclosing pl.at scope; that metadata is consumed by the ExpandMixedKernel pass via the outlined function's SplitMode. optimizations=[pl.split(mode)] lowers the scope to ScopeKind::InCore with the split metadata attached.

Parameters:

Name Type Description Default
mode SplitMode

Split mode (SplitMode.NONE, SplitMode.UP_DOWN, or SplitMode.LEFT_RIGHT).

required
slot_num int | None

Deprecated — use pl.cross_core_slot(slot_num=N), which carries the same value without naming a split mode. Kept as an alias so existing kernels keep working; see CrossCoreSlot.

None

mode instance-attribute

slot_num = None class-attribute instance-attribute

cross_core_slot(*, slot_num)

Create a CrossCoreSlot optimization entry.

Parameters:

Name Type Description Default
slot_num int

Cross-core pipe slot count (ring depth). Must be positive.

required

Returns:

Type Description
CrossCoreSlot

CrossCoreSlot instance for use in pl.at(..., optimizations=[...]).

Raises:

Type Description
ValueError

If slot_num is not a positive integer.

Examples:

>>> # Deepen the auto-inserted ring so the producing core can run further ahead
>>> with pl.at(level=pl.Level.CORE_GROUP,
...            optimizations=[pl.cross_core_slot(slot_num=4)]):
...     ...

split(mode, *, slot_num=None)

Create a Split optimization entry.

Parameters:

Name Type Description Default
mode SplitMode

Split mode. May be SplitMode.NONE, SplitMode.UP_DOWN, or SplitMode.LEFT_RIGHT.

required
slot_num int | None

Deprecated — use pl.cross_core_slot(slot_num=N). Must be positive when set. Emits a DeprecationWarning.

None

Returns:

Type Description
Split

Split instance for use in pl.at(..., optimizations=[...]).

Raises:

Type Description
ValueError

If slot_num is set but not positive.

SPLIT_SLOT_NUM_DEPRECATION = 'pl.split(slot_num=...) is deprecated: the cross-core slot count is orthogonal to the split mode, and spelling it here forces a split mode you may not want (the pl.split(pl.SplitMode.NONE, slot_num=N) idiom). Use optimizations=[pl.cross_core_slot(slot_num=N)] instead, optionally alongside pl.split(MODE).' module-attribute