Skip to content

testing/bench.py: _format_value lacks dict support #6

@pandacooming

Description

@pandacooming

Problem

In tile_kernels/testing/bench.py, the _format_value() function handles torch.dtype, tuple, and None, but not dict:

def _format_value(value):
    if isinstance(value, torch.dtype):
        return dtype_to_str(value)
    if isinstance(value, tuple):
        return 'x'.join(str(v) for v in value)
    if value is None:
        return 'None'
    return str(value)  # dict falls through here → ugly {'key': 'val'}

When a dict is passed, it falls through to str(value), producing raw output like {'topk': 2, 'hidden': 256} — inconsistent with the ,-joined k=v style used everywhere else in benchmark output.

Expected Fix

Add dict handling that formats as k1=v1,k2=v2, consistent with make_param_key:

if isinstance(value, dict):
    return ','.join(f'{k}={_format_value(v)}' for k, v in sorted(value.items()))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions