vortex_torch.cache.fill¶
Classes
|
In-place page-wise fill dispatcher. |
- class vortex_torch.cache.fill.Fill(alpha=0.0)[source]¶
Bases:
vOpIn-place page-wise fill dispatcher.
This operator performs an in-place, format-aware fill over a batched tensor. The input is treated as a rank-3 tensor
\[X \in \mathbb{R}^{B \times D_0 \times D_1},\]where:
\(B\) is a batch-like axis (for example, batch * heads),
\(D_0, D_1\) encode per-page/per-token features.
Using per-position metadata stored in
loctogether with layout information inContext, the implementation identifies positions where a page has reached its logical end (e.g. an end-of-page or end-of-sequence condition) and fills the corresponding tiles with a scalar valuealpha:\[X[b, d_0, d_1] \leftarrow \alpha \quad \text{for all positions } (b, d_0, d_1) \text{ that lie past the end-of-page mark.}\]All modifications are performed in-place; the tensor format (PAGED, RAGGED, etc.) determines how page boundaries are interpreted and which elements are affected.
Key properties¶
Dispatch is keyed only by the input tensor format
x._format.The operator is purely in-place: no output buffer is allocated.
The same
vTensoris returned fromprofile().
- _impl_map¶
Dispatch table keyed by
x_format. Each entry maps to a callable implementation that performs the in-place fill.- Type:
Dict[FORMAT, Callable]
- profile(x, loc, ctx)[source]¶
Validate inputs and select the in-place implementation.
Since the operation is in-place, no output buffer is allocated and this method simply returns the input
vTensorunmodified.- Parameters:
x (vTensor) – Input tensor to be modified in-place. Expected logical shape
[B, D_0, D_1].loc (torch.Tensor) – Auxiliary tensor carrying page/position metadata used to detect end-of-page locations.
ctx (Context) – Execution context providing layout information and any additional metadata needed by the implementation.
- Returns:
The same object as
x, returned as the output view.- Return type:
- Raises:
AssertionError – If
xis not avTensor, if its rank is not 3, iflocis not atorch.Tensor, or if no implementation is registered forx._format.
- execute(x, loc, ctx)[source]¶
Execute the in-place page-wise fill and return the input tensor.
The selected implementation examines page/position metadata in
locand context, and overwrites elements inxwith the scalar valuealphaonce an end-of-page condition is detected.- Parameters:
- Returns:
The same tensor instance
x, after in-place filling.- Return type:
torch.Tensor
- Raises:
AssertionError – If
profile()has not been called and no implementation is available.
- Parameters:
alpha (float)