Skip to content

Commit

Permalink
Update transformers to fix CalledProcessError in optimum-cli call (#2657
Browse files Browse the repository at this point in the history
)

CVS-156213
  • Loading branch information
aleksandr-mokrov authored Jan 16, 2025
1 parent db8f650 commit b15d434
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
1 change: 1 addition & 0 deletions notebooks/text-to-image-genai/text-to-image-genai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"\n",
"%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\"\n",
"%pip install -q -U --pre --extra-index-url https://storage.openvinotoolkit.org/simple/wheels/nightly \"openvino>=2024.5\" \"openvino-tokenizers>=2024.5\" \"openvino-genai>=2024.5\"\n",
"%pip install -q -U \"transformers>=4.45\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q Pillow \"diffusers>=0.30.3\" \"gradio>=4.19\" \"typing_extensions>=4.9\" \"tqdm\"\n",
"if platform.system() == \"Darwin\":\n",
" %pip install -q \"numpy<2.0.0\"\n",
Expand Down
19 changes: 10 additions & 9 deletions notebooks/whisper-asr-genai/whisper-asr-genai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@
"\n",
"\n",
"%pip install -q \"torch>=2.3\" \"torchvision>=0.18.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n",
"%pip install -q -U \"transformers>=4.45\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q \"git+https://github.com/huggingface/optimum-intel.git\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install --pre -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n",
"%pip install -q datasets \"gradio>=4.0\" \"soundfile>=0.12\" \"librosa\" \"python-ffmpeg<=1.0.16\"\n",
"%pip install -q \"nncf>=2.14.0\" \"jiwer\" \"typing_extensions>=4.9\"\n",
"if platform.system() == \"Darwin\":\n",
Expand Down Expand Up @@ -995,7 +996,7 @@
" encoder_calibration_data = []\n",
" decoder_calibration_data = []\n",
" ov_model.encoder.request = InferRequestWrapper(ov_model.encoder.request, encoder_calibration_data, apply_caching=True)\n",
" ov_model.decoder_with_past.request = InferRequestWrapper(ov_model.decoder_with_past.request,\n",
" ov_model.decoder.request = InferRequestWrapper(ov_model.decoder.request,\n",
" decoder_calibration_data,\n",
" apply_caching=True)\n",
"\n",
Expand All @@ -1012,7 +1013,7 @@
" pipe(sample[\"audio\"], return_timestamps=True)\n",
" finally:\n",
" ov_model.encoder.request = ov_model.encoder.request.request\n",
" ov_model.decoder_with_past.request = ov_model.decoder_with_past.request.request\n",
" ov_model.decoder.request = ov_model.decoder.request.request\n",
"\n",
" return encoder_calibration_data, decoder_calibration_data"
]
Expand Down Expand Up @@ -1070,17 +1071,17 @@
" del encoder_calibration_data\n",
" gc.collect()\n",
"\n",
" print(\"Quantizing decoder with past\")\n",
" quantized_decoder_with_past = nncf.quantize(\n",
" ov_model.decoder_with_past.model,\n",
" print(\"Quantizing decoder\")\n",
" quantized_decoder = nncf.quantize(\n",
" ov_model.decoder.model,\n",
" nncf.Dataset(decoder_calibration_data),\n",
" subset_size=len(decoder_calibration_data),\n",
" model_type=nncf.ModelType.TRANSFORMER,\n",
" # Smooth Quant algorithm reduces activation quantization error; optimal alpha value was obtained through grid search\n",
" advanced_parameters=nncf.AdvancedQuantizationParameters(smooth_quant_alpha=0.96)\n",
" )\n",
" ov.save_model(quantized_decoder_with_past, quantized_model_path / \"openvino_decoder_with_past_model.xml\")\n",
" del quantized_decoder_with_past\n",
" ov.save_model(quantized_decoder, quantized_model_path / \"openvino_decoder_model.xml\")\n",
" del quantized_decoder\n",
" del decoder_calibration_data\n",
" gc.collect()\n",
"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@
"import importlib.util\n",
"\n",
"%pip install -q \"nncf>=2.14.0\"\n",
"%pip install -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n",
"%pip install -q \"python-ffmpeg<=1.0.16\" \"ffmpeg\" \"moviepy\" \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" \"torch>=2.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install --pre -q -U \"openvino>=2024.5.0\" \"openvino-tokenizers>=2024.5.0\" \"openvino-genai>=2024.5.0\"\n",
"%pip install -q -U \"python-ffmpeg<=1.0.16\" \"ffmpeg\" \"moviepy\" \"transformers>=4.45\" \"git+https://github.com/huggingface/optimum-intel.git\" \"torch>=2.1\" --extra-index-url https://download.pytorch.org/whl/cpu\n",
"%pip install -q -U \"yt_dlp>=2024.8.6\" soundfile librosa jiwer packaging\n",
"%pip install -q -U \"gradio>=4.19\" \"typing_extensions>=4.9\"\n",
"\n",
Expand Down Expand Up @@ -744,7 +744,7 @@
" encoder_calibration_data = []\n",
" decoder_calibration_data = []\n",
" ov_model.encoder.request = InferRequestWrapper(ov_model.encoder.request, encoder_calibration_data, apply_caching=True)\n",
" ov_model.decoder_with_past.request = InferRequestWrapper(ov_model.decoder_with_past.request,\n",
" ov_model.decoder.request = InferRequestWrapper(ov_model.decoder.request,\n",
" decoder_calibration_data,\n",
" apply_caching=True)\n",
"\n",
Expand All @@ -761,7 +761,7 @@
" pipe(sample[\"audio\"], generate_kwargs={\"task\": task.value}, return_timestamps=True)\n",
" finally:\n",
" ov_model.encoder.request = ov_model.encoder.request.request\n",
" ov_model.decoder_with_past.request = ov_model.decoder_with_past.request.request\n",
" ov_model.decoder.request = ov_model.decoder.request.request\n",
"\n",
" return encoder_calibration_data, decoder_calibration_data"
]
Expand Down Expand Up @@ -812,17 +812,17 @@
" del encoder_calibration_data\n",
" gc.collect()\n",
"\n",
" print(\"Quantizing decoder with past\")\n",
" quantized_decoder_with_past = nncf.quantize(\n",
" ov_model.decoder_with_past.model,\n",
" print(\"Quantizing decoder\")\n",
" quantized_decoder = nncf.quantize(\n",
" ov_model.decoder.model,\n",
" nncf.Dataset(decoder_calibration_data),\n",
" subset_size=len(decoder_calibration_data),\n",
" model_type=nncf.ModelType.TRANSFORMER,\n",
" # Smooth Quant algorithm reduces activation quantization error; optimal alpha value was obtained through grid search\n",
" advanced_parameters=nncf.AdvancedQuantizationParameters(smooth_quant_alpha=0.96),\n",
" )\n",
" ov.save_model(quantized_decoder_with_past, quantized_model_path / \"openvino_decoder_with_past_model.xml\")\n",
" del quantized_decoder_with_past\n",
" ov.save_model(quantized_decoder, quantized_model_path / \"openvino_decoder_model.xml\")\n",
" del quantized_decoder\n",
" del decoder_calibration_data\n",
" gc.collect()\n",
"\n",
Expand Down

0 comments on commit b15d434

Please sign in to comment.