-
Notifications
You must be signed in to change notification settings - Fork 791
[Benchmarks] Metadata generator #20294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
43b0b80
[Benchmarks] Metadata generator
PatKamin ff00adc
Apply lslusarczyk's comments
PatKamin 988cb08
Update missing returned object info in docstring
PatKamin e315350
Be explicit about explicit_group format
PatKamin a918231
Apply linter
PatKamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
# Copyright (C) 2025 Intel Corporation | ||
# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. | ||
# See LICENSE.TXT | ||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
""" | ||
Metadata generator for Compute Benchmarks. | ||
|
||
This module provides centralized metadata generation for Compute Benchmark groups, | ||
ensuring consistency between benchmark group membership and group metadata definitions. | ||
""" | ||
|
||
from collections import namedtuple | ||
from typing import Dict, List | ||
|
||
from utils.result import BenchmarkMetadata | ||
|
||
from .base import Benchmark | ||
|
||
|
||
def string_consts(cls): | ||
"""Decorator to convert string-annotated class attributes to string constants.""" | ||
for key, value in cls.__annotations__.items(): | ||
if value is str: | ||
setattr(cls, key, key) | ||
return cls | ||
|
||
|
||
@string_consts | ||
class Tags: | ||
"""String constants for benchmark tags to prevent typos.""" | ||
|
||
submit: str | ||
micro: str | ||
SYCL: str | ||
UR: str | ||
L0: str | ||
graph: str | ||
memory: str | ||
proxy: str | ||
finalize: str | ||
|
||
|
||
BaseGroupMetadata = namedtuple( | ||
"BaseGroupMetadata", | ||
[ | ||
"description", | ||
"notes", | ||
"unstable", | ||
"tags", | ||
"range_min", | ||
"range_max", | ||
], | ||
defaults=(None, None, None, [], None, None), | ||
) | ||
|
||
class ComputeMetadataGenerator: | ||
""" | ||
Generates metadata for Compute Benchmark groups. | ||
|
||
This class keeps the logic for creating group metadata, ensuring that | ||
all possible benchmark group configurations have corresponding metadata entries. | ||
""" | ||
|
||
def __init__(self): | ||
# Base metadata for core groups | ||
self._base_group_metadata = { | ||
"SubmitKernel": BaseGroupMetadata( | ||
description="Measures CPU time overhead of submitting kernels through different APIs.", | ||
notes=( | ||
"Each layer builds on top of the previous layer, adding functionality and overhead.\n" | ||
"The first layer is the Level Zero API, the second is the Unified Runtime API, and the third is the SYCL API.\n" | ||
"The UR v2 adapter noticeably reduces UR layer overhead, also improving SYCL performance.\n" | ||
"Work is ongoing to reduce the overhead of the SYCL API\n" | ||
), | ||
tags=[Tags.submit, Tags.micro, Tags.SYCL, Tags.UR, Tags.L0], | ||
range_min=0.0, | ||
), | ||
"SinKernelGraph": BaseGroupMetadata( | ||
unstable="This benchmark combines both eager and graph execution, and may not be representative of real use cases.", | ||
tags=[ | ||
Tags.submit, | ||
Tags.memory, | ||
Tags.proxy, | ||
Tags.SYCL, | ||
Tags.UR, | ||
Tags.L0, | ||
Tags.graph, | ||
], | ||
), | ||
"SubmitGraph": BaseGroupMetadata( | ||
tags=[Tags.submit, Tags.micro, Tags.SYCL, Tags.UR, Tags.L0, Tags.graph] | ||
), | ||
"FinalizeGraph": BaseGroupMetadata( | ||
tags=[Tags.finalize, Tags.micro, Tags.SYCL, Tags.graph] | ||
), | ||
} | ||
|
||
def generate_metadata_from_benchmarks( | ||
self, benchmarks: List[Benchmark] | ||
) -> Dict[str, BenchmarkMetadata]: | ||
""" | ||
Generate group metadata based on actual benchmark configurations. | ||
|
||
Args: | ||
benchmarks: List of benchmark instances to analyze | ||
|
||
Returns: | ||
Dictionary mapping group names to their metadata | ||
""" | ||
metadata = {} | ||
# Discover all group names from actual benchmarks | ||
for benchmark in benchmarks: | ||
group_name = benchmark.explicit_group() | ||
if group_name and group_name not in metadata: | ||
metadata[group_name] = self._generate_metadata(group_name) | ||
|
||
return metadata | ||
|
||
def _generate_metadata(self, group_name: str) -> BenchmarkMetadata: | ||
""" | ||
Generate metadata for a specific benchmark group. | ||
Args: | ||
group_name: Name of the benchmark group | ||
""" | ||
base_metadata = self._base_group_metadata.get( | ||
group_name.split()[0], BaseGroupMetadata() | ||
) | ||
lslusarczyk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return BenchmarkMetadata( | ||
type="group", | ||
description=base_metadata.description, | ||
notes=base_metadata.notes, | ||
unstable=base_metadata.unstable, | ||
tags=base_metadata.tags, | ||
range_min=base_metadata.range_min, | ||
range_max=base_metadata.range_max, | ||
explicit_group=group_name, | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.