-
Notifications
You must be signed in to change notification settings - Fork 145
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
Added OLMo support to builder.py #1061
Open
shobrienDMA
wants to merge
14
commits into
microsoft:main
Choose a base branch
from
shobrienDMA:shobrien/add-olmo-builder-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+24
−5
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c94ee92
adding OLMO to the list of Decoder Only Models
shobrienDMA 149cef2
Added OLMoModel Class and config.architecture detection, and temporar…
shobrienDMA df8107f
Comment out our hack, modify the OLMo class to attempt to skip the La…
shobrienDMA c2071d5
add olmo builder support
shobrienDMA 814faa6
Pulled the layernorm.weight and layernorm.bias values from the config…
shobrienDMA 2faf06e
Merge branch 'microsoft:main' into shobrien/add-olmo-builder-support
shobrienDMA d0bc543
Merge branch 'main' into shobrien/add-olmo-builder-support
shobrienDMA 1ba81c8
fix new issue where bos_token_id was always set to None if it didn't …
shobrienDMA 30bb7a5
Update readmes and add OLMo and Qwen to the CI tests_utils
shobrienDMA 45dc21b
Merge branch 'main' into shobrien/add-olmo-builder-support
shobrienDMA 37bd4fb
Merge branch 'main' into shobrien/add-olmo-builder-support
shobrienDMA 05f9208
pin transformers to 4.44.2 for the python tests
shobrienDMA 1731adc
Merge branch 'main' of https://github.com/microsoft/onnxruntime-genai…
shobrienDMA fafc989
Bump ONNX Runtime Extensions dependency version
shobrienDMA 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 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 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 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 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 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 |
---|---|---|
|
@@ -330,7 +330,7 @@ def make_genai_config(self, model_name_or_path, extra_kwargs, out_dir): | |
|
||
genai_config = { | ||
"model": { | ||
"bos_token_id": config.bos_token_id if hasattr(config, "bos_token_id") else 1, # config.bos_token_id not present in ChatGLM model configs. | ||
"bos_token_id": config.bos_token_id if hasattr(config, "bos_token_id") and config.bos_token_id != None else 1, # config.bos_token_id not present in ChatGLM model configs. | ||
"context_length": self.context_length, | ||
"decoder": { | ||
"session_options" : { | ||
|
@@ -3085,6 +3085,14 @@ def make_layer(self, layer_id, layer): | |
layer.self_attn = layer.self_attn if hasattr(layer, 'self_attn') else layer.self_attention | ||
super().make_layer(layer_id, layer) | ||
|
||
class OLMoModel(Model): | ||
def __init__(self, config, io_dtype, onnx_dtype, ep, cache_dir, extra_options): | ||
super().__init__(config, io_dtype, onnx_dtype, ep, cache_dir, extra_options) | ||
|
||
def make_layernorm(self, layer_id, layernorm, skip, simple, location): | ||
layernorm.weight = torch.ones(self.hidden_size) | ||
layernorm.bias = torch.zeros(self.hidden_size) | ||
super().make_layernorm(layer_id, layernorm, skip, simple, location) | ||
|
||
class GraniteModel(MistralModel): | ||
def __init__(self, config, io_dtype, onnx_dtype, ep, cache_dir, extra_options): | ||
|
@@ -3244,6 +3252,14 @@ def create_model(model_name, input_path, output_dir, precision, execution_provid | |
onnx_model = Phi3VModel(config, io_dtype, precision, execution_provider, cache_dir, extra_options) | ||
elif config.architectures[0] == "Qwen2ForCausalLM": | ||
onnx_model = QwenModel(config, io_dtype, precision, execution_provider, cache_dir, extra_options) | ||
elif config.architectures[0] == "NemotronForCausalLM": | ||
onnx_model = NemotronModel(config, io_dtype, precision, execution_provider, cache_dir, extra_options) | ||
elif config.architectures[0] == "ChatGLMForConditionalGeneration" or config.architectures[0] == "ChatGLMModel": | ||
# Quantized ChatGLM model has ChatGLMForConditionalGeneration as architecture whereas HF model as the latter | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This appears to be a merge conflict issue. Nemotron and ChatGLM are checked earlier so they don't need to be checked again here. Can you also insert OLMo into the checks so that the alphabetical order is still maintained? |
||
config.hidden_act = "swiglu" | ||
onnx_model = ChatGLMModel(config, io_dtype, precision, execution_provider, cache_dir, extra_options) | ||
elif config.architectures[0] == "OlmoForCausalLM": | ||
onnx_model = OLMoModel(config, io_dtype, precision, execution_provider, cache_dir, extra_options) | ||
else: | ||
raise NotImplementedError(f"The {hf_name} model is not currently supported.") | ||
|
||
|
This file contains 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 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 |
---|---|---|
|
@@ -6,5 +6,5 @@ protobuf==5.27 | |
sympy | ||
pytest | ||
onnx | ||
transformers | ||
transformers==4.44.2 | ||
huggingface_hub[cli] |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.