Skip to content

Commit

Permalink
align skip gpu for quantization in tests (#2032)
Browse files Browse the repository at this point in the history
  • Loading branch information
eaidova authored May 21, 2024
1 parent 40f393b commit 188f335
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 53 deletions.
18 changes: 15 additions & 3 deletions .ci/patch_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,24 @@ def disable_gradio_debug(nb, notebook_path):
return nb


def disable_skip_ext(nb, notebook_path):
def disable_skip_ext(nb, notebook_path, test_device=""):
found = False

skip_for_device = None if test_device else False
for cell in nb["cells"]:
if test_device is not None and skip_for_device is None:
if (
'skip_for_device = "{}" in device.value'.format(test_device) in cell["source"]
and "to_quantize = widgets.Checkbox(value=not skip_for_device" in cell["source"]
):
skip_for_device = True

if "%%skip" in cell["source"]:
found = True
cell["source"] = re.sub(r"%%skip.*.\n", "\n", cell["source"])
if not skip_for_device:
cell["source"] = re.sub(r"%%skip.*.\n", "\n", cell["source"])
else:
cell["source"] = '"""\n' + cell["source"] + '\n"""'
if found:
print(f"Disabled skip extension mode for {notebook_path}")
return nb
Expand Down Expand Up @@ -139,7 +151,7 @@ def patch_notebooks(notebooks_dir, test_device="", skip_ov_install=False):
if not found:
print(f"No replacements found for {notebookfile}")
disable_gradio_debug(nb, notebookfile)
disable_skip_ext(nb, notebookfile)
disable_skip_ext(nb, notebookfile, args.test_device)
nb_without_out, _ = output_remover.from_notebook_node(nb)
with notebookfile.with_name(f"test_{notebookfile.name}").open("w", encoding="utf-8") as out_file:
out_file.write(nb_without_out)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "ed3140bd-24c7-4eb3-9a1a-2b9ece1e2e76",
"metadata": {},
Expand All @@ -15,6 +16,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "836f7a88-8d7f-43b7-b0c7-394a7483d932",
"metadata": {},
Expand Down Expand Up @@ -43,6 +45,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6e8f0c42-62f4-44f1-90a3-2bf33d797aa3",
"metadata": {},
Expand All @@ -68,6 +71,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "31b4f27a-c164-499f-8cfe-4e94509b5384",
"metadata": {},
Expand Down Expand Up @@ -165,6 +169,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "9c38f8d4-fa96-4ba0-abe0-8f6050bb1c22",
"metadata": {},
Expand All @@ -180,6 +185,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "be642b08-96d3-437d-8057-21f37777a9e6",
"metadata": {},
Expand Down Expand Up @@ -208,6 +214,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "24868d33-c539-454c-ab27-5cbe99091dba",
"metadata": {},
Expand Down Expand Up @@ -247,6 +254,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "a3fbfa19-293c-4a64-9d32-9fa58df2062e",
"metadata": {},
Expand Down Expand Up @@ -300,6 +308,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "1f91cd05-3b5b-46ec-89a9-bdaa711d4665",
"metadata": {},
Expand Down Expand Up @@ -359,6 +368,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "fb1c619c-b134-4a45-bed6-061da6b298a4",
"metadata": {},
Expand Down Expand Up @@ -430,6 +440,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "b8c30389-9cc3-486e-93e8-03474161b8e9",
"metadata": {},
Expand All @@ -439,6 +450,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "113b5a88-8b21-43a8-b453-88065ef06e8b",
"metadata": {},
Expand Down Expand Up @@ -506,6 +518,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "1a05be62-e609-4a9a-9aec-243550d9e523",
"metadata": {},
Expand Down Expand Up @@ -617,6 +630,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6752651b-53a4-4f93-8910-6a2aa02ae69c",
"metadata": {},
Expand Down Expand Up @@ -693,6 +707,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "25e65a716d719fde",
"metadata": {},
Expand Down Expand Up @@ -732,12 +747,8 @@
"source": [
"QUANTIZED_TRANSFORMER_OV_PATH = Path(str(TRANSFORMER_OV_PATH).replace(\".xml\", \"_quantized.xml\"))\n",
"\n",
"to_quantize = widgets.Checkbox(\n",
" value=True,\n",
" description=\"Quantization\",\n",
" disabled=False,\n",
")\n",
"\n",
"skip_for_device = \"GPU\" in device.value\n",
"to_quantize = widgets.Checkbox(value=not skip_for_device, description=\"Quantization\", disabled=skip_for_device)\n",
"to_quantize"
]
},
Expand All @@ -764,6 +775,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "4f354c94da7dd923",
"metadata": {},
Expand Down Expand Up @@ -848,6 +860,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "6b639455e8e4f718",
"metadata": {},
Expand Down Expand Up @@ -910,6 +923,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "e684f5e111282666",
"metadata": {},
Expand Down Expand Up @@ -943,6 +957,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f6c49afdc5f4c94e",
"metadata": {},
Expand Down Expand Up @@ -1024,6 +1039,7 @@
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "281ca3bd-651c-4cc8-bcee-22fa3fbb3636",
"metadata": {},
Expand Down
Loading

0 comments on commit 188f335

Please sign in to comment.