pub struct FusedOps;Expand description
Associated constants for the well-known fused-op ids. Rule code
matches Op::Fused(FusedOps::SOFTMAX_LAST_DIM, _) — almost as
ergonomic as today’s Op::SoftmaxLastDim. Steps 3-4 fill these in
as each fused op migrates to the registry.
Implementations§
Source§impl FusedOps
impl FusedOps
Sourcepub const SOFTMAX_LAST_DIM: FusedOpId
pub const SOFTMAX_LAST_DIM: FusedOpId
SoftmaxLastDim — proof-of-concept migration target (step 3).
Sourcepub const FUSED_LINEAR: FusedOpId
pub const FUSED_LINEAR: FusedOpId
FusedLinear — first multi-input fused op migrated to the
registry (step 4). Three inputs [a, b, bias], output
(a @ b) + bias. The CUTLASS bias-epilogue integration in the
baracuda-cutlass alpha.13 plan registers here.
Sourcepub const RMS_NORM_LAST_DIM: FusedOpId
pub const RMS_NORM_LAST_DIM: FusedOpId
RmsNormLastDim — x / sqrt(mean(x²) + eps) along the last dim.
Migrated in step 4 (continued). Single input + eps param.
Sourcepub const LAYER_NORM_LAST_DIM: FusedOpId
pub const LAYER_NORM_LAST_DIM: FusedOpId
LayerNormLastDim — (x - mean) / sqrt(var + eps) along the
last dim (no affine). Single input + eps param.
Sourcepub const ROPE: FusedOpId
pub const ROPE: FusedOpId
Rope — rotary position embedding with caller-supplied cos/sin
tables. Three inputs [x, cos, sin], parameterless (the seq/
head_dim shape parameters live in the input shapes).
Sourcepub const CONV2D: FusedOpId
pub const CONV2D: FusedOpId
Conv2D — 2-D cross-correlation. Two or three inputs [x, weight] or [x, weight, bias]; carries stride / padding /
groups in FusedOpParams::Conv2D.
Sourcepub const SOFTMAX_LAST_DIM_BACKWARD: FusedOpId
pub const SOFTMAX_LAST_DIM_BACKWARD: FusedOpId
SoftmaxLastDimBackward — fused backward helper for the
SoftmaxLastDim forward. Two inputs [y, upstream],
parameterless. Wired through BackwardKind::Fused from
SOFTMAX_LAST_DIM’s entry.
Sourcepub const LAYER_NORM_LAST_DIM_BACKWARD: FusedOpId
pub const LAYER_NORM_LAST_DIM_BACKWARD: FusedOpId
LayerNormLastDimBackward — fused backward helper for the
LayerNormLastDim forward. Two inputs [x, upstream] + eps.
Sourcepub const RMS_NORM_LAST_DIM_BACKWARD: FusedOpId
pub const RMS_NORM_LAST_DIM_BACKWARD: FusedOpId
RmsNormLastDimBackward — fused backward helper for the
RmsNormLastDim forward. Two inputs [x, upstream] + eps.
Sourcepub const REDUCE_MAX_TO_BACKWARD: FusedOpId
pub const REDUCE_MAX_TO_BACKWARD: FusedOpId
ReduceMaxToBackward — fused backward helper for the
Op::ReduceMaxTo primitive (routes upstream to argmax
positions, fair-share on ties). Two inputs [x, upstream],
parameterless. Note this is the backward of a primitive
(Op::ReduceMaxTo), not of a fused forward — there’s no
BackwardKind::Fused edge wired to this helper, autograd
reaches it directly from Op::ReduceMaxTo’s arm.
Sourcepub const CONV_TRANSPOSE2D: FusedOpId
pub const CONV_TRANSPOSE2D: FusedOpId
ConvTranspose2D — fractionally-strided 2-D convolution.
Two inputs [x, weight] (no bias); carries
stride/padding/output_padding/dilation/groups in
FusedOpParams::ConvTranspose2D.
Sourcepub const FLASH_ATTN: FusedOpId
pub const FLASH_ATTN: FusedOpId
FlashAttn — multi-head attention with FlashAttention-shaped kernel hooks. 4-5 inputs (q, k, v, optional alibi).
Sourcepub const PAGED_ATTN: FusedOpId
pub const PAGED_ATTN: FusedOpId
PagedAttn — paged-cache attention. 5-6 inputs.
Sourcepub const QMATMUL: FusedOpId
pub const QMATMUL: FusedOpId
QMatMul — quantized matmul C = A @ dequant(W_Q). Two
inputs [a, w_q_bytes].
Sourcepub const POWI_BACKWARD: FusedOpId
pub const POWI_BACKWARD: FusedOpId
PowIBackward — fused backward helper for Op::PowI(n).
grad_x = n · x^(n-1) · upstream. Two inputs [x, upstream],
carries exp: i32 in FusedOpParams::PowIBackward. Replaces
the autograd primitive decomposition (PowI(n-1) → MulScalar →
Mul, 3 nodes) with a single launch of baracuda alpha.31’s
unary_powi_backward_* kernel. Note this is the backward of a
primitive (Op::PowI), not of a fused forward — autograd
reaches it directly from Op::PowI’s arm rather than via a
BackwardKind::Fused edge.
Sourcepub const INPLACE_AFFINE: FusedOpId
pub const INPLACE_AFFINE: FusedOpId
In-place affine: x = mul·x + add. Single input (the mutated
tensor), single launch into baracuda’s affine_inplace_*
symbol on CUDA. Carries mul: f64, add: f64 in
FusedOpParams::InplaceAffine. Marked destructive on input
0 via Op::destructive_input, so opt::derive_ordering pins
it to run after every non-destructive reader. Phase 1 of the
in-place ops infrastructure
(docs/session-prompts/in-place-ops-infrastructure.md);
dispatch + autograd integration deferred to Phases 3 + 4.
Sourcepub const FUSED_SOFTMAX_CROSS_ENTROPY: FusedOpId
pub const FUSED_SOFTMAX_CROSS_ENTROPY: FusedOpId
FusedSoftmaxCrossEntropy — fused softmax + NLL over class-indexed
targets. Two inputs [logits, targets]; carries
{ reduction, ignore_index } in
FusedOpParams::FusedSoftmaxCrossEntropy. The forward kernel
avoids materializing the [..., V] softmax/log-softmax
intermediates that the primitive composition does (fuel-core:: train::cross_entropy_with_logits). Backward via Decompose runs
the primitive chain; the in-place Liger-style fused backward is a
later session (needs in-place mutation infrastructure).
Sourcepub const CAUSAL_CONV1D: FusedOpId
pub const CAUSAL_CONV1D: FusedOpId
CausalConv1d — depthwise 1-D convolution + causal masking +
optional fused SiLU. Three inputs [x, weight, bias] where
x: [batch, channels, seq + kernel - 1],
weight: [channels, 1, kernel], bias: [channels]. Carries
use_silu: bool in FusedOpParams::CausalConv1d. The forward
kernel matches baracuda’s causal_conv1d_*_run contract.
BackwardKind::NotDifferentiable for v1 (Mamba inference path
today is inference-only).
Sourcepub const SELECTIVE_SCAN: FusedOpId
pub const SELECTIVE_SCAN: FusedOpId
SelectiveScan — Mamba-1’s selective state-space scan
(forward only). Five inputs [u, delta, a, b, c]; one output
y: [batch, seqlen, dim]. Carries delta_softplus: bool in
FusedOpParams::SelectiveScan. v1 drops the optional
inputs (d_skip, z, delta_bias) and the last_state second
output — both are mechanical follow-ups when a consumer needs
them. BackwardKind::NotDifferentiable for v1.
Sourcepub const SSD_CHUNK_SCAN: FusedOpId
pub const SSD_CHUNK_SCAN: FusedOpId
SsdChunkScan — Mamba-2’s State-Space Duality chunked scan
(forward only). Five inputs [x, dt, a, b, c]; one output
y: [batch, seqlen, heads, head_dim]. Carries
chunk_size: usize in FusedOpParams::SsdChunkScan
(parallelism granularity for the GPU path; the CPU kernel
runs sequential and any positive chunk_size dividing
seqlen produces the same mathematical answer).
BackwardKind::NotDifferentiable for v1.
Sourcepub const NF4_MATMUL: FusedOpId
pub const NF4_MATMUL: FusedOpId
Nf4Matmul — bitsandbytes-style 4-bit NormalFloat quantized
matrix multiply. Three inputs [activations, w_packed, absmax]
where w_packed: [N, K/2] U8 and absmax: [N, K/block_size] F32.
Output [..., M, N] matching activations’ dtype (F32/F16/BF16
in v1). Carries block_size: usize in
FusedOpParams::Nf4Matmul. BackwardKind::NotDifferentiable
(NF4 weights are frozen; the dequant-then-matmul fallback is
the wrong path for the cases NF4 exists to optimize).
Sourcepub const FLASH_ATTN_BACKWARD_Q: FusedOpId
pub const FLASH_ATTN_BACKWARD_Q: FusedOpId
FlashAttnBackwardQ — produces dQ from (q, k, v, do, [alibi]).
See fuel_ir::dispatch::OpKind::FlashAttnBackwardQ. Three
separate FusedOp ids (Q/K/V) is the v1 design — a single
multi-output op would share the recompute pass across all three
gradients but needs multi-output infrastructure that doesn’t
exist yet. Reuses FusedOpParams::FlashAttnBackward.
Sourcepub const FLASH_ATTN_BACKWARD_K: FusedOpId
pub const FLASH_ATTN_BACKWARD_K: FusedOpId
FlashAttnBackwardK — produces dK. See Self::FLASH_ATTN_BACKWARD_Q.
Sourcepub const FLASH_ATTN_BACKWARD_V: FusedOpId
pub const FLASH_ATTN_BACKWARD_V: FusedOpId
FlashAttnBackwardV — produces dV. See Self::FLASH_ATTN_BACKWARD_Q.
Sourcepub const AWQ_MATMUL: FusedOpId
pub const AWQ_MATMUL: FusedOpId
AwqMatmul — AWQ (mit-han-lab) asymmetric int4 weight-only
matmul. Four inputs [activations, weight, zeros, scales]
(one more than NF4’s three — AWQ’s zero-point is a fourth
operand, not baked into the dequant like NF4’s codebook) where
weight: [N, K/8] U32, zeros: [N, zeros_w] U32,
scales: [N, 8 * zeros_w] F16 — the baracuda kernel layout.
Output [..., M, N] matching activations’ dtype
(F32/F16/BF16 in v1). Carries { group_size, split_k_iters }
in FusedOpParams::AwqMatmul. BackwardKind::Decompose
(the weight is frozen; the activation gradient flows through
the decompose). Unlike NF4 (a non-linear codebook with no
primitive spelling), AWQ’s affine dequant decomposes cleanly
into primitives — see the module doc on
crate::registry::awq_matmul for the recipe.