Back Home

GitHub Repo

Transformers Community Reports Weight Export Regression That May Prevent Parameter Restoration

A Transformers community report on October 30 says certain weight-renaming rules introduced in 5.21.0 may produce incorrect keys, causing parameters to be lost when exported models are reloaded. A fix and unit test have been proposed, but had not been merged at the time of review; the scope of impact remains unclear.

Marcus Qwertyus · Public domain · Image source
zh-Hant

On October 30, the Transformers community reported a model export regression: when weight conversion uses a WeightRenaming rule with a trailing $ anchor, save_pretrained() may write a regular-expression symbol into a parameter key. The reporter said save-and-load round trips work in 5.20.0 but reproduce the issue in 5.21.0 and 5.22.0. These are community test results, not a maintainer-confirmed list of all affected versions. Issue report

The specific case involves LiquidAI’s LFM3-Audio-2B: a weight that should be exported as mask_embedding instead becomes mask_embedding$, so it cannot match the original rule when reloaded. The reporter says the exported model is consequently left with randomly initialized parameters, causing abnormal speech generation without a warning. The model’s public code confirms that this parameter is used by the speech depth decoder and is initialized from a normal distribution with a standard deviation of 0.02. However, this review did not independently run a full reproduction. Model code

The proposed fix locates the problem in string handling when reversing weight mappings: the pattern converted into a replacement string must have its trailing $ removed, while the reverse-matching pattern must retain the end anchor. PR #50178 restores both behaviors and adds test_reverse_anchored_patterns. At the time of review, the PR was still open and the page showed no approval, so it cannot be considered fixed in an official release. Proposed fix

This report is particularly relevant to workflows for exporting fine-tuned models, converting model formats, and packaging deployments. The official documentation lists directories saved by save_pretrained() as sources for loading with from_pretrained(). Accordingly, engineering validation should cover parameter keys, tensor contents, and fixed-input outputs before and after saving—not merely confirm that files were written successfully. Next, watch for the fix to be merged, a release containing it, and round-trip tests on additional models. Current evidence is insufficient to conclude that all Transformers models are affected. Loading and saving documentation

Sources

  1. Transformers Issue #50177:結尾錨點權重映射的匯出回歸
  2. Transformers PR #50178:修復反向權重映射的結尾錨點處理
  3. LFM3-Audio-2B 模型實作
  4. Transformers 模型載入與儲存 API 文件