{"record":{"id":"0d92eb5084471d65","repo":"sgl-project/sglang","slug":"unexpected-arguments-rope-kwargs-and-config","errorCode":null,"errorMessage":"Unexpected arguments: `**rope_kwargs` and `config` are mutually exclusive","messagePattern":"Unexpected arguments: `\\*\\*rope_kwargs` and `config` are mutually exclusive","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/models/mimo_audio.py","lineNumber":34,"sourceCode":"from einops import rearrange\nfrom transformers.activations import ACT2FN\nfrom transformers.configuration_utils import PretrainedConfig\nfrom transformers.modeling_utils import PreTrainedModel\nfrom transformers.models.qwen2.configuration_qwen2 import Qwen2Config\nfrom transformers.models.qwen2.modeling_qwen2 import Qwen2Model\n\nfrom sglang.srt.layers.attention.vision import VisionAttention\nfrom sglang.srt.layers.quantization.base_config import QuantizationConfig\nfrom sglang.srt.runtime_context import get_model\n\nlogger = logging.getLogger(__name__)\n\n\ndef _compute_default_rope_parameters(\n    config=None, device=None, seq_len=None, **rope_kwargs\n):\n    if config is not None and len(rope_kwargs) > 0:\n        raise ValueError(\n            \"Unexpected arguments: `**rope_kwargs` and `config` are mutually exclusive\"\n        )\n    if len(rope_kwargs) > 0:\n        base = rope_kwargs[\"base\"]\n        dim = rope_kwargs[\"dim\"]\n    elif config is not None:\n        base = config.rope_theta\n        partial_rotary_factor = (\n            config.partial_rotary_factor\n            if hasattr(config, \"partial_rotary_factor\")\n            else 1.0\n        )\n        head_dim = getattr(config, \"head_dim\", None)\n        if head_dim is None:\n            head_dim = config.hidden_size // config.num_attention_heads\n            logger.info(\n                \"audio.head_dim not set; defaulting to hidden_size/num_heads = %d\",\n                head_dim,","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/models/mimo_audio.py#L16-L52","documentation":"MiMo audio's rope-parameter helper accepts either a HF-style config object or explicit rope keyword args (base, dim, ...), never both. Passing config together with any rope kwarg raises immediately. This mirrors transformers' _compute_default_rope_parameters signature contract.","triggerScenarios":"Calling _compute_default_rope_parameters(config=cfg, base=10000, dim=64) or similar mixed calls; wrapping the helper and forwarding both *args-derived kwargs and a config.","commonSituations":"Code adapted from transformers rope utilities where callers sometimes pass partial kwargs; refactors that forward **kwargs blindly while also injecting config.","solutions":["Pass only config=..., deriving base/dim from it, and drop the extra kwargs","Or omit config and pass all required rope_kwargs (base, dim, etc.) explicitly","If wrapping the function, strip config from **rope_kwargs before forwarding"],"exampleFix":"// before\n_compute_default_rope_parameters(config=cfg, base=10000, dim=64)\n// after\n_compute_default_rope_parameters(config=cfg)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def call_rope_params(config=None, **kwargs):\n    assert config is None or not kwargs, \"pass config OR rope kwargs, not both\"\n    return _compute_default_rope_parameters(config=config, **kwargs)","tryCatchPattern":null,"preventionTips":["Choose one calling convention per call site","In wrappers, pop 'config' before forwarding **kwargs"],"tags":["mimo-audio","rope","api-misuse","argument-validation"],"backgroundTag":"mutually-exclusive-arguments","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}