Skip to content

[docs] Per-layer config - #48601

Merged
stevhliu merged 1 commit into
huggingface:mainfrom
stevhliu:hetero-config
Sep 8, 2026
Merged

stevhliu merged 1 commit into
huggingface:mainfrom
stevhliu:hetero-config

Conversation

@stevhliu

@stevhliu stevhliu commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

CPU CI GPU run-slow

Some updates and edits to improve the docs:

  • update from "Heterogeneous model configurations" to "Per-layer configurations" so its less abstract, shorter and clearer
  • lead with the problem and when to use per_layer_config so the motivation arrives faster for why to reach for this power feature

@eladsegal, if you could also take a look that'd be awesome 😄

@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 34154637673
Result: success | Grafana metrics are not available yet.

@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.

I would also check #47384 out since this was a bigger change after the introduction of this. But overall looks good

cc @hmellor if you have a better memory on this feature

title: Customizing models
- local: heterogeneous_configurations
title: Heterogeneous configurations
title: Per-layer configurations

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.

should we keep a reference to the old title somewhere?

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.

i think it's ok to leave it out, there are multiple instances of "heterogeneous" in the doc itself so it should still be searchable

| [nvidia/Llama-3_3-Nemotron-Super-49B-v1_5](https://huggingface.co/nvidia/Llama-3_3-Nemotron-Super-49B-v1_5) | [meta-llama/Llama-3.3-70B-Instruct](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) |
| [nvidia/Llama-3_1-Nemotron-Ultra-253B-v1](https://huggingface.co/nvidia/Llama-3_1-Nemotron-Ultra-253B-v1) | [meta-llama/Llama-3.1-405B-Instruct](https://huggingface.co/meta-llama/Llama-3.1-405B-Instruct) |
| [nvidia/gpt-oss-puzzle-88B](https://huggingface.co/nvidia/gpt-oss-puzzle-88B) | [openai/gpt-oss-120b](https://huggingface.co/openai/gpt-oss-120b) |
| [nvidia/NVIDIA-Nemotron-Labs-3-Puzzle-75B-A9B-BF16](https://huggingface.co/nvidia/NVIDIA-Nemotron-Labs-3-Puzzle-75B-A9B-BF16) | [nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16](https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-BF16) |

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.

We can also include gemma4, we refactored it with this feature

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

IIRC the Gemma4 checkpoint doesn't contain per_layer_config but the Python class reworks it, still a very relevant model for this feature though!

@hmellor hmellor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This all reads nicely to me!

@stevhliu
stevhliu added this pull request to the merge queue Sep 8, 2026
Merged via the queue into huggingface:main with commit bcd59bc Sep 8, 2026
34 checks passed
@stevhliu
stevhliu deleted the hetero-config branch September 8, 2026 17:47
> `per_layer_config`. Prefer the explicit architecture when one exists.

Examples of heterogeneous checkpoints include:
The models below are heterogeneous checkpoints. Layers are not uniform across the stack. They use a dedicated architecture with `block_configs` and their own `model_type`, rather than `per_layer_config` on a standard architecture.

@eladsegal eladsegal Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good clarification! I’m working on #45332, which will let us migrate these checkpoints to per_layer_config and remove the need for remote code. Once they’re migrated, we can update this section accordingly.


`per_layer_config` records and resolves configuration values. It does not by itself change the modules a model creates
or how those modules run. Applying a size override or a `skip` requires model code that reads the resolved per-layer
configuration when constructing or running each layer. The current `LlamaModel` constructs every `LlamaDecoderLayer`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I find it a little confusing to mention LlamaModel and LlamaDecoderLayer here, since they don't consume per_layer_config. I think it would be clearer to focus on what this example demonstrates, which is specifying and resolving the configs, and note that applying them to a model would require modeling support.

@eladsegal

Copy link
Copy Markdown
Contributor

@stevhliu Thanks for looping me in and making these improvements! I was a little late with my comments, but glad to see this merged :)

sbucaille pushed a commit to sbucaille/transformers that referenced this pull request Sep 16, 2026
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.

5 participants