Skip to content

[KernelBench] Add XeGPU support in kernel bench tool - #209

Merged
tkarna merged 7 commits into
llvm:mainfrom
tkarna:kb-xegpu-target
Jul 2, 2026
Merged

[KernelBench] Add XeGPU support in kernel bench tool#209
tkarna merged 7 commits into
llvm:mainfrom
tkarna:kb-xegpu-target

Conversation

@tkarna

@tkarna tkarna commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
  • Adds a simplified xegpu matmul schedule that takes tile size parameters as kwargs. This is easier to hook up with the yaml desciptors.
  • Adds xegpu target support to kernel-bench tool. Currently enabled only in the torch.compile code path.
  • test_kernel_bench.py example:
    • Add --pipeline arg to optionally override the schedule yaml file look up.
    • Adds schedules/xegpu/matmul/bf16.yaml example schedule for a ~4k matmul. Compatible with the existing schedule lookup scheme.

Examples (executes, verifies, okayish performance):

python test-kernel-bench.py --kernel level1/1_ --dtype bf16 --target xegpu --torch-compile --benchmark --nruns 500 --nwarmup 500
python test-kernel-bench.py --kernel level1/2_ --dtype bf16 --target xegpu --torch-compile --benchmark --nruns 500 --nwarmup 500

@tkarna
tkarna requested review from adam-smnk and rengolin July 1, 2026 09:22
@tkarna

tkarna commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Possible improvements:

  1. Generalize benchmark yaml descriptors. CPU and GPU targets might require different metadata (e.g. problem size). Flop count calculation should be symbolic to take into account the used problem size.
  2. Generalize schedule yaml descriptors. The MLP schedule, for example takes parameters as a list of dicts, one for each layer. At the moment we cannot express this. The schedule should be separated from the parameters (e.g. use the same schedule for many benchmarks, just change the params).
  3. Current TargetInfo arch/feature sounds CPU specific, generalize (?).
  4. Support tile size tuning. This is required to get good performance on XeGPU. We need a way to obtain the KB payload IR and run it with the matmul tuner. Either at runtime or as a separate step and (in both cases) cache the params on disk.

@rengolin

rengolin commented Jul 1, 2026

Copy link
Copy Markdown
Member

#207 propagates the target flags, will conflict with this PR

Comment thread tools/kernel-bench Outdated
Comment thread tools/kernel-bench Outdated
Comment thread tools/kernel-bench Outdated
@tkarna
tkarna force-pushed the kb-xegpu-target branch from a07e517 to 02acbe2 Compare July 1, 2026 16:57

@rengolin rengolin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one comment, otherwise, lgtm

Comment thread examples/KernelBench/test-kernel-bench.py Outdated
Comment thread tools/kernel-bench
return (
torch.from_numpy(buf.view(np.uint16)).view(torch.bfloat16)
if buf.dtype == torch.bfloat16
if buf.dtype == ml_dtypes.bfloat16

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be sufficient as the torch.bfloat16 case never matches

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does in #211, but that can be done in that PR, not here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check if both are needed, too many changes recently 😅

@tkarna
tkarna merged commit 7e3f0cc into llvm:main Jul 2, 2026
3 checks passed
@tkarna
tkarna deleted the kb-xegpu-target branch July 2, 2026 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants