transformers
44412f6e - Fix TypeError in dot_natural_key when state_dict keys have mixed types at same position (#43966)

Commit
80 days ago
Fix TypeError in dot_natural_key when state_dict keys have mixed types at same position (#43966) * Fix TypeError in dot_natural_key when state_dict keys have mixed types When a model has sub-models with different naming conventions (e.g. 'model.layers.26.self_attn...' vs 'desc_model.roberta.encoder...'), dot_natural_key can produce lists where the same position contains an int in one key and a str in another. Python 3 cannot compare int and str, causing a TypeError during sorted(). Fix by returning tuples of (type_rank, int_value, str_value) for each segment, ensuring all comparisons are between same-typed values while preserving natural numeric ordering within each type. Fixes #43867 * Update src/transformers/core_model_loading.py * Update src/transformers/core_model_loading.py --------- Co-authored-by: Matt <Rocketknight1@users.noreply.github.com>
Author
Parents
Loading