Skip to content

Decode prompt token trace payloads#455

Merged
SunnySoldier357 merged 7 commits into
mainfrom
sandeep/fir2-1747-remote-rollout-prompt-token-payloads
Jun 19, 2026
Merged

Decode prompt token trace payloads#455
SunnySoldier357 merged 7 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
Touches the trace-to-EvaluationRow payload path used by remote rollouts; behavior should match prior LP/R3 keys but prompt_token_ids depends on the gateway emitting pti/v1 (coordinated land).

Overview
Introduces eval_protocol.tracing, a small standalone package with decode_payloads / decode_trace, PayloadType, and per-type decoders for prompt token IDs (pti/v1 as zstd-compressed JSON), logprobs (lp/v1), and router replay (r3/v1). LP/R3 logic moves out of the adapters; old lp_deserializer and r3_deserializer modules remain as deprecation shims that re-export the new modules.

FireworksTracingAdapter trace conversion now calls decode_payloads once instead of inline R3/LP blocks, and maps results onto the same execution_metadata.extra keys as before, plus prompt_token_ids and prompt_token_ids_metadata. tracing_utils._merge_payloads_into_longest_row carries prompt_token_ids into assistant_turn_payloads for multi-turn rollouts.

Adds package README, registry/unit tests, adapter tests for PTI, shim tests, and an optional E2E script for RemoteRolloutProcessor hydration of prompt token IDs.

Reviewed by Cursor Bugbot for commit 68a32dd. 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>
@xiaoyifan

Copy link
Copy Markdown
Collaborator

One compat concern: eval_protocol.adapters.lp_deserializer / r3_deserializer were public importable modules, so deleting them can break users. Can we keep thin re-export shims at the old paths, maybe with a deprecation note?

Re-export the moved tracing decoders from their old adapter paths with a
DeprecationWarning so existing imports keep working after the tracing refactor.

Co-authored-by: Cursor <cursoragent@cursor.com>
@SunnySoldier357 SunnySoldier357 merged commit 08e9b85 into main Jun 19, 2026
17 checks passed
@SunnySoldier357 SunnySoldier357 deleted the sandeep/fir2-1747-remote-rollout-prompt-token-payloads branch June 19, 2026 20:02
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.

2 participants