-
Notifications
You must be signed in to change notification settings - Fork 223
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
Initial stab at string based config parser #1774
base: main
Are you sure you want to change the base?
Conversation
stack-info: PR: #1774, branch: drisspg/stack/39
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/ao/1774
Note: Links to docs will display an error until the docs builds have been completed. ❌ 7 New FailuresAs of commit ed64709 with merge base 38e36de ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
c9f0b11
to
ed64709
Compare
Didn't read the code yet, but a couple of high level questions:
|
My high-level thoughts are:
|
I'd change that to "one benefit, from several, of a string API is quick shorthand...". One other benefit is serialization/deserialization, i.e. being able to go between strings and Python objects. |
Not as implemented unless you define your param matcher so that it clearly disambiguates the two
You could write a param-matcher to do this. But feels kinda weird or at least I dont really know a good notation for doing this besides a few special matrices
I went back and fourth on this. We could enforce that AoBaseconfigs define their "string_form"
I very much agree w/ this and thus why I only added a few params its very easy to add 0 params and just enforce the string map and you only get default values.
Agree I played w/ having a "wSym" "wAsym" "aSym" "aAsym" +1 on complexity
Yeah listed this as follow up. Not tottally sure what you mean by multiple strings map to same config. As stated here that is possible since we dont enforce a param order. But if just had base_config + dtypes then I think we should not allow for multiple strings |
Stacked PRs:
Configuration String Parser for TorchAO Quantization
This document explains how this prototype example string-based configuration system could* work for TorchAO quantization, including the parsing process and how to extend it for future needs.
Configuration String Schema
The configuration strings follow this general pattern:
<base_config>_<param1>_<param2>_...
Where:
<base_type>
defines the fundamental quantization config (e.g.,Int8WeightOnlyConfig
,Float8DynamicActivationFloat8WeightConfig
)<param>
adds specific configurations like bit width, group size, or data typeBase Types
The following base types are supported:
int4wo
Int4WeightOnlyConfig
int8wo
Int8WeightOnlyConfig
int8dqint4
Int8DynamicActivationInt4WeightConfig
int8dqint8
Int8DynamicActivationInt8WeightConfig
int4dqint4
Int4DynamicActivationInt4WeightConfig
float8wo
Float8WeightOnlyConfig
float8dqfloat8
Float8DynamicActivationFloat8WeightConfig
uintxwo
UIntXWeightOnlyConfig
Parameter Tokens
WIP: Need to finalize on what params we think we should support and which ones we shouldn't as well as naming scheme
Parameters are specified as tokens after the base type, separated by underscores. Each parameter has its own format:
<N>bit
4bit
bits
g<N>
g32
group_size
sym
orasym
sym
mapping_type
int4
,int8
,uint4
,uint8
,e4m3
,e5m2
int8
dtype
orweight_dtype
per_row
per_row
per_row
The Parsing Process
The parsing process follows these steps:
_
) into tokensExample Parsing
Example configuration string:
int8dqint4_g32_sym
["int8dqint4", "g32", "sym"]
int8dqint4
maps toInt8DynamicActivationInt4WeightConfig
g32
matches the patterng(\d+)
and setsgroup_size=32
sym
matches the pattern(sym|asym)
and setsmapping_type=MappingType.SYMMETRIC
Int8DynamicActivationInt4WeightConfig(group_size=32, mapping_type=MappingType.SYMMETRIC)
Extending the Parser
You can extend the parser in several ways:
1. Add New Base Configuration Types
To add a new base configuration type:
2. Add New Parameter Types
To add a new parameter type:
3. Create Special Processing Logic
If you need special handling based on the config type:
Best Practices for Extensions
When extending the parser:
Complete Example
To add support for a new "fast" parameter that enables faster computation:
Open Questions
1. Parameter Selection and Naming
g32
) or clarity (group32
)?2. Parameter Validation
3. Default Values
4. Extensibility
6. Backward Compatibility
Parsing Flow Diagram