jax.experimental.pallas.fuser.push_pull_block_spec

jax.experimental.pallas.fuser.push_pull_block_spec#

jax.experimental.pallas.fuser.push_pull_block_spec(f, *block_specs, scalar_prefetch_handler=None, grid_len=None, **block_spec_kwargs)[source]#

Pushes BlockSpecs forward through an output fusion, then pulls them back.

For an output fusion f(values, *args, **kwargs) with closed-over side inputs values (assigned no_block_spec during the forward push) and unfused kernel outputs *args, **kwargs, pushes block_specs forward through f and then pulls the resulting output BlockSpecs backward (with strict_mode=False) to derive BlockSpecs for values and build the block-level kernel function.

Parameters:
  • f (Callable) – Output fusion function taking (values, *args, **kwargs).

  • *block_specs (Any) – BlockSpecs for the positional kernel outputs *args.

  • scalar_prefetch_handler (Any | None) – Optional getter created by make_scalar_prefetch_handler that selects this fusion’s scalar prefetch values from the kernel’s scalar prefetch inputs.

  • grid_len (int | None) – Optional number of grid dimensions in the enclosing kernel; see pull_block_spec.

  • **block_spec_kwargs (Any) – BlockSpecs for the keyword kernel outputs **kwargs.

Returns:

A function taking (values, *args, **kwargs) (or their abstract types) and returning (kernel_fn, values_block_specs, kwarg_block_specs, out_type, out_block_specs), where kernel_fn(program_ids, scalar_prefetch, values, *args, **kwargs) evaluates f on a single block, values_block_specs and kwarg_block_specs are the pulled BlockSpecs for values and **kwargs (pulled specs for positional *args are omitted because they are already given by *block_specs), and out_type and out_block_specs are the ShapeDtypeStructs and pushed BlockSpecs for the outputs of f.