Conversation
There was a problem hiding this comment.
Would it make sense to have this configs somewhere else and use them by default in case user does not provide a config?
Maybe in optimum/amd/default_cfgs/
Could ask this in the meeting tomorrow
optimum/amd/ryzenai/modeling.py
Outdated
| # is_dynamic = RyzenAIModel._check_uses_static_shape(path) | ||
| # if is_dynamic and provider == "VitisAIExecutionProvider": | ||
| # raise ValueError( | ||
| # "The model provided has dynamic axes in input/output. Please provide model with static shapes for inference with RyzenAI." | ||
| # ) |
There was a problem hiding this comment.
Should this be removed? Why is it commented out?
There was a problem hiding this comment.
In their documentation, its mentioned
For CNN’s on NPU platform, dynamic input shapes are currently not supported and only a batch size of 1 is allowed. Please ensure that the shape of input is a fixed value, and the batch dimension is set to 1.
But since, LLMs support dynamic shapes had to comment it. Shifted the error to image-classification model as we do not support transformers model there yet.
optimum/amd/ryzenai/modeling.py
Outdated
| if config: | ||
| self.model_type = config.model_type |
There was a problem hiding this comment.
config is hinted as PretrainedConfig, not Optional[PretrainedConfig] so I am not sure about the controflow here.
In general for simplicity, I think we should probably avoid dynamically defined instance attributes (i.e., all RyzenAIModel instances should (or should not) have a model_type attribute.
There was a problem hiding this comment.
I guess I added it because some of their pretrained models do not have config. So I made two changes now:
- Made config a hard requirement for
RyzenAIModelForCausalLM - Made it optional in
RyzenAIModel
|
|
||
| @classmethod | ||
| def _from_pretrained( | ||
| def _load_model_and_processors( |
There was a problem hiding this comment.
Maybe we discussed this already but why the renaming?
There was a problem hiding this comment.
This method is not actually renamed, but a new method is created. I could reuse the _load_model_and_processors in _from_pretrained of CausalLM class. The UI is making it look like its renamed.
| self.use_fp16 = False | ||
| for inp in model.get_inputs(): | ||
| if ( | ||
| inp.name == "past_key_values" or inp.name in self.key_value_input_names | ||
| ) and inp.type == "tensor(float16)": | ||
| self.use_fp16 = True | ||
| break |
There was a problem hiding this comment.
fp16 is not and never will be supported no? We could probably remove fp16 related code if so
There was a problem hiding this comment.
I did see some references of fp16 in their quantizer, but nothing concrete on device inference. So will remove it.
| "RYZENAI_SW_PATH environment variable is not set. Attempting to clone RyzenAI-SW repository now...\n" | ||
| ) | ||
| ryzenai_sw_path = normalize_path(os.path.join(os.getcwd(), "RyzenAI-SW")) | ||
| clone_repository("https://github.com/amd/RyzenAI-SW/", ryzenai_sw_path) |
There was a problem hiding this comment.
Couldn't we instead have https://github.com/amd/RyzenAI-SW as a git submodule with a pinned commit (in order to avoid breaking changes)?
No strong opinion here, could anyway revisit later. Still probably a good idea to pin the commit.
There was a problem hiding this comment.
I am using a specific commit after clone to avoid breaking changes. Added the RYZEN_SW_COMMIT_HASH at top of file.
| "opt", | ||
| "llama", | ||
| "mistral", |
There was a problem hiding this comment.
Added gpt bigcode, there are other models also which should be supported without a change. Would add them in other PR after full testing.
As per title!
Example Usage: