Skip to content

Decode prompt token trace payloads#455

Open
SunnySoldier357 wants to merge 6 commits into
mainfrom
sandeep/fir2-1747-remote-rollout-prompt-token-payloads
Open

Decode prompt token trace payloads#455
SunnySoldier357 wants to merge 6 commits into
mainfrom
sandeep/fir2-1747-remote-rollout-prompt-token-payloads

Conversation

@SunnySoldier357

@SunnySoldier357 SunnySoldier357 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • New standalone eval_protocol/tracing/ package for decoding Fireworks tracing-gateway payloads, independent of EvaluationRow/rollout machinery (stdlib + zstandard only). It is the "folder you can point at" for extracting gateway payloads even without using EP for rollouts.
  • PayloadType StrEnum + DecodedPayload + a master decode_payloads(payloads) registry that runs every decoder over a trace's payloads in one call (plus decode_payload() and decode_trace()). Adding a payload type is one decoder + one PAYLOAD_DECODERS entry.
  • Decode pti/v1 as zstd(JSON int array) to match the gateway (fw-ai/fireworks#29923). The lp/v1 and r3/v1 decoders are moved verbatim.
  • Refactor FireworksTracingAdapter to use decode_payloads instead of three copy-pasted decode blocks; execution_metadata.extra keys are unchanged. Removed adapters/{pti,lp,r3}_deserializer.py.
  • Adds tests/tracing/test_registry.py and a package README.md.

Test plan

  • Unit: conda run -n pilot python -m pytest tests/tracing/test_registry.py tests/adapters/test_fireworks_tracing_prompt_token_ids.py tests/adapters/test_fireworks_tracing_logprobs.py tests/adapters/test_lp_deserializer.py tests/adapters/test_r3_deserializer.py (pass; one pre-existing skip that needs the mono serializer).
  • Live E2E against the dev tracing gateway + accounts/pyroworks-dev/deployments/malaysia2-intended-butterfly: scripts/test_remote_rollout_prompt_token_ids.py hydrates assistant_turn_payloads[0].prompt_token_ids with 13 ids. prompt_token_ids and logprobs decoded live through the new registry; router_replay covered by unit tests (deployment has MoE stats disabled).

Requires fw-ai/fireworks#29923 (the gateway must emit pti/v1 as zstd(JSON)); land together.


Note

Medium Risk
Refactors trace payload decoding used by rollouts and eval rows; behavior is intended to be backward-compatible for existing extra keys, but incorrect decoding or merge logic could affect training/eval consumers of logprobs, routing, and prompt token IDs.

Overview
Introduces eval_protocol.tracing, a small stdlib + zstandard package that decodes Fireworks tracing-gateway out-of-band payloads (prompt_token_ids / pti/v1, logprobs / lp/v1, router_replay / r3/v1) via decode_payloads, decode_payload, and decode_trace, with per-payload error isolation and a registry for new types.

FireworksTracingAdapter no longer inlines LP/R3 decode logic; it calls decode_payloads and maps results onto the same execution_metadata.extra keys as before, plus new prompt_token_ids and prompt_token_ids_metadata. LP/R3 parsing moves from adapters/*_deserializer into eval_protocol.tracing (those adapter deserializers are removed).

Rollout path: _merge_payloads_into_longest_row now carries prompt_token_ids (and metadata) into assistant_turn_payloads per turn. Tests and a live E2E script (scripts/test_remote_rollout_prompt_token_ids.py) cover registry behavior and remote rollout hydration. Depends on gateway emitting pti/v1 as zstd(JSON).

Reviewed by Cursor Bugbot for commit 38fe102. Bugbot is set up for automated code reviews on this repo. Configure here.

Hydrate prompt_token_ids from Fireworks tracing payloads so RemoteRolloutProcessor can pass token-native prompt IDs through assistant turn metadata.

Co-authored-by: Cursor <cursoragent@cursor.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@SunnySoldier357 SunnySoldier357 self-assigned this Jun 12, 2026
SunnySoldier357 and others added 5 commits June 15, 2026 17:25
Move the per-payload binary deserializers out of adapters/ into a
dependency-light eval_protocol/tracing package: a PayloadType StrEnum,
DecodedPayload, and a decode_payloads registry (master decode) usable without
EvaluationRow/rollout machinery. Refactor FireworksTracingAdapter to use the
registry instead of three copy-pasted decode blocks, and decode pti/v1 as
zstd(JSON int array) to match the gateway. Adds tests/tracing and a README.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the 4-line narrating comment over the payload-decode block with a single
intent line; the code already shows what it does.

Co-authored-by: Cursor <cursoragent@cursor.com>
Export only PayloadType, DecodedPayload, and decode_payloads/decode_payload/
decode_trace from the package __init__. The per-type decoders and
PAYLOAD_DECODERS are internal building blocks, still reachable via submodules.

Co-authored-by: Cursor <cursoragent@cursor.com>
… module

The shared helper had a single caller (prompt_token_ids); logprobs/router_replay
already inline the same base64+zstd step. Inline it there too for consistency
and remove the dedicated _decompress.py file.

Co-authored-by: Cursor <cursoragent@cursor.com>
Replace the Dict[str, Any] `extras` field (only ever holding logprobs token_ids)
with a typed `token_ids: Optional[List[int]]` field. Callers now get a real type
(dp.token_ids) instead of Any from extras.get(...). Update adapter, tests, README.

Co-authored-by: Cursor <cursoragent@cursor.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.

1 participant