deepseek-ai / deepseek-ai/TileKernels

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

Open
#8 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.8k
Forks
162
PR merge metrics
No merged PRs in 30d

Description

## 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()`:
```python
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()`:
```python
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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.