-
Notifications
You must be signed in to change notification settings - Fork 2
Advanced
Don Kackman edited this page Jan 6, 2025
·
9 revisions
The quantization configuration allows you to specify how model components should be quantized to reduce memory usage and potentially improve performance. This is defined in the workflow JSON schema and processed by the pipeline system.
The quantization config can be specified for pipeline components like transformers, text encoders, etc. Here's the relevant schema structure:
"quantization_config": {
"type": "object",
"properties": {
"configuration": {
"type": "object",
"properties": {
"config_type": {
"type": "string"
}
},
"required": ["config_type"]
},
"arguments": {
"$ref": "#/$defs/arguments"
}
},
"required": ["configuration", "arguments"]
}Here's an example of using quantization config in a workflow file:
"transformer": {
"configuration": {
"pipeline_type": "SD3Transformer2DModel"
},
"quantization_config": {
"configuration": {
"config_type": "BitsAndBytesConfig"
},
"arguments": {
"load_in_4bit": true,
"bnb_4bit_quant_type": "nf4",
"bnb_4bit_compute_dtype": "torch.bfloat16"
}
},
"from_pretrained_arguments": {
"model_name": "stabilityai/stable-diffusion-3.5-large",
"subfolder": "transformer",
"torch_dtype": "torch.bfloat16"
}
}The BitsAndBytesConfig is used for 4-bit and 8-bit quantization using the bitsandbytes library. Common arguments include:
-
load_in_4bit: Enable 4-bit quantization -
bnb_4bit_quant_type: Quantization type (e.g., "nf4") -
bnb_4bit_compute_dtype: Computation data type
- Quantization config is optional for pipeline components
- The
config_typeshould be a valid configuration class (typically from transformers or diffusers) - Arguments are passed directly to the
config_typeconstructor - Improper configuration may result in runtime errors when loading the model