Add IBM Granite architecture support#683
Merged
Merged
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
Adds architecture definition for GraniteForCausalLM (IBM Granite 3.x dense models). Without this, mergekit logs "No JSON architecture found for GraniteForCausalLM" and falls back to inference for every Granite model. Granite uses the same transformer weight layout as Llama (q/k/v/o projections, gate/up/down MLP, input and post-attention layernorms) with model_type "granite". Optional bias entries are included for models released with attention_bias=True or mlp_bias=True to prevent silent tensor loss during merges. Adds make_picogranite() to test helpers and TestGraniteMerges covering passthrough copy, linear merge, and SLERP.
0ca5233 to
fb75d9a
Compare
Import torch in architecture/base.py so Pydantic can resolve the torch.dtype forward reference in PretrainedConfig, then call model_rebuild() on ConfiguredModuleArchitecture and ConfiguredModelArchitecture to complete type resolution.
Collaborator
|
Thanks for the PR! |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Adds architecture definition for GraniteForCausalLM (IBM Granite 3.x dense models). Without this, mergekit logs "No JSON architecture found for GraniteForCausalLM" and falls back to inference for every Granite model.
Granite uses the same transformer weight layout as Llama (q/k/v/o projections, gate/up/down MLP, input and post-attention layernorms) with model_type "granite". Optional bias entries are included for models released with attention_bias=True or mlp_bias=True to prevent silent tensor loss during merges.
Adds make_picogranite() to test helpers and TestGraniteMerges covering passthrough copy, linear merge, and SLERP.
Note
Medium Risk
Adds a new JSON architecture mapping and forces Pydantic model rebuilds for
Configured*Architecture, which could affect architecture loading/validation across model types if the forward-reference resolution changes.Overview
Adds first-class support for IBM Granite dense models by introducing a
granite.jsonarchitecture definition (including optional bias tensors and tiedlm_headhandling) so merges no longer fall back to architecture inference.Updates
mergekit/architecture/base.pyto importtorchforPretrainedConfigforward-ref resolution and explicitlymodel_rebuild()the configured architecture Pydantic models.Extends the test suite with a minimal
GraniteForCausalLMfixture (make_picogranite) and new passthrough/linear/SLERP merge coverage for Granite models.Reviewed by Cursor Bugbot for commit e1a7b40. Bugbot is set up for automated code reviews on this repo. Configure here.