flashinfer.cake_causal_conv1d_nondet_train.cake_causal_conv1d_nondet_train_backward

flashinfer.cake_causal_conv1d_nondet_train.cake_causal_conv1d_nondet_train_backward(x: Tensor, weight: Tensor, cu_seqlens: Tensor, dy: Tensor, *, bias: Tensor | None = None, silu_grad_preactivation: str = 'bf16', workspace: Tensor | None = None, dx: Tensor | None = None, dweight: Tensor | None = None, dbias: Tensor | None = None, bwd_grid_mult: int = 1) → tuple[Tensor, ...]

Packed width-4 depthwise causal convolution + SiLU, training backward (one launch, unordered dweight / dbias reductions).

Under torch.use_deterministic_algorithms(True) the backward raises PyTorch’s RuntimeError before it launches (a UserWarning, then it runs, with warn_only=True); it never falls back to the deterministic package.

Parameters:
  • x – The forward’s inputs; nothing else is saved.

  • weight – The forward’s inputs; nothing else is saved.

  • cu_seqlens – The forward’s inputs; nothing else is saved.

  • bias – The forward’s inputs; nothing else is saved.

  • dy (torch.Tensor) – BF16 gradient of y, x’s shape, contiguous.

  • silu_grad_preactivation ({"bf16", "fp32"}) – "bf16": SiLU’ at the BF16-rounded recomputed preactivation (FP32 accumulators). "fp32": at the unrounded FP32 preactivation with FP64 accumulators.

  • workspace (torch.Tensor, optional) – Caller-owned buffer from cake_causal_conv1d_nondet_train_backward_workspace().

  • dx (torch.Tensor, optional) – Preallocated BF16 output of x’s shape.

  • dweight (torch.Tensor, optional) – Preallocated [C, 4] output (FP32 or BF16; the parameter’s dtype when omitted). An FP32 dweight must be 16-byte aligned (one 16-byte store per channel; ValueError otherwise).

  • dbias (torch.Tensor, optional) – Preallocated [C] output (FP32 or BF16; the parameter’s dtype when omitted).

  • bwd_grid_mult ({1, 2, 3, 4}) – Opt-in finer static partition of the token axis (default 1, the default grid): the backward launches bwd_grid_mult times its default untrimmed CTA count, so each CTA streams that much fewer tokens (for a backward that overlaps kernels of other streams: a CTA that starts late trails by a shorter stream). dx is bitwise the default’s; more CTAs add into the same accumulators (same budgets, same workspace size). TypeError for a non-int, ValueError for another value.

Returns:

(dx, dweight), with a third element dbias only when bias is given. S == 0 returns the empty dx and zero gradients without launching.

Return type:

tuple[torch.Tensor, …]