Skip to content

Commit 4876ae6

Browse files
Remove MIXED quantization preset for transformer models (#1728)
Since recently MIXED preset is set by default for transformer models. List of notebooks where preset is set manually: [122-yolov8-quantization-with-accuracy-control.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/122-quantizing-model-with-accuracy-control/122-yolov8-quantization-with-accuracy-control.ipynb) – not a transformer [226-yolov7-optimization.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/226-yolov7-optimization/226-yolov7-optimization.ipynb) – not a transformer [230-yolov8-instance-segmentation.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/230-yolov8-optimization/230-yolov8-instance-segmentation.ipynb) – not a transformer [230-yolov8-keypoint-detection.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/230-yolov8-optimization/230-yolov8-keypoint-detection.ipynb) – not a transformer [230-yolov8-object-detection.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/230-yolov8-optimization/230-yolov8-object-detection.ipynb) – not a transformer [237-segment-anything.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/237-segment-anything/237-segment-anything.ipynb) – updated ✅ [249-oneformer-segmentation.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/249-oneformer-segmentation/249-oneformer-segmentation.ipynb) – updated ✅ [255-mms-massively-multilingual-speech.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/255-mms-massively-multilingual-speech/255-mms-massively-multilingual-speech.ipynb) – updated ✅ [259-decidiffusion-image-generation.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/259-decidiffusion-image-generation/259-decidiffusion-image-generation.ipynb) – updated ✅ [261-fast-segment-anything.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/261-fast-segment-anything/261-fast-segment-anything.ipynb) – not a transformer [263-latent-consistency-models-image-generation.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/263-latent-consistency-models-image-generation/263-latent-consistency-models-image-generation.ipynb) – updated ✅ [274-efficient-sam.ipynb](https://github.com/openvinotoolkit/openvino_notebooks/blob/main/notebooks/274-efficient-sam/274-efficient-sam.ipynb) – updated ✅ Ticket 133131
1 parent 9ccee7e commit 4876ae6

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

notebooks/237-segment-anything/237-segment-anything.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"source": [
88
"# Object masks from prompts with SAM and OpenVINO\n",
99
"\n",
10-
"#### Table of contents:\n\n",
10+
"#### Table of contents:\n",
11+
"\n",
1112
"- [Background](#Background)\n",
1213
"- [Prerequisites](#Prerequisites)\n",
1314
"- [Convert model to OpenVINO Intermediate Representation](#Convert-model-to-OpenVINO-Intermediate-Representation)\n",
@@ -81,7 +82,7 @@
8182
"metadata": {},
8283
"outputs": [],
8384
"source": [
84-
"%pip install -q \"segment_anything\" \"gradio>=4.13\" \"openvino>=2023.1.0\" \"nncf>=2.5.0\" \"torch>=2.1\" \"torchvision>=0.16\" --extra-index-url https://download.pytorch.org/whl/cpu"
85+
"%pip install -q \"segment_anything\" \"gradio>=4.13\" \"openvino>=2023.1.0\" \"nncf>=2.7.0\" \"torch>=2.1\" \"torchvision>=0.16\" --extra-index-url https://download.pytorch.org/whl/cpu"
8586
]
8687
},
8788
{
@@ -1873,7 +1874,7 @@
18731874
"quantized_model = nncf.quantize(model,\n",
18741875
" calibration_dataset,\n",
18751876
" model_type=nncf.parameters.ModelType.TRANSFORMER,\n",
1876-
" preset=nncf.common.quantization.structs.QuantizationPreset.MIXED, subset_size=128)\n",
1877+
" subset_size=128)\n",
18771878
"print(\"model quantization finished\")"
18781879
]
18791880
},
@@ -2238,4 +2239,4 @@
22382239
},
22392240
"nbformat": 4,
22402241
"nbformat_minor": 5
2241-
}
2242+
}

notebooks/249-oneformer-segmentation/249-oneformer-segmentation.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"metadata": {},
2929
"source": [
3030
"\n",
31-
"#### Table of contents:\n\n",
31+
"#### Table of contents:\n",
32+
"\n",
3233
"- [Install required libraries](#Install-required-libraries)\n",
3334
"- [Prepare the environment](#Prepare-the-environment)\n",
3435
"- [Load OneFormer fine-tuned on COCO for universal segmentation](#Load-OneFormer-fine-tuned-on-COCO-for-universal-segmentation)\n",
@@ -75,7 +76,7 @@
7576
}
7677
],
7778
"source": [
78-
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"transformers>=4.26.0\" \"openvino>=2023.1.0\" \"nncf>=2.6.0\" gradio torch scipy ipywidgets Pillow matplotlib"
79+
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"transformers>=4.26.0\" \"openvino>=2023.1.0\" \"nncf>=2.7.0\" gradio torch scipy ipywidgets Pillow matplotlib"
7980
]
8081
},
8182
{
@@ -935,7 +936,6 @@
935936
" model,\n",
936937
" calibration_dataset,\n",
937938
" model_type=nncf.parameters.ModelType.TRANSFORMER,\n",
938-
" preset=nncf.QuantizationPreset.MIXED,\n",
939939
" subset_size=len(coco_dataset),\n",
940940
" # smooth_quant_alpha value of 0.5 was selected based on prediction quality visual examination\n",
941941
" advanced_parameters=nncf.AdvancedQuantizationParameters(smooth_quant_alpha=0.5))\n",
@@ -1297,4 +1297,4 @@
12971297
},
12981298
"nbformat": 4,
12991299
"nbformat_minor": 5
1300-
}
1300+
}

notebooks/255-mms-massively-multilingual-speech/255-mms-massively-multilingual-speech.ipynb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
},
3535
"source": [
3636
"\n",
37-
"#### Table of contents:\n\n",
37+
"#### Table of contents:\n",
38+
"\n",
3839
"- [Prerequisites](#Prerequisites)\n",
3940
"- [Prepare an example audio](#Prepare-an-example-audio)\n",
4041
"- [Language Identification (LID)](#Language-Identification-(LID))\n",
@@ -85,7 +86,7 @@
8586
"outputs": [],
8687
"source": [
8788
"%pip install -q --upgrade pip\n",
88-
"%pip install -q \"transformers>=4.33.1\" \"openvino>=2023.1.0\" \"numpy>=1.21.0,<=1.24\" \"nncf>=2.6.0\" \n",
89+
"%pip install -q \"transformers>=4.33.1\" \"openvino>=2023.1.0\" \"numpy>=1.21.0,<=1.24\" \"nncf>=2.7.0\" \n",
8990
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu torch datasets accelerate soundfile librosa gradio jiwer"
9091
]
9192
},
@@ -1300,7 +1301,6 @@
13001301
" quantized_lid_model = nncf.quantize(\n",
13011302
" get_lid_model(lid_model_xml_path, compiled=False),\n",
13021303
" calibration_dataset=nncf.Dataset(calibration_data),\n",
1303-
" preset=nncf.QuantizationPreset.MIXED,\n",
13041304
" subset_size=len(calibration_data),\n",
13051305
" model_type=nncf.ModelType.TRANSFORMER\n",
13061306
" )\n",
@@ -1423,7 +1423,6 @@
14231423
" quantized_asr_model = nncf.quantize(\n",
14241424
" get_asr_model(asr_model_xml_path_template, language_id, compiled=False),\n",
14251425
" calibration_dataset=nncf.Dataset(calibration_data),\n",
1426-
" preset=nncf.QuantizationPreset.MIXED,\n",
14271426
" subset_size=len(calibration_data),\n",
14281427
" model_type=nncf.ModelType.TRANSFORMER\n",
14291428
" )\n",
@@ -1881,4 +1880,4 @@
18811880
},
18821881
"nbformat": 4,
18831882
"nbformat_minor": 5
1884-
}
1883+
}

notebooks/259-decidiffusion-image-generation/259-decidiffusion-image-generation.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
"6. Run Interactive demo for DeciDiffusion model.\n",
2424
"\n",
2525
"\n",
26-
"#### Table of contents:\n\n",
26+
"#### Table of contents:\n",
27+
"\n",
2728
"- [Prerequisites](#Prerequisites)\n",
2829
"- [Prepare DeciDiffusion models for OpenVINO format conversion](#Prepare-DeciDiffusion-models-for-OpenVINO-format-conversion)\n",
2930
" - [About model](#About-model)\n",
@@ -65,7 +66,7 @@
6566
"metadata": {},
6667
"outputs": [],
6768
"source": [
68-
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"diffusers\" \"transformers\" \"torch\" \"pillow\" \"openvino>=2023.1.0\" \"gradio\" \"datasets\" \"nncf\""
69+
"%pip install -q --extra-index-url https://download.pytorch.org/whl/cpu \"diffusers\" \"transformers\" \"torch\" \"pillow\" \"openvino>=2023.1.0\" \"gradio\" \"datasets\" \"nncf>=2.7.0\""
6970
]
7071
},
7172
{
@@ -1379,7 +1380,6 @@
13791380
" quantized_unet = nncf.quantize(\n",
13801381
" model=unet,\n",
13811382
" subset_size=subset_size,\n",
1382-
" preset=nncf.QuantizationPreset.MIXED,\n",
13831383
" calibration_dataset=nncf.Dataset(unet_calibration_data),\n",
13841384
" model_type=nncf.ModelType.TRANSFORMER,\n",
13851385
" # Smooth Quant algorithm reduces activation quantization error; optimal alpha value was obtained through grid search\n",
@@ -1850,4 +1850,4 @@
18501850
},
18511851
"nbformat": 4,
18521852
"nbformat_minor": 5
1853-
}
1853+
}

notebooks/263-latent-consistency-models-image-generation/263-latent-consistency-models-image-generation.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"In this tutorial, we consider how to convert and run LCM using OpenVINO. An additional part demonstrates how to run quantization with [NNCF](https://github.com/openvinotoolkit/nncf/) to speed up pipeline.\n",
1717
"\n",
1818
"\n",
19-
"#### Table of contents:\n\n",
19+
"#### Table of contents:\n",
20+
"\n",
2021
"- [Prerequisites](#Prerequisites)\n",
2122
"- [Prepare models for OpenVINO format conversion](#Prepare-models-for-OpenVINO-format-conversion)\n",
2223
"- [Convert models to OpenVINO format](#Convert-models-to-OpenVINO-format)\n",
@@ -52,7 +53,7 @@
5253
"outputs": [],
5354
"source": [
5455
"%pip install -q \"torch\" --index-url https://download.pytorch.org/whl/cpu\n",
55-
"%pip install -q \"openvino>=2023.1.0\" transformers \"diffusers>=0.23.1\" pillow gradio \"nncf>=2.6.0\" datasets --extra-index-url https://download.pytorch.org/whl/cpu"
56+
"%pip install -q \"openvino>=2023.1.0\" transformers \"diffusers>=0.23.1\" pillow gradio \"nncf>=2.7.0\" datasets --extra-index-url https://download.pytorch.org/whl/cpu"
5657
]
5758
},
5859
{
@@ -1261,7 +1262,6 @@
12611262
" quantized_unet = nncf.quantize(\n",
12621263
" model=unet,\n",
12631264
" subset_size=subset_size,\n",
1264-
" preset=nncf.QuantizationPreset.MIXED,\n",
12651265
" calibration_dataset=nncf.Dataset(unet_calibration_data),\n",
12661266
" model_type=nncf.ModelType.TRANSFORMER,\n",
12671267
" advanced_parameters=nncf.AdvancedQuantizationParameters(\n",
@@ -2598,4 +2598,4 @@
25982598
},
25992599
"nbformat": 4,
26002600
"nbformat_minor": 5
2601-
}
2601+
}

notebooks/274-efficient-sam/274-efficient-sam.ipynb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"\n",
1919
"\n",
2020
"\n",
21-
"#### Table of contents:\n\n",
21+
"#### Table of contents:\n",
22+
"\n",
2223
"- [Prerequisites](#Prerequisites)\n",
2324
"- [Load PyTorch model](#Load-PyTorch-model)\n",
2425
"- [Run PyTorch model inference](#Run-PyTorch-model-inference)\n",
@@ -57,7 +58,7 @@
5758
"metadata": {},
5859
"outputs": [],
5960
"source": [
60-
"%pip install -q \"openvino>=2023.3.0\" \"nncf>=2.7\" opencv-python matplotlib \"gradio>=4.13\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu"
61+
"%pip install -q \"openvino>=2023.3.0\" \"nncf>=2.7.0\" opencv-python matplotlib \"gradio>=4.13\" torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu"
6162
]
6263
},
6364
{
@@ -933,7 +934,7 @@
933934
"quantized_model = nncf.quantize(model,\n",
934935
" calibration_dataset,\n",
935936
" model_type=nncf.parameters.ModelType.TRANSFORMER,\n",
936-
" preset=nncf.common.quantization.structs.QuantizationPreset.MIXED, subset_size=128)\n",
937+
" subset_size=128)\n",
937938
"print(\"model quantization finished\")"
938939
]
939940
},
@@ -1837,4 +1838,4 @@
18371838
},
18381839
"nbformat": 4,
18391840
"nbformat_minor": 5
1840-
}
1841+
}

0 commit comments

Comments
 (0)