-
Notifications
You must be signed in to change notification settings - Fork 65
feat: Adds embed_tokens, lm_head as trainable for vocab expansion in peft and enables tying of adapters #625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dushyantbehl
merged 12 commits into
foundation-model-stack:main
from
romitjain:feat/embed-lmhead-tying-and-expansion
Nov 24, 2025
+248
−24
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
2ad3840
Added implementation
romitjain 4fff10b
Added test artifact and all tests
romitjain a5252fe
Moved to llama model for all testing
romitjain 931c087
Added deppcopy for peft config
romitjain 4f16cc8
Linting fixes
romitjain eeae8b7
Merge branch 'main' into feat/embed-lmhead-tying-and-expansion
romitjain a9b9344
Merge branch 'main' of github.com:foundation-model-stack/fms-hf-tunin…
romitjain 3a7cc16
Resolved comments
romitjain 154f489
Updated for PEFT v0.18.0
romitjain d19db92
Merge branch 'main' into feat/embed-lmhead-tying-and-expansion
dushyantbehl f208098
Updated pytest skip signature
romitjain 08cdbbd
Fixed lint errors
romitjain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
4 changes: 4 additions & 0 deletions
4
tests/artifacts/language_models/tiny-Gemma2ForCausalLM/chat_template.jinja
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| {{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% endif %}{% for message in messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + ' | ||
| ' + message['content'] | trim + '<end_of_turn> | ||
| ' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model | ||
| '}}{% endif %} |
34 changes: 34 additions & 0 deletions
34
tests/artifacts/language_models/tiny-Gemma2ForCausalLM/config.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "architectures": [ | ||
| "Gemma2ForCausalLM" | ||
| ], | ||
| "attention_bias": false, | ||
| "attention_dropout": 0.0, | ||
| "attn_logit_softcapping": 50.0, | ||
| "bos_token_id": 2, | ||
| "dtype": "float32", | ||
| "eos_token_id": 1, | ||
| "final_logit_softcapping": 30.0, | ||
| "head_dim": 256, | ||
| "hidden_activation": "gelu_pytorch_tanh", | ||
| "hidden_size": 8, | ||
| "initializer_range": 0.02, | ||
| "intermediate_size": 32, | ||
| "layer_types": [ | ||
| "sliding_attention", | ||
| "full_attention" | ||
| ], | ||
| "max_position_embeddings": 8192, | ||
| "model_type": "gemma2", | ||
| "num_attention_heads": 4, | ||
| "num_hidden_layers": 2, | ||
| "num_key_value_heads": 2, | ||
| "pad_token_id": 0, | ||
| "query_pre_attn_scalar": 256, | ||
| "rms_norm_eps": 1e-06, | ||
| "rope_theta": 10000.0, | ||
| "sliding_window": 4096, | ||
| "transformers_version": "4.57.0.dev0", | ||
| "use_cache": true, | ||
| "vocab_size": 256000 | ||
| } |
7 changes: 7 additions & 0 deletions
7
tests/artifacts/language_models/tiny-Gemma2ForCausalLM/generation_config.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "_from_model_config": true, | ||
| "bos_token_id": 2, | ||
| "eos_token_id": 1, | ||
| "pad_token_id": 0, | ||
| "transformers_version": "4.57.0.dev0" | ||
| } |
Binary file added
BIN
+8.01 MB
tests/artifacts/language_models/tiny-Gemma2ForCausalLM/model.safetensors
Binary file not shown.
34 changes: 34 additions & 0 deletions
34
tests/artifacts/language_models/tiny-Gemma2ForCausalLM/special_tokens_map.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| "additional_special_tokens": [ | ||
| "<start_of_turn>", | ||
| "<end_of_turn>" | ||
| ], | ||
| "bos_token": { | ||
| "content": "<bos>", | ||
| "lstrip": false, | ||
| "normalized": false, | ||
| "rstrip": false, | ||
| "single_word": false | ||
| }, | ||
| "eos_token": { | ||
| "content": "<eos>", | ||
| "lstrip": false, | ||
| "normalized": false, | ||
| "rstrip": false, | ||
| "single_word": false | ||
| }, | ||
| "pad_token": { | ||
| "content": "<pad>", | ||
| "lstrip": false, | ||
| "normalized": false, | ||
| "rstrip": false, | ||
| "single_word": false | ||
| }, | ||
| "unk_token": { | ||
| "content": "<unk>", | ||
| "lstrip": false, | ||
| "normalized": false, | ||
| "rstrip": false, | ||
| "single_word": false | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.