fix(loader): resolve registered custom architectures and validate weights - #1459
Draft
Qiong Wu (qiowu) (DingmaomaoBJTU) wants to merge 2 commits into
Draft
Qiong Wu (qiowu) (DingmaomaoBJTU) wants to merge 2 commits into
Qiong Wu (qiowu) (DingmaomaoBJTU) wants to merge 2 commits into
Conversation
| EMOTION_REGRESSION_MODEL_TYPE = "wav2vec2_emotion_regression" | ||
|
|
||
| # Architecture identity selects the custom head, never performance settings. | ||
| ARCHITECTURE_LOADER_DEFAULTS = { |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The declared Wav2Vec2ForSpeechClassification architecture is not a Transformers class, so automatic loading could select a different head. Resolve registered custom architectures using native model_type, architecture and required config fields instead of an exact Hugging Face repository ID. The emotion regression registration reuses the existing EmotionModel and export variant; default performance settings remain unchanged. Renamed repositories and local copies follow the same metadata-based route.
Explicit task/class/type choices retain precedence. Ambiguous declarations and incompatible registered configs fail explicitly. EmotionModel opts into complete checkpoint loading checks: missing, unexpected, mismatched weights or loading errors reject the model instead of silently using a partially initialized head. This validates compatibility with an explicitly registered architecture, not arbitrary inference of forward semantics.
Validation: 721 loader/build-config tests passed; the restored direct-loader tests separately passed (27 tests). Ruff and diff checks passed. Real local-checkpoint automatic loading reached the custom model/export path without -c; the subsequent full ONNX export attempt failed due to insufficient disk space, so no complete build claim is made for this revision. No NPU benchmark or performance change is included.