sgl-project/sglang · error · ValueError
Required: indexer, forward_batch, x, q_lora, positions
Error message
Required: indexer, forward_batch, x, q_lora, positions
What it means
DeepSeek DSA sparse retrieval requires five kwargs: indexer, forward_batch, x, q_lora, and positions. Any None among them raises this ValueError, because the DeepSeek indexer call needs the hidden states (x), low-rank query projection (q_lora), and position ids to compute retrieval scores.
Source
Thrown at python/sglang/srt/mem_cache/sparsity/algorithms/deepseek_dsa.py:39
def retrieve_topk(
self,
queries: torch.Tensor,
layer_id: int,
req_pool_indices: torch.Tensor,
sparse_mask: torch.Tensor,
attn_metadata: Optional[Any],
**kwargs,
) -> tuple:
indexer, forward_batch, x, q_lora, positions = (
kwargs.get("indexer"),
kwargs.get("forward_batch"),
kwargs.get("x"),
kwargs.get("q_lora"),
kwargs.get("positions"),
)
if any(v is None for v in [indexer, x, q_lora, positions, forward_batch]):
raise ValueError("Required: indexer, forward_batch, x, q_lora, positions")
return (
indexer(
x=x,
q_lora=q_lora,
positions=positions,
forward_batch=forward_batch,
layer_id=layer_id,
),
None,
)
def initialize_representation_pool(
self,
start_layer: int,
end_layer: int,
token_to_kv_pool,
req_to_token_pool,View on GitHub (pinned to 0132848349)
Solutions
- Supply all five kwargs from the model's forward: retrieve_topk(queries, indexer=self.indexer, x=hidden_states, q_lora=q_lora, positions=positions, forward_batch=forward_batch)
- Ensure the model actually has the DSA indexer components (DeepSeek V3.2 DSA architecture); otherwise pick a different sparse algorithm
- Check integration examples for the DeepSeek DSA path to copy the exact argument wiring
Example fix
# before
out = dsa.retrieve_topk(queries, forward_batch=forward_batch)
# after
out = dsa.retrieve_topk(queries, forward_batch=forward_batch,
indexer=self.indexer, x=hidden_states,
q_lora=q_lora, positions=positions) Defensive patterns
Strategy: validation
Validate before calling
required = {k: kwargs.get(k) for k in ("indexer", "forward_batch", "x", "q_lora", "positions")}
missing = [k for k, v in required.items() if v is None]
assert not missing, f"missing DSA kwargs: {missing}" Prevention
- Wrap DSA retrieval in a helper that always supplies the five kwargs
When it happens
Trigger: Calling retrieve_topk on the DeepSeek DSA algorithm without supplying indexer (the DeepSeek indexer module), x (hidden states), q_lora (LoRA-projected queries), or positions.
Common situations: Wiring the DSA algorithm into a custom model forward where the indexer module or q_lora projection is not plumbed through; using the generic sparse-algorithm API without model-specific arguments for DeepSeek V3.2-style DSA.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- forward_batch with seq_lens is required for TopK retrieval
- bad compress_ratio {compress_ratio}
- DSA indexer weights_proj LoRA is incompatible with piecewise
- DSA indexer only supports CUDA, HIP, and NPU
- Quest query hidden size {hidden} not divisible by head_dim {
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/ba214eb8b466e2f1.
Report an issue: GitHub.