Skip to content

Commit

Permalink
Add quantization config option (#433)
Browse files Browse the repository at this point in the history
Co-authored-by: ZHENG, Zhen <[email protected]>
Co-authored-by: Logan Adams <[email protected]>
  • Loading branch information
3 people authored Mar 8, 2024
1 parent 6062c89 commit 429bc5c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions mii/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def _parse_kwargs_to_model_config(

# Create the ModelConfig object and return it with remaining kwargs
model_config = ModelConfig(**model_config)

return model_config, remaining_kwargs


Expand Down
13 changes: 13 additions & 0 deletions mii/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ class ModelConfig(MIIConfigModel):
`inference_engine_config`.
"""

quantization_mode: Optional[str] = None
"""
The quantization mode in string format. The supported modes are as follows:
- 'wf6af16', weight-only quantization with FP6 weight and FP16 activation.
"""

inference_engine_config: RaggedInferenceEngineConfig = {}
"""
DeepSpeed inference engine config. This is automatically generated, but you
Expand Down Expand Up @@ -210,6 +216,13 @@ def propagate_tp_size(cls, values: Dict[str, Any]) -> Dict[str, Any]:
values.get("inference_engine_config").tensor_parallel.tp_size = tensor_parallel
return values

@root_validator
def propagate_quantization_mode(cls, values: Dict[str, Any]) -> Dict[str, Any]:
quantization_mode = values.get("quantization_mode")
values.get(
"inference_engine_config").quantization.quantization_mode = quantization_mode
return values

@root_validator
def check_replica_config(cls, values: Dict[str, Any]) -> Dict[str, Any]:
num_replica_config = len(values.get("replica_configs"))
Expand Down
2 changes: 1 addition & 1 deletion requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
asyncio
deepspeed>=0.13.0
deepspeed>=0.14.0
deepspeed-kernels
Flask-RESTful
grpcio
Expand Down

0 comments on commit 429bc5c

Please sign in to comment.