Skip to content

fix(testing/bench.py): add dict support to _format_value#7

Open
pandacooming wants to merge 2 commits intodeepseek-ai:mainfrom
pandacooming:fix/format-value-dict-support
Open

fix(testing/bench.py): add dict support to _format_value#7
pandacooming wants to merge 2 commits intodeepseek-ai:mainfrom
pandacooming:fix/format-value-dict-support

Conversation

@pandacooming
Copy link
Copy Markdown

Summary

Add dict handling to _format_value() in tile_kernels/testing/bench.py, formatting dicts as k1=v1,k2=v2 consistent with make_param_key style.

Fixes #6

Changes

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 isinstance(value, dict):
+       return ','.join(f'{k}={_format_value(v)}' for k, v in sorted(value.items()))
    if value is None:
        return 'None'
    return str(value)

Testing

All cases pass:

{'topk': 2, 'hidden': 256} → hidden=256,topk=2  ✅ (sorted)
{'a': 1, 'b': 2}           → a=1,b=2            ✅
{}                          → (empty string)     ✅
{'outer': {'inner': 1}}    → outer=inner=1      ✅ (recursive)
torch.float16               → fp16               ✅ (still works)
(128, 256)                  → 128x256            ✅ (still works)

pandacooming added 2 commits April 24, 2026 00:53
- Add .github/workflows/format.yml: GitHub Actions workflow that runs
  yapf + ruff on every push to main and on every PR.
- Add format.sh: local formatting script (used by CI and for
  contributors to run locally before pushing).

Both files follow the same conventions as deepseek-ai/DeepEP.
Formats dict as k1=v1,k2=v2, consistent with make_param_key style.
Handles nested dicts recursively.

Fixes deepseek-ai#6
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.

testing/bench.py: _format_value lacks dict support

1 participant