PositionWiseFeedForward skips learnable activation parameters during training and checkpointing
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
- Initialize a
PositionWiseFeedForwardConfig::new(1, 1)on an autodiff-enabled Flex device, with dropout0.0, both linear layers usingInitializer::Constant { value: 1.0 }, andActivationConfig::PRelu(PReluConfig::new())(slope0.25). - 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. - Collect gradients through
GradientsParams::from_grads(grads, &model)and apply plain SGD with learning rate0.1. The slope remains0.25instead of becoming0.35. - 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 atff25e7354. - 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.
Source: tracel-ai/burn