core.ssm.ops.gdp.wy_fast#
Recompute the w and u factors of the WY representation.
Given the inverted transition block A from solve_tril, this produces the
two per-chunk factors the state recurrence consumes: u, the effective values,
and w, the effective keys carrying the decay.
Module Contents#
Functions#
Apply the inverted transition block to the betas-scaled keys and values. |
|
Recompute the WY factors |
API#
- core.ssm.ops.gdp.wy_fast.recompute_w_u_fwd_kernel(
- k,
- v,
- beta,
- w,
- u,
- A,
- g,
- cu_seqlens,
- chunk_indices,
- T,
- H: core.ssm.ops.gdp.common.tl.constexpr,
- HV: core.ssm.ops.gdp.common.tl.constexpr,
- K: core.ssm.ops.gdp.common.tl.constexpr,
- V: core.ssm.ops.gdp.common.tl.constexpr,
- BT: core.ssm.ops.gdp.common.tl.constexpr,
- BK: core.ssm.ops.gdp.common.tl.constexpr,
- BV: core.ssm.ops.gdp.common.tl.constexpr,
- USE_G: core.ssm.ops.gdp.common.tl.constexpr,
- IS_VARLEN: core.ssm.ops.gdp.common.tl.constexpr,
Apply the inverted transition block to the betas-scaled keys and values.
- core.ssm.ops.gdp.wy_fast.recompute_w_u_fwd(
- k: torch.Tensor,
- v: torch.Tensor,
- beta: torch.Tensor,
- A: torch.Tensor,
- g: torch.Tensor | None = None,
- cu_seqlens: torch.Tensor | None = None,
- chunk_indices: torch.Tensor | None = None,
Recompute the WY factors
wandufor every chunk.- Parameters:
k – Keys
[B, T, H, K], whereHis the number of query/key heads.v – Values
[B, T, HV, V], whereHVis the number of value/output heads. For GVA,H < HVandHV % H == 0; otherwiseH == HV.beta – Betas
[B, T, HV].A – Inverted transition blocks
[B, T, HV, BT]fromsolve_tril.g – Within-chunk cumulative log2 decays
[B, T, HV], orNone.cu_seqlens – Sequence boundaries
[N+1]for variable-length input.chunk_indices – Precomputed chunk descriptors. Derived from
cu_seqlenswhen omitted, which synchronizes on the device.
Returns
(w, u), shaped[B, T, HV, K]and likevrespectively.