flashinfer.cake_rmsnorm_train.cake_rmsnorm_train_backward_workspace_bytes¶
- flashinfer.cake_rmsnorm_train.cake_rmsnorm_train_backward_workspace_bytes(rows: int, hidden: int, device: device, *, residual: bool = False, deterministic: bool = True) int¶
Bytes of the caller-owned backward workspace of width
hiddenondevicefor up torowstokens.deterministicis resolved as the backward resolves it (seecake_rmsnorm_train_backward()), so the buffer fits the kernels the backward call with the same flag runs. Undertorch.use_deterministic_algorithms(True, warn_only=True),deterministic=Falsewarns and returns the deterministic package’s size; the backward call of that fallback does not use a caller’s workspace (it passes none to the deterministic package, which allocates its own). The deterministic package’s workspace holds its chunk-claim counters and one FP32dwpartial row per chunk and grows withrows(flashinfer.cake_rmsnorm_det_train.cake_rmsnorm_det_train_backward_workspace_bytes()). The non-deterministic workspace has one layout for every call (cake_jit.workspace_layout, offsets fixed by the package): the deterministic pairs’uint32counters (cake_jit.COUNTERS_BYTES), the single kernel’s counters (cake_jit.SINGLE_COUNTERS_BYTESatcake_jit.SINGLE_COUNTERS_OFFSET), its FP64 column sums (cake_jit.SUMS_BYTESatcake_jit.SUMS_OFFSET, the largestworkspace_bytesof the package’s single kernels) and, when a window up torowsof the width runs the deterministic pair, that pair’s FP32 partial rows atcake_jit.PAIR_ROWS_OFFSET, which grow withrows. The size returned is the largest layout of the records the width’s backward routes (hidden,residual, both weight dtypes) run for up torowstokens. The buffer must be zero on first use (allocate withtorch.zerosor usecake_rmsnorm_train_backward_workspace()); after every launch the kernels leave the counters at rest and the sums at zero, so with no host write one buffer serves any sequence ofdeterministic=Falsebackward calls – hidden sizes, residual flags, weight dtypes, token counts, windows and CUDA Graph replays – whose sizes it covers. It serves calls of one mode: do not pass it to adeterministic=Truecall (that package’s workspace has another layout). Zeroing it again between calls is harmless. Backward calls that may run at the same time (on different streams) need one buffer each.