Skip to content
15 changes: 11 additions & 4 deletions renderers/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ async def generate(
Returns a dict with: request_id, prompt_ids, renderer_prompt_ids,
mm_placeholders, completion_ids, completion_logprobs, content,
reasoning_content, tool_calls, finish_reason, routed_experts,
multi_modal_data, prompt_attribution. ``renderer_prompt_ids`` is the
unexpanded logical prompt when ``process_multimodal=False`` and ``None``
otherwise.
sampling_mask, sampling_mask_logprobs, payload, multi_modal_data,
prompt_attribution. ``renderer_prompt_ids`` is the unexpanded logical
prompt when ``process_multimodal=False`` and ``None`` otherwise.

``prompt_attribution`` is the renderer's :class:`RenderedTokens` for
the prompt — either the one this call computed via
Expand Down Expand Up @@ -396,8 +396,11 @@ def _prepare():
routed_experts = choice.get("routed_experts")
# vLLM's native kept-set sampling masks (``--return-sampling-mask``):
# one list of surviving vocab ids per completion token, or (prime-rl's
# server) packed CSR ``{"ids", "counts"}`` base64 int32 arrays.
# server) packed CSR ``{"ids", "counts"}`` base64 int32 arrays. With score
# centering on, prime-rl's server also returns the sampler's renormalized
# logprob of each of those ids (packed float32, parallel to the ids).
sampling_mask = choice.get("sampling_mask")
sampling_mask_logprobs = choice.get("sampling_mask_logprobs")

# /inference/v1/generate returns finish_reason in {"stop","length",...} —
# never "tool_calls" (a chat-completions concept). Promote stop→tool_calls
Expand Down Expand Up @@ -429,6 +432,10 @@ def _prepare():
"reasoning_complete": parsed.reasoning_complete,
"routed_experts": routed_experts,
"sampling_mask": sampling_mask,
"sampling_mask_logprobs": sampling_mask_logprobs,
# By-handle side arrays: segments of a shared payload file the inference
# server wrote instead of returning routed_experts / sampling_mask inline.
"payload": choice.get("payload"),
# The mm sidecar consumed on the request side, surfaced back so
# callers can persist it on the trajectory step for downstream
# multi-turn bridging and training-sample construction.
Expand Down
Loading