Back Home

GitHub Repo

Transformers Community Reports Missing Mask2Former Parameter Registration; Projection Layers May Not Move to GPU with the Model

A Transformers community report on October 17 said some Mask2Former projection layers are stored in a plain Python list and may be omitted from optimizer and device-transfer workflows. A patch has been proposed, but the official fix release and any effect on segmentation accuracy remain unconfirmed.

Andrew Wippler from Lancaster, USA · CC BY 2.0 · Image source
zh-Hant

On October 17, Transformers received a report about Mask2Former: the Transformer decoder’s input_projections are stored in a plain Python list, so the projection layers are not registered as PyTorch submodules. The reporter noted that the v5.20.0 source uses this pattern and included a minimal reproduction. These parameters may not be included in the optimizer and may not move to CUDA with the model. Issue report

Mask2Former supports semantic, instance, and panoptic segmentation. The official documentation says enforce_input_projection is disabled by default; when enabled, it adds a 1×1 convolutional projection even if the input channel count matches the decoder’s hidden dimension. The reproduction sets both dimensions to 64 and enables this option, so it does not establish that the default inference path for all pretrained models will fail. Model and configuration documentation

The reproduction compares each projection layer’s weights with module.parameters() and lists 12,480 unregistered parameters. That figure applies to the test configuration; it is not a fixed count for all models. The report also says CUDA execution may raise a device mismatch error, with inputs on the GPU and weights still on the CPU. An optimizer built from the parameters enumerated by the model may therefore fail to update these projection weights. Reproduction details

The technical issue lies in how the container registers modules. PyTorch documentation states that nn.ModuleList supports list-style indexing while formally registering its contained modules, making them visible to the parent module’s methods. This means training checks should verify not only that the forward pass succeeds, but also that trainable weights appear in the parameter list and saved state, and reside on the correct device. PyTorch documentation

A contributor in the discussion said they submitted PR #49703 to replace the container with nn.ModuleList() and add a parameter registration test. As of the time of verification, the issue remained open; no official fix release had been confirmed, and no downstream accuracy measurements were available. Teams that have customized projection settings can check the parameter list and device placement, then track the patch review and the loading behavior of existing checkpoints. Patch proposal discussion

Sources

  1. Mask2Former input_projections 未註冊問題與修補討論
  2. Mask2Former 模型與設定文件
  3. torch.nn.ModuleList API 文件