Skip to content

Commit 4736efd

Browse files
authored
Merge branch 'main' into overlap_o
2 parents 1bcf71e + eb88a1b commit 4736efd

2 files changed

Lines changed: 48 additions & 15 deletions

File tree

python/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,28 @@ If these environment variables are not set, the installation process will infer
124124
* `CUTLASS_PATH`: either one directory level above the current directory (i.e., `$(pwd)/..`) if installed locally or in the `source` directory of the location in which `cutlass_library` was installed
125125
* `ONEAPI_ROOT`: the default Intel oneAPI installation path
126126

127+
#### Performance related environment variables
128+
129+
For improving performance on Intel PVC/BMG you could try the following:
130+
131+
* `export IGC_ExtraOCLOptions="-cl-intel-256-GRF-per-thread"`
132+
133+
Please refer to [Building with Sycl Support](../media/docs/cpp/build/building_with_sycl_support.md#building-with-sycl-for-intel-gpu-support) for the complete environment setup.
134+
135+
* `SYCL_TLA_ADDITIONAL_TILE_SHAPES` : Path to JSON file containing workgroup and subgroup tile sizes meant for Intel Xe architecture. Expected format s a list of dictionaries like [{"wg": [256, 256, 32], "sg": [8,4,1]}, ...]. Here `wg` refers to the workgroup tile shape and `sg` refers to the subgroup tile layout. This is enabled only for BF16/FP16 kernels.
136+
137+
Sample JSON file that may be used for adding tile shapes.
138+
139+
> Note: This is purely an illustrative example that has NOT been evaluated for performance.
140+
141+
```
142+
[{"wg":[512, 256, 32],"sg":[8,4,1]},
143+
{"wg":[256, 128, 16],"sg":[8,4,1]}]
144+
```
145+
> Note: This feature is meant for advanced users and should be used only if the existing tile shapes don't match desired performance. We recommend you first validate and benchmark any custom tile shapes with SYCL-TLA GEMM examples which can be found [here](../examples/).
146+
Please note additional tile shapes also increase the torch inductor's autotune benchmarking duration.
147+
148+
127149
#### Installation
128150

129151
Stable releases of the SYCL*TLA Python interface are available via the `sycl-tla` PyPI package.

python/cutlass_library/generator.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import sys
4545
import copy
4646
from typing import Any, Dict, Optional, Sequence, Tuple
47+
import json
4748

4849
_LOGGER = logging.getLogger(__name__)
4950

@@ -200,12 +201,10 @@ def CreateGemmUniversal3xOperator(
200201

201202
operations = []
202203

203-
# by default, only generate the largest tile and largest alignment
204-
# but generate all tiles when --kernels=all is specified
204+
# generate all tiles when --kernels=all is specified
205205
if manifest.kernel_filter == '' or manifest.kernel_filter == 'all':
206206
if len(tile_descriptions) == 0:
207207
return operations
208-
tile_descriptions = [tile_descriptions[0]]
209208

210209
combinations = product(layouts, tile_descriptions, data_types, complex_transforms, schedules, tile_schedulers)
211210
for layout, tile_description, data_type, complex_transform, schedules, tile_scheduler in combinations:
@@ -10901,21 +10900,33 @@ def GenerateXe_TensorOp_16b_DPAS_gemm(manifest, cuda_version, min_cc=20):
1090110900
MathOperation.multiply_add)
1090210901
]
1090310902

10903+
default_tiles_wg_sg = [
10904+
([256, 256, 32],[8,4,1]),
10905+
([128, 256, 32],[4,8,1]),
10906+
([256, 128, 32],[8,4,1]),
10907+
([128, 128, 32],[4,4,1]),
10908+
([64, 128, 32],[2,4,1]),
10909+
]
10910+
1090410911
max_cc = min_cc
1090510912

10913+
# Expecting JSON of format i.e list of dictionaries [{"wg": [256, 256, 32], "sg": [8,4,1]}, ...]
10914+
custom_tile_shapes = []
10915+
if os.getenv("SYCL_TLA_ADDITIONAL_TILE_SHAPES"):
10916+
custom_json = os.getenv("SYCL_TLA_ADDITIONAL_TILE_SHAPES")
10917+
with open(custom_json, "r") as f:
10918+
try:
10919+
custom_tile_shapes = json.load(f)
10920+
except json.JSONDecodeError:
10921+
raise ValueError(f"Error decoding JSON : {custom_json}")
10922+
for tile in custom_tile_shapes:
10923+
default_tiles_wg_sg.append((tile["wg"],tile["sg"]))
10924+
10925+
tile_descriptions=[]
1090610926
for math_inst in math_instructions:
10907-
tile_descriptions = [
10908-
TileDescription([256, 256, 32],
10909-
0, [8, 4, 1], math_inst, min_cc, max_cc, [1, 1, 1]),
10910-
TileDescription([128, 256, 32],
10911-
0, [4, 8, 1], math_inst, min_cc, max_cc, [1, 1, 1]),
10912-
TileDescription([256, 128, 32],
10913-
0, [8, 4, 1], math_inst, min_cc, max_cc, [1, 1, 1]),
10914-
TileDescription([128, 128, 32],
10915-
0, [4, 4, 1], math_inst, min_cc, max_cc, [1, 1, 1]),
10916-
TileDescription([64, 128, 32],
10917-
0, [2, 4, 1], math_inst, min_cc, max_cc, [1, 1, 1]),
10918-
]
10927+
for wg_tile,sg_tile in default_tiles_wg_sg:
10928+
tile_descriptions.append(TileDescription(wg_tile,
10929+
0, sg_tile, math_inst, min_cc, max_cc, [1, 1, 1]))
1091910930

1092010931
# Generate kernels for different output (D) types
1092110932
# Default: accumulator type (FP32 for mixed precision, same as input for native precision)

0 commit comments

Comments
 (0)