Skip to content

Commit ffcd7ea

Browse files
authored
Pr1 fixes (#6)
* fix Intel_Extension_For_SKLearn_GettingStarted * fix INC-Sample-for-Tensorflow * fixed INC-Quantization-Sample-for-PyTorch * fix IntelTransformers_Quantization * fix IntelTensorFlow_Transformer_AMX_bfloat16_MixedPrecision * fixed IntelTensorFlow_InferenceOptimization * fixed IntelTensorFlow_AMX_BF16_Inference * fixed IntelTensorFlow_AMX_BF16_Training * fix IntelPyTorch_TrainingOptimizations_AMX_BF16 * fix IntelPyTorch_GPU_InferenceOptimization_with_AMP
1 parent 459902a commit ffcd7ea

File tree

39 files changed

+1626
-5946
lines changed

39 files changed

+1626
-5946
lines changed

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_GPU_InferenceOptimization_with_AMP/IntelPyTorch_GPU_InferenceOptimization_with_AMP.ipynb

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
},
297297
{
298298
"cell_type": "markdown",
299-
"id": "0d6d8fb4-983b-417f-88c3-dc2747de3d4a",
299+
"id": "415587fc",
300300
"metadata": {},
301301
"source": [
302302
"### Model Training on CPU(Optional, if device is CPU) "
@@ -305,7 +305,7 @@
305305
{
306306
"cell_type": "code",
307307
"execution_count": null,
308-
"id": "1ff86b79-9bc8-4e6e-8d43-b2cfa1eb500f",
308+
"id": "69093d44",
309309
"metadata": {},
310310
"outputs": [],
311311
"source": [
@@ -518,7 +518,7 @@
518518
},
519519
{
520520
"cell_type": "markdown",
521-
"id": "87063fd1",
521+
"id": "7f5ef9d6",
522522
"metadata": {},
523523
"source": [
524524
"Model Evaluation on CPU(optional, if trained on CPU)"
@@ -527,7 +527,7 @@
527527
{
528528
"cell_type": "code",
529529
"execution_count": null,
530-
"id": "8a59b600",
530+
"id": "c84c5b1e",
531531
"metadata": {},
532532
"outputs": [],
533533
"source": [
@@ -616,25 +616,7 @@
616616
]
617617
}
618618
],
619-
"metadata": {
620-
"language_info": {
621-
"codemirror_mode": {
622-
"name": "ipython",
623-
"version": 3
624-
},
625-
"file_extension": ".py",
626-
"mimetype": "text/x-python",
627-
"name": "python",
628-
"nbconvert_exporter": "python",
629-
"pygments_lexer": "ipython3",
630-
"version": "3.9.15"
631-
},
632-
"vscode": {
633-
"interpreter": {
634-
"hash": "ed6ae0d06e7bec0fef5f1fb38f177ceea45508ce95c68ed2f49461dd6a888a39"
635-
}
636-
}
637-
},
619+
"metadata": {},
638620
"nbformat": 4,
639621
"nbformat_minor": 5
640622
}

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_GPU_InferenceOptimization_with_AMP/pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ authors = [
77
]
88
license = {text = "MIT"}
99
readme = "README.md"
10-
requires-python = ">=3.11"
10+
requires-python = ">=3.11,<3.12"
1111
dependencies = [
1212
"deepspeed==0.15.4",
1313
"intel-extension-for-pytorch==2.5.10",
@@ -25,7 +25,6 @@ dependencies = [
2525

2626
[dependency-groups]
2727
dev = [
28-
"ipykernel>=6.29.5",
2928
"jupyter>=1.1.1",
3029
]
3130

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_GPU_InferenceOptimization_with_AMP/sample.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
"steps": [
1616
"pip install uv==0.6.3",
1717
"uv sync",
18-
"uv run IntelPyTorch_GPU_InferenceOptimization_with_AMP.py"
19-
]
18+
"uv run jupyter nbconvert --ExecutePreprocessor.enabled=True --to notebook IntelPyTorch_GPU_InferenceOptimization_with_AMP.ipynb"
19+
]
2020
}
21-
]
21+
]
2222
},
2323
"expertise": "Code Optimization"
2424
}

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_GPU_InferenceOptimization_with_AMP/uv.lock

Lines changed: 21 additions & 540 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_TrainingOptimizations_AMX_BF16/IntelPyTorch_TrainingOptimizations_AMX_BF16.ipynb

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,7 @@
127127
"id": "2f7486b6",
128128
"metadata": {},
129129
"outputs": [],
130-
"source": [
131-
"os.environ[\"ONEDNN_MAX_CPU_ISA\"] = \"AVX512_CORE_BF16\""
132-
]
130+
"source": []
133131
},
134132
{
135133
"cell_type": "code",
@@ -152,6 +150,13 @@
152150
" training_time: the time in seconds it takes to train the model\n",
153151
" \"\"\"\n",
154152
"\n",
153+
" if amx:\n",
154+
" # Set the environment variable to enable Intel® AMX\n",
155+
" os.environ[\"ONEDNN_MAX_CPU_ISA\"] = \"AVX512_CORE_AMX\"\n",
156+
" else:\n",
157+
" # Set the environment variable to disable Intel® AMX\n",
158+
" os.environ[\"ONEDNN_MAX_CPU_ISA\"] = \"AVX512_CORE_BF16\"\n",
159+
"\n",
155160
" # Initialize the model \n",
156161
" model = torchvision.models.resnet50()\n",
157162
" model = model.to(memory_format=torch.channels_last)\n",
@@ -265,18 +270,7 @@
265270
"outputs": [],
266271
"source": [
267272
"print(\"Training model with BF16 with AVX512\")\n",
268-
"!python pytorch_training_avx512_bf16.py"
269-
]
270-
},
271-
{
272-
"cell_type": "code",
273-
"execution_count": null,
274-
"id": "a9bd6dec",
275-
"metadata": {},
276-
"outputs": [],
277-
"source": [
278-
"# Record the training time for BF16 using AVX512\n",
279-
"bf16_avx512_training_time = None #TODO: enter in training time"
273+
"bf16_avx512_training_time = trainModel(train_loader, amx=False, modelName=\"bf16_withAmx\", dataType=\"bf16\")"
280274
]
281275
},
282276
{
@@ -287,7 +281,7 @@
287281
"outputs": [],
288282
"source": [
289283
"print(\"Training model with BF16 with Intel® AMX\")\n",
290-
"bf16_amx_training_time = trainModel(train_loader, modelName=\"bf16_withAmx\", dataType=\"bf16\")"
284+
"bf16_amx_training_time = trainModel(train_loader, amx=True, modelName=\"bf16_noAmx\", dataType=\"bf16\")"
291285
]
292286
},
293287
{
@@ -389,30 +383,7 @@
389383
]
390384
}
391385
],
392-
"metadata": {
393-
"kernelspec": {
394-
"display_name": "Python 3.8.10 64-bit (microsoft store)",
395-
"language": "python",
396-
"name": "python3"
397-
},
398-
"language_info": {
399-
"codemirror_mode": {
400-
"name": "ipython",
401-
"version": 3
402-
},
403-
"file_extension": ".py",
404-
"mimetype": "text/x-python",
405-
"name": "python",
406-
"nbconvert_exporter": "python",
407-
"pygments_lexer": "ipython3",
408-
"version": "3.8.10"
409-
},
410-
"vscode": {
411-
"interpreter": {
412-
"hash": "ed6ae0d06e7bec0fef5f1fb38f177ceea45508ce95c68ed2f49461dd6a888a39"
413-
}
414-
}
415-
},
386+
"metadata": {},
416387
"nbformat": 4,
417388
"nbformat_minor": 5
418389
}

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_TrainingOptimizations_AMX_BF16/pyproject.toml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,39 @@ authors = [
77
]
88
license = {text = "MIT"}
99
readme = "README.md"
10-
requires-python = ">=3.11"
10+
requires-python = ">=3.11,<3.12"
1111
dependencies = [
1212
"deepspeed==0.15.4",
1313
"intel-extension-for-pytorch==2.5.0",
14+
"ipykernel>=6.29.5",
1415
"ipywidgets>=8.1.5",
1516
"jupyter>=1.1.1",
1617
"matplotlib>=3.10.1",
1718
"neural-compressor==3.1.1",
1819
"numpy==1.26.4",
19-
"oneccl-bind-pt==2.5.0",
2020
"onnxruntime==1.19.2",
2121
"py-cpuinfo>=9.0.0",
2222
"setuptools>=75.8.2",
2323
"torch==2.5.0",
2424
"torchaudio==2.5.0",
25-
"torchvision==0.20.0",
25+
"torchvision>=0.20.0",
2626
"transformers>=4.49.0",
2727
]
2828

2929
[tool.uv.sources]
30-
oneccl-bind-pt = { index = "intel" }
30+
torch = { index = "pytorch" }
31+
torchvision = { index = "pytorch" }
32+
33+
[[tool.uv.index]]
34+
name = "pytorch"
35+
# Required URL for the index.
36+
url = "https://download.pytorch.org/whl/cpu"
37+
explicit = true
3138

3239
[[tool.uv.index]]
33-
name = "intel"
34-
url = "https://pytorch-extension.intel.com/release-whl/stable/cpu/cn/"
40+
url = "https://software.repos.intel.com/python/pypi"
3541

3642
[dependency-groups]
3743
dev = [
38-
"ipykernel>=6.29.5",
44+
"jupyter>=1.1.1",
3945
]

AI-and-Analytics/Features-and-Functionality/IntelPyTorch_TrainingOptimizations_AMX_BF16/sample.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@
1414
"id": "intel amx bf16 training",
1515
"steps": [
1616
"pip install uv==0.6.3",
17-
"uv venv",
1817
"uv sync",
19-
"uv run python -m ipykernel install --user --name=torch_trainOpt_AMX_BF16",
20-
"uv run python pytorch_training_avx512_bf16.py",
21-
"uv run python pytorch_training_amx_bf16.py",
22-
"uv run jupyter nbconvert --ExecutePreprocessor.enabled=True --ExecutePreprocessor.kernel_name=torch_trainOpt_AMX_BF16 --to notebook IntelPyTorch_TrainingOptimizations_AMX_BF16.ipynb"
18+
"uv run jupyter nbconvert --ExecutePreprocessor.enabled=True --to notebook IntelPyTorch_TrainingOptimizations_AMX_BF16.ipynb"
2319
]
2420
}
2521
]

0 commit comments

Comments
 (0)