#5931·burn

PositionWiseFeedForward skips learnable activation parameters during training and checkpointing

Author: Mikyx-1Created Oct 1, 2026Updated Oct 1, 2026

Describe the bug

PositionWiseFeedForward.activation is marked #[module(skip)], so learnable activations such as PReLU and SwiGLU are excluded from module parameter traversal. Their parameters are used in the forward pass and can receive raw autodiff gradients, but GradientsParams::from_grads does not collect those gradients for the normal optimizer step. Checkpoints also omit the activation parameters.

To Reproduce

  1. Initialize a PositionWiseFeedForwardConfig::new(1, 1) on an autodiff-enabled Flex device, with dropout 0.0, both linear layers using Initializer::Constant { value: 1.0 }, and ActivationConfig::PRelu(PReluConfig::new()) (slope 0.25).
  2. Forward the input [[[-2.0]]], sum the output, and backpropagate. The inner linear produces -1, and the raw gradient of the PReLU slope is -1.
  3. Collect gradients through GradientsParams::from_grads(grads, &model) and apply plain SGD with learning rate 0.1. The slope remains 0.25 instead of becoming 0.35.
  4. Separately, manually change the activation parameters, save the PWFF into BurnpackStore, and load it into a freshly initialized model. The saved activation values and resulting output are not restored. Both PReLU and SwiGLU are affected.

Expected behavior

Stateful activation parameters should participate in normal training, module state transitions, device transfers, parameter counts, and checkpoint save/load. Existing tensor checkpoints containing only the historical GELU activation should continue to load, since GELU has no parameter tensors.

Desktop

  • OS: Linux
  • Burn: 0.22.0-pre.4; the skipped activation field is present on upstream main at ff25e7354.
  • Backend: Flex with autodiff

Additional context

The forward activation dispatch already calls the stored activation module; the problem is the skipped module field. The skip comment cites compatibility with the old gelu field name. With named tensor checkpoints, the two linear layer paths can remain unchanged while stateful activation tensors are included.

Older checkpoints created with stateful activations never saved those parameters. A narrowly scoped loading filter can retain initialized activation parameters while preserving strict checks for the saved linear layers. The applier currently reports an absent filtered-out tensor as missing before honoring that filter, which also needs correction for this migration path.