Skip to content

testing/bench.py: make_param_key does not handle torch.dtype consistently with make_param_id #8

Description

@pandacooming

Problem

In tile_kernels/testing/bench.py, make_param_key() and make_param_id() format benchmark parameter dicts differently when a value is a torch.dtype.

make_param_id() — correctly uses _format_value():

def make_param_id(params: dict) -> str:
    parts = []
    for key in params:
        value = params[key]
        parts.append(f'{key}={_format_value(value)}')  # dtype → 'fp16' ✅
    return '-'.join(parts) if parts else 'default'

make_param_key() — does NOT use _format_value():

def make_param_key(params: dict) -> str:
    param_str = ','.join(
        f'{_SHORT_NAME.get(k, k)}={format(v, f">{_WIDTH.get(k)}") if k in _WIDTH else v}'
        for k, v in params.items() if v != None
    )
    # dtype falls through: v is torch.float16 → str(v) = 'torch.float16' (ugly)
Function Input {'dtype': torch.float16} Output
make_param_id dtype=fp16
make_param_key dtype=torch.float16

Expected Fix

Apply _format_value(v) to each value in make_param_key(), consistent with make_param_id(). This also ensures any future types added to _format_value (like dict) are handled uniformly in both functions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions