flashinfer.cake_mhc_det_train.cake_mhc_det_train_backward_workspace_bytes

flashinfer.cake_mhc_det_train.cake_mhc_det_train_backward_workspace_bytes(T: int, device: device, *, hidden: int = 4096) → int

Bytes of the caller-owned backward workspace for up to T tokens of hidden size hidden.

The backward_finish route holds one 256-byte ticket region (first, at the same offset for every token count), the transposed BF16 pieces of fn, the per-token records of the token-owner pass (dz' pieces and the per-token scalars, padded to a multiple of 128 rows), the per-CTA parameter partials and the per-chunk FP32 partials of dfn. The ticket words must be zero on first use (allocate with torch.zeros or cake_mhc_det_train_backward_workspace()); the kernels leave them zero.

Parameters:
  • T (int) – Largest token count the buffer serves (the size is the maximum over every token count up to T); T == 0 needs no workspace.

  • device (torch.device) – CUDA device of the calls.

  • hidden (int) – Hidden size H of the calls the buffer serves (X.shape[2]; default 4096), as in cake_mhc_det_train_forward_workspace_bytes(): a buffer sized for one H is refused by a call of a larger H it is too small for.

Returns:

The size of the backward workspace in bytes.

Return type:

int