added hf adapter classes and llama hf implementation; added model testing suite#2
added hf adapter classes and llama hf implementation; added model testing suite#2JRosenkranz wants to merge 17 commits into
Conversation
… is what meta uses; added readme example for hf
| **kwargs, | ||
| ) -> BaseModelOutputWithPastAndCrossAttentions: | ||
| output = self.model( | ||
| output = self.model._helper( |
There was a problem hiding this comment.
ah, clearer seeing your motive in context.
|
|
||
| import torch | ||
| import torch.nn as nn | ||
| from transformers import LlamaForCausalLM |
There was a problem hiding this comment.
I think it's cleaner if the model code is independent, without first needing to import HF. maybe convert_hf_llama should be in a different file?
There was a problem hiding this comment.
ya that is an option, not sure where we want to put it, maybe we create a separate file called model_utils that has this for multiple different models?
…sed for a type hint in llama model; now using _has_hf in conversion
| """ | ||
|
|
||
| if not _has_hf: | ||
| raise ImportError("in order to convert huggingface weights, you need to have transformers installed") |
There was a problem hiding this comment.
I think it's worth separating the HF code from the main code, i.e. putting this function in a separate file from the model code.
There was a problem hiding this comment.
I think this has a place here, its providing a utility to load an FMS model from a huggingface model (not related to FMS Huggingface). If we move this, we maybe should move the meta load as well. One possibility is we add some form of FMS model creation utility.
There was a problem hiding this comment.
I can make the PR for moving both to different files
|
|
||
| import pytest | ||
|
|
||
|
|
There was a problem hiding this comment.
is this code related to HF equivalence? if so we should put it in that dir. otherwise it could be confusing if we add any other kind of model tests in this dir.
(and if it's not HF code, maybe should be a separate PR?)
I think I've already reviewed all of the actual code in an internal copy, but I'd like to keep it mostly consolidated in a directory. I think it'll be confusing if it's interspersed with other tests and code.
There was a problem hiding this comment.
this base is related to model consistency as well, it can be used with both. Note this PR: #9
This has no HF related code in it, just the non-hf and it uses the same classes.
| from fms.utils.config import ModelConfig | ||
| from tests.models.base import ModelBase | ||
|
|
||
|
|
There was a problem hiding this comment.
Same idea here as above, I think we should use a directory to make it clear that there's a suite of tests specifically testing equivalence to HF (and include that and only that in this PR).
Just looking at the file names/paths one might assume we have "test_config.py" for testing utils/config.py independently, and then separately there's a test_hf_config for testing hf config equivalence. but they're both added as part of this HF PR and I think are actually both related to HF.
There was a problem hiding this comment.
test_config is only related to our fms model config, test_hf_config includes our model config as well as hf config tests i believe
There was a problem hiding this comment.
I agree that HF tests in general should be in an HF folder, with things like hf_equivalence, hf_config, hf_model becoming subfolders of this hf folder, and becoming hf/equivalence, etc.
|
This is being replaced by #39 |
Signed-off-by: Sahil Suneja <suneja@us.ibm.com>
* adding siglip vision support Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * import fix Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * update attn_kwargs Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding tests Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff format Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * test update Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * siglip updates post review #2 Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding fms/models/llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding fms/models/llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * update attn_kwargs Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding tests for llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * rebasing on siglip branch + addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * rebse atop siglip #2 Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding hf bs fms output equivalence test Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * moving imports to make build framework happy during testing Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * pytest.mark.slow Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * mypy Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding HF config loading via hf_pretrained Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * percolate unfuse_weights to constituents Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * hf config loading check Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * recursive model config mapping Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * removing loops Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * fix graph break Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * combining input_ids and inputs_embeds args Signed-off-by: Sahil Suneja <suneja@us.ibm.com> --------- Signed-off-by: Sahil Suneja <suneja@us.ibm.com> Co-authored-by: Antoni Viros <aviros@ibm.com>
* adding siglip vision support Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * import fix Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * update attn_kwargs Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding tests Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff format Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * test update Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * siglip updates post review foundation-model-stack#2 Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding fms/models/llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding fms/models/llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * update attn_kwargs Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * ruff Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding tests for llava_next Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * rebasing on siglip branch + addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * rebse atop siglip foundation-model-stack#2 Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding hf bs fms output equivalence test Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * moving imports to make build framework happy during testing Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * pytest.mark.slow Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * addressing review comments Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * mypy Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * adding HF config loading via hf_pretrained Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * percolate unfuse_weights to constituents Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * hf config loading check Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * recursive model config mapping Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * removing loops Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * fix graph break Signed-off-by: Sahil Suneja <suneja@us.ibm.com> * combining input_ids and inputs_embeds args Signed-off-by: Sahil Suneja <suneja@us.ibm.com> --------- Signed-off-by: Sahil Suneja <suneja@us.ibm.com> Co-authored-by: Antoni Viros <aviros@ibm.com> Signed-off-by: Niraj Kamal Karunanidhi <nirajkkamal@gmail.com>
…g_attention Feature/ring attention
…beddings Fix weight loading to be compatible with FMS RoPE
Added the huggingface adapters along with model testing.