Skip to content

Conversation

@yurekami
Copy link

Summary

This PR adds backwards compatibility for the renamed parameter in get_mla_metadata(), addressing issue #108.

Problem

The parameter name was changed from num_heads_per_head_k to num_q_tokens_per_head_k, breaking existing code that uses the old name.

Solution

Add support for the old parameter name as a deprecated alias:

# Old code still works (with deprecation warning)
get_mla_metadata(seqlens, num_heads_per_head_k=8, num_heads_k=1)

# New recommended usage
get_mla_metadata(seqlens, num_q_tokens_per_head_k=8, num_heads_k=1)

# Positional arguments continue to work
get_mla_metadata(seqlens, 8, 1)

Changes

  • Add num_heads_per_head_k as keyword-only deprecated parameter
  • Emit DeprecationWarning when deprecated name is used
  • Raise clear error if both old and new names are specified
  • Use sentinel value to properly detect unset required parameters
  • Preserve positional argument compatibility

Example Warning

DeprecationWarning: The parameter 'num_heads_per_head_k' is deprecated and will be removed 
in a future version. Please use 'num_q_tokens_per_head_k' instead.

Test plan

  • Positional arguments work: get_mla_metadata(seqlens, 8, 1)
  • New keyword works: get_mla_metadata(seqlens, num_q_tokens_per_head_k=8, num_heads_k=1)
  • Old keyword works with warning: get_mla_metadata(seqlens, num_heads_per_head_k=8, num_heads_k=1)
  • Error on conflicting names

Fixes #108

🤖 Generated with Claude Code

Add support for the old parameter name `num_heads_per_head_k` as a
deprecated alias for `num_q_tokens_per_head_k` in `get_mla_metadata()`.

This maintains backwards compatibility for existing code that uses the
old parameter name, while emitting a deprecation warning to encourage
migration to the new name.

Changes:
- Add `num_heads_per_head_k` as keyword-only deprecated parameter
- Emit DeprecationWarning when deprecated name is used
- Raise clear error if both old and new names are specified
- Use sentinel value to properly detect unset required parameters
- Preserve positional argument compatibility

Fixes deepseek-ai#108

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

metadata api compatibility issue

1 participant