-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Fix quant model param fetch regex #2662
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
Conversation
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.
Pull Request Overview
This PR improves the regex used to extract the approximate parameter count from model names in the quantization module, addressing issues with decimal values and lower-case “b” identifiers.
- Introduces a new helper function extract_approx_params_from_config to extract the parameter count from the model configuration.
- Updates get_model_param_count to use the new extraction function while removing the previous basic regex calculation.
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.
Pull Request Overview
This pull request improves the regex used for extracting approximate parameter counts from model configuration strings, addressing issues with decimal numbers in model names and lower-case "b" identifiers.
- Introduces a new helper function extract_approx_params_from_config.
- Updates get_model_param_count to use the new extraction function instead of the basic regex.
| lowercase_b_families = ["gemma"] # gemma uses small 'b' : google/gemma-3-1b-it | ||
| model_name = getattr(config, "name_or_path", "") | ||
| import re | ||
| cleaned = re.sub(r"[-_]?bnb[-_]?4bit|[-_]?4bit|[-_]?8bit|[-_]?bnb", "", model_name, flags=re.IGNORECASE) # replace bnb and xbit |
Copilot
AI
Jun 1, 2025
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.
The regex substitution comment mentions 'xbit', but the pattern does not match any 'xbit' strings. Please update either the comment or the regex to correctly handle 'xbit' if intended.
| cleaned = re.sub(r"[-_]?bnb[-_]?4bit|[-_]?4bit|[-_]?8bit|[-_]?bnb", "", model_name, flags=re.IGNORECASE) # replace bnb and xbit | |
| cleaned = re.sub(r"[-_]?bnb[-_]?4bit|[-_]?4bit|[-_]?8bit|[-_]?bnb|[-_]?xbit", "", model_name, flags=re.IGNORECASE) # replace bnb and xbit |
Fixes: #2661
The current regex is very basic and doesn't consider the following scenarios for example
I don't know if there are any. But I've tested with a few popular models and it works.
Note: Picking the param count from model name is not 100% accurate but is decent enough estimate.