Repository navigation
Add a tiny Laguna model - #8589
Open
albertvillanova wants to merge 1 commit into
Open
albertvillanova wants to merge 1 commit into
albertvillanova wants to merge 1 commit into
Conversation
|
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. |
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.
This PR adds a generation script for
trl-internal-testing/tiny-LagunaForCausalLM, based onpoolside/Laguna-XS.2.Part of #7943.
Motivation
Laguna is only covered by the parsing tests, which borrow another tokenizer (#8511 (review)). A tiny Laguna model lets it join the model parametrizations (SFT, GRPO with tools, the training template suite) like the other families. The stacked PR above it, #8511, uses this model.
Changes
laguna_for_causal_lm.py, which generatestiny-LagunaForCausalLMwith the tokenizer and generation config ofpoolside/Laguna-XS.2. Laguna was added in transformers 5.7.0, but before 5.16.0 the order in which its rotary embedding registers the per-layer-type buffers comes from a set, so building the model fails at random (fixed in deterministic layer_types buffer registration in multiple models transformers#48162). The script pins 5.16.0.Alignment with the reference
Dry run at transformers 5.16.0, with the real save and only the Hub calls stubbed. The config diff against
poolside/Laguna-XS.2has 16 keys:hidden_size2048 → 8,intermediate_size8192 → 32,num_attention_heads48 → 4,num_key_value_heads8 → 2,head_dim128 → 8,num_experts256 → 4,num_experts_per_tok8 → 2,moe_intermediate_size512 → 32,shared_expert_intermediate_size512 → 32num_hidden_layers40 → 2,layer_types[full_attention, sliding_attention],mlp_layer_types[dense, sparse],num_attention_heads_per_layer[4, 8](the sliding attention layers keep more heads than the full attention ones)auto_map: dropped, the model is the transformersLagunaForCausalLMpartial_rotary_factor(0.5): dropped.LagunaConfigwrites it over the per-layer-type value of the sliding attention layers (1.0), while the model only reads the per-layer-type values inrope_parameters, which match the reference.Every other key is the same as the reference, and all tensors have the reference dtype. The reloaded saved files run a forward pass and
generateat transformers 5.16.0 and 5.22.0.Note
Low Risk
Adds an isolated generation script with no changes to training, inference, or library runtime code.
Overview
Adds
laguna_for_causal_lm.pyto the tiny-model generator suite, producingtiny-LagunaForCausalLMwith tokenizer and generation config frompoolside/Laguna-XS.2.The script shrinks the reference architecture to two layers (full attention + dense MLP, then sliding attention + sparse MoE), applies the usual
_commonchecks (smoke_test, dtype pattern, config diff, Hub push), and pins transformers 5.16.0 because earlier versions can fail nondeterministically when building Laguna’s per-layer rotary buffers.Reviewed by Cursor Bugbot for commit d68206d. Bugbot is set up for automated code reviews on this repo. Configure here.