You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Advanced Matrix Extensions (AMX), also known as Intel® Advanced Matrix Extensions (Intel® AMX), is an extension to the x86 instruction set architecture (ISA).
8
+
Advanced Matrix Extensions (AMX), also known as Intel® Advanced Matrix Extensions (Intel® AMX), is an x86 extension,
9
+
which introduce two new components: a 2-dimensional register file called 'tiles' and an accelerator of Tile Matrix Multiplication (TMUL) that are able to operate on those tiles.
10
+
AMX is designed to work on matrices to accelerate deep-learning training and inference on the CPU and is ideal for workloads like natural-language processing, recommendation systems and image recognition.
11
+
9
12
Intel advances AI capabilities with 4th Gen Intel® Xeon® Scalable processors and Intel® AMX, delivering 3x to 10x higher inference and training performance versus the previous generation, see `Accelerate AI Workloads with Intel® AMX`_.
10
-
AMX supports two data types, INT8 and BFloat16, compared to AVX512 FP32, it can achieve up to 32x and 16x acceleration, respectively, see figure 6 of `Accelerate AI Workloads with Intel® AMX`_.
13
+
Compared to 3rd Gen Intel Xeon Scalable processors running Intel® Advanced Vector Extensions 512 Neural Network Instructions (Intel® AVX-512 VNNI),
14
+
4th Gen Intel Xeon Scalable processors running Intel AMX can perform 2,048 INT8 operations per cycle, rather than 256 INT8 operations per cycle. They can also perform 1,024 BF16 operations per cycle, as compared to 64 FP32 operations per cycle, see page 4 of `Accelerate AI Workloads with Intel® AMX`_.
11
15
For more detailed information of AMX, see `Intel® AMX Overview`_.
12
16
13
17
@@ -19,7 +23,34 @@ to get higher performance out-of-box on x86 CPUs with AMX support.
19
23
For more detailed information of oneDNN, see `oneDNN`_.
20
24
21
25
The operation is fully handled by oneDNN according to the execution code path generated. I.e. when a supported operation gets executed into oneDNN implementation on a hardware platform with AMX support, AMX instructions will be invoked automatically inside oneDNN.
22
-
Since oneDNN is the default acceleration library for CPU, no manual operations are required to enable the AMX support.
26
+
Since oneDNN is the default acceleration library for PyTorch CPU, no manual operations are required to enable the AMX support.
27
+
28
+
Guidelines of leveraging AMX with workloads
29
+
-------------------------------------------
30
+
31
+
- BFloat16 data type:
32
+
33
+
Using ``torch.cpu.amp`` or ``torch.autocast("cpu")`` would utilize AMX acceleration for supported operators.
34
+
35
+
::
36
+
37
+
model = model.to(memory_format=torch.channels_last)
38
+
with torch.cpu.amp.autocast():
39
+
output = model(input)
40
+
41
+
Note: Use channels last format to get better performance.
42
+
43
+
- quantization:
44
+
45
+
Applying quantization would utilize AMX acceleration for supported operators.
46
+
47
+
- torch.compile:
48
+
49
+
When the generated graph model runs into oneDNN implementations with the supported operators, AMX accelerations will be activated.
50
+
51
+
52
+
CPU operators that can leverage AMX:
53
+
------------------------------------
23
54
24
55
- BF16 CPU ops that can leverage AMX:
25
56
@@ -36,13 +67,9 @@ Since oneDNN is the default acceleration library for CPU, no manual operations a
36
67
``addbmm``,
37
68
``linear``,
38
69
``matmul``,
39
-
``_convolution``
40
70
41
71
- Quantization CPU ops that can leverage AMX:
42
72
43
-
``conv1d``,
44
-
``conv2d``,
45
-
``conv3d``,
46
73
``conv1d``,
47
74
``conv2d``,
48
75
``conv3d``,
@@ -53,34 +80,18 @@ Since oneDNN is the default acceleration library for CPU, no manual operations a
53
80
54
81
Note: For quantized linear, whether to leverage AMX depends on the policy of the quantization backend.
Using ``torch.cpu.amp`` or ``torch.autocast("cpu")`` would utilize AMX acceleration.
62
-
63
-
::
64
-
65
-
model = model.to(memory_format=torch.channels_last)
66
-
with torch.cpu.amp.autocast():
67
-
output = model(input)
68
-
69
-
Note: Use channels last format to get better performance.
70
-
71
-
- quantization:
72
83
73
-
Applying quantization would utilize AMX acceleration.
74
-
75
-
- torch.compile:
76
-
77
-
When the generated graph model runs into oneDNN implementations with the supported operators mentioned in lists above, AMX accelerations will be activated.
78
84
79
85
80
86
Confirm AMX is being utilized
81
87
------------------------------
82
88
83
-
Set environment variable ``export ONEDNN_VERBOSE=1`` to get oneDNN verbose at runtime.
89
+
Set environment variable ``export ONEDNN_VERBOSE=1``, or use ``torch.backends.mkldnn.verbose`` to flexibly enable oneDNN to dump verbose messages.
90
+
91
+
::
92
+
93
+
with torch.backends.mkldnn.verbose(torch.backends.mkldnn.VERBOSE_ON):
0 commit comments