Practice in Lab: Partition AdamW parameters without duplicate ownership →
Partition AdamW parameters without duplicate ownership
A training policy must say which parameters receive decoupled weight decay. This exercise uses an explicit dimensional rule: matrices decay, while vectors and scalars do not. It is a policy to review, not a universal theorem about every architecture. Shared embeddings and tied output heads can expose the same parameter through several module paths. Duplicating ownership changes the update or causes an optimizer error. The Lab checks identities and executes an actual AdamW step rather than accepting only a plausible list of names.
import torch
layer = torch.nn.Linear(3, 2)
for name, p in layer.named_parameters():
print(name, p.ndim)Review the design
Defend the decay policy for normalization, embeddings, biases and adapters. Parameter identity, gradient participation and optimizer state ownership are separate concerns.
Your task
Return two optimizer group dicts with params lists. Include each distinct trainable parameter once. In this declared policy, tensors with ndim>=2 receive decay; scalars and vectors receive zero decay. Exclude frozen parameters. Reject negative/nonfinite decay and a model with no trainable parameters. Return original Parameter objects, not detached copies. Tied weights must not enter an optimizer twice.
The explanation opens here once every check passes.