flashinfer.cake_mhc_train.cake_mhc_train_finish¶
- flashinfer.cake_mhc_train.cake_mhc_train_finish(X: Tensor, B: Tensor, handle) Tensor¶
Autograd-enabled
forward_finish:YfromX, the branch outputBand the preparehandle.- Parameters:
X (torch.Tensor) – The BF16
[T, 4, 4096]tensor passed tocake_mhc_train_prepare().B (torch.Tensor) – BF16
[T, 4096]output of the external branch applied toU(may require gradients).handle (object) – The handle returned by
cake_mhc_train_prepare(), for one finish. A reentrant checkpoint region (use_reentrant=True) holds both calls or starts after the prepare; it does not end between them.
- Returns:
BF16
Yof shape[T, 4, 4096]. Its backward returnsdBfor thebranch and no gradient for
X(the residual-mixing contribution is partof the single-cast
dXof the prepare node).