Debian Codegraph @

tensilelite/Tensile/Utilities/tensile_generator/README.md

raw symbols SCIP
1 ## Tensile Config Generator (Beta)
2
3 The `tensile_config_generator.py` script is a tool designed to generate Tensile configuration files for hipBLASLt. These configuration files are essential for optimizing GEMM (General Matrix Multiplication) operations on AMD GPUs.
4
5 ### Purpose
6
7 The main purpose of this script is to:
8 1. Analyze the hipBLASLt logs for GEMM operations
9 2. Generate optimized Tensile configurations based on the identified GEMM patterns
10 3. Produce YAML files that can be used by hipBLASLt to tune GEMM operations
11
12 ### Usage
13
14 To use the `tensile_config_generator.py` script, follow these steps:
15
16 1. Generate hipBLASLt logs:
17 ```
18 HIPBLASLT_LOG_MASK=32 HIPBLASLT_LOG_FILE=./hipblaslt_%i.log <CMD>
19 ```
20
21 2. Run the script from the command line:
22 ```
23 python ./tensile_config_generator.py [options]
24 ```
25
26 Available options:
27
28 | Option | Description |
29 |--------|-------------|
30 | `-h, --help` | Show this help message and exit |
31 | `--hipblaslt_log HIPBLASLT_LOG` | Path to hipblaslt log file |
32 | `--tensile_config TENSILE_CONFIG` | Path to tensile config file |
33 | `--gpus GPUS` | Number of GPUs for tuning hipblaslt |
34 | `--topk TOPK` | Top k GEMMs for tuning |
35 | `--iters ITERS` | Max tuning iterations |
36 | `--fast BOOL` | If enabled, only tune the matrix instruction with min tile sizes, else, tune full matrix instructions |
37 | `--gridbase_config GRIDBASE_CONFIG` | Path to gridbase config file |
38 | `--full_mfma BOOL` | If enabled, will search for all mfma instructions |
39 | `--full_stage BOOL` | If enabled, will search for all stages instructions |
40 | `--num_stages STAGES` | How many times to divide matrix |
41
42 Equality tuning example:
43 ```
44 python ./tensile_config_generator.py --hipblaslt_log ./hipblaslt_gemm_log_example.txt --tensile_config ./tuning_template.yaml --gpus 4 --iters 100
45 ```
46
47 Gridbase tuning example:
48 ```
49 python ./tensile_config_generator.py --gridbase_config ./gridbase_config_template.yaml --tensile_config ./tuning_template.yaml --gpus 4 --iters 100
50 ```
51
52 3. Install hipBLASLt and Tensile (change the path to the hipBLASLt repo):
53 ```
54 bash ./install.sh -idc -a $(/opt/rocm/llvm/bin/offload-arch) --cpu_ref_lib=lapack
55 ```
56
57 4. Tune GEMM kernels using the generated YAML files:
58 ```
59 HIP_FORCE_DEV_KERNARG=1 ./tensilelite/Tensile/bin/Tensile <generated yaml path> <tune result directory>
60 ```
61
62 5. Merge tune results:
63
64 gfx942:
65
66 ```
67 python3 ./tensilelite/Tensile/Utilities/merge.py --no_eff library/src/amd_detail/rocblaslt/src/Tensile/Logic/asm_full/aquavanjaram/gfx942_{cu count}/{Equality|GridBased}/ <tune result directory>/3_LibraryLogic/ library/src/amd_detail/rocblaslt/src/Tensile/Logic/asm_full/aquavanjaram/gfx942_{cu count}/{Equality|GridBased}/
68 ```
69 gfx90a:
70
71 ```
72 python3 ./tensilelite/Tensile/Utilities/merge.py --no_eff library/src/amd_detail/rocblaslt/src/Tensile/Logic/asm_full/aldebaran/{cu count}/{Equality|GridBased}/ <tune result directory>/3_LibraryLogic/ library/src/amd_detail/rocblaslt/src/Tensile/Logic/asm_full/aldebaran/{cu count}/{Equality|GridBased}/
73 ```
74
75 6. Rebuild hipBLASLt with the merged results:
76 ```
77 bash ./install.sh -idc -a $(/opt/rocm/llvm/bin/offload-arch) --cpu_ref_lib=lapack
78 ```
79
80 For more detailed information on the script's functionality and advanced usage, please refer to the comments within the `tensile_config_generator.py` file.