Skip to content

馃毃 Remap indexers layer_type - #48974

Merged
Cyrilvallez merged 11 commits into
mainfrom
remap-indexers
Sep 22, 2026
Merged

Cyrilvallez merged 11 commits into
mainfrom
remap-indexers

Conversation

@Cyrilvallez

@Cyrilvallez Cyrilvallez commented Sep 21, 2026

Copy link
Copy Markdown
Member

CPU CI GPU run-slow

What does this PR do?

As per the title. Instead of deepseek_sparse_attention, qwen_sparse_attention, xxx_sparse_attention etc etc, let's remap to a simpler indexed_attention as the cache/mask will always be similar for those variants

Also, much better to ALWAYS call remap_legacy_layer_types in the general __post_init__ vs only a few given Configs, since it's only a cheap lookup table -> will avoid many issues for custom checkpoints/configs/finetunes etc

Comment thread src/transformers/configuration_utils.py Outdated
Comment on lines +373 to +377
# Remap layer types if needed
if hasattr(self, "layer_types"):
self.layer_types = remap_legacy_layer_types(self.layer_types)
if hasattr(self, "mtp_layer_types"):
self.mtp_layer_types = remap_legacy_layer_types(self.mtp_layer_types)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this, the remap was happening only manually in a few given configs... Much better to make it automatic in the general __post_init__ of all, since it's only an extremely cheap lookup table

@Cyrilvallez

Copy link
Copy Markdown
Member Author

run-slow: axk2, deepseek_v32, glm5_next, glm_moe_dsa, granitemoehybrid, hy_v4, nemotron_h, olmo_hybrid, qwen3_5, qwen3_5_moe, qwen3_next, qwen4_exp

@huggingface huggingface deleted a comment from github-actions Bot Sep 21, 2026
@huggingface huggingface deleted a comment from github-actions Bot Sep 21, 2026
@huggingface huggingface deleted a comment from github-actions Bot Sep 21, 2026
@huggingface huggingface deleted a comment from github-actions Bot Sep 21, 2026
@huggingface huggingface deleted a comment from github-actions Bot Sep 21, 2026
@HuggingFaceDocBuilderDev

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@vasqu vasqu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mark with 馃毃 just in case since it's technically breaking if anyone relied on the exact namings of our cache (which shouldnt be many imo)

Comment on lines -108 to -109
else:
self.layer_types = remap_legacy_layer_types(self.layer_types)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok so this is now a general remap in config utils?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep


# Mapping from old names to new names
_LEGACY_LAYER_TYPE_REMAP = {
"conv": "linear_attention", # only in LFMv2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we removing this?

@Cyrilvallez Cyrilvallez Sep 22, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's part of the names we ALLOW 馃ゲ So I have no idea why it was in the deprecated mapping

Comment thread src/transformers/configuration_utils.py Outdated
Comment thread src/transformers/configuration_utils.py Outdated
# correct conventions), so it avoids trying to reset it
if (remapped := remap_legacy_layer_types(self.layer_types)) != self.layer_types:
self.layer_types = remapped
if getattr(self, "mtp_layer_types", None) is not None:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now needed for the dsa rename ig?

Comment thread src/transformers/configuration_utils.py Outdated
# This check should not be needed, but sometimes `layer_types` is a read-only @attribute (already following
# correct conventions), so it avoids trying to reset it
if (remapped := remap_legacy_layer_types(self.layer_types)) != self.layer_types:
self.layer_types = remapped

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we not just pass the layer type optionally so it has these conditional in there?

@Cyrilvallez Cyrilvallez Sep 22, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well we could pass the config into remap_legacy_layer_types directly to do it there, but then we have to also pass a list[str] to say which attributes we want to check (here both layer_types and mtp_layer_types) which makes it clunky IMO

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we decide to do it for both when the config is explicitly given

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually let me do that

@Cyrilvallez Cyrilvallez changed the title Remap indexers layer_type 馃毃 Remap indexers layer_type Sep 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: axk2, deepseek_v32, glm5_next, glm_moe_dsa, granitemoehybrid, hy_v4, nemotron_h, olmo_hybrid, qwen3_5, qwen3_5_moe, qwen3_next, qwen4_exp

@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 35682250828:1
Result: success | Jobs: 16 | Tests: 191,003 | Failures: 1 | Duration: 17h 27m

@Cyrilvallez
Cyrilvallez merged commit e2d83fd into main Sep 22, 2026
114 checks passed
@Cyrilvallez
Cyrilvallez deleted the remap-indexers branch September 22, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants