Skip to content

policy_client: wire-format codecs (openpi msgpack + lerobot pickle)#251

Open
shantanuparab-tr wants to merge 3 commits into
06-15-policy-client-02-neutral-typesfrom
06-15-policy-client-03-codecs
Open

policy_client: wire-format codecs (openpi msgpack + lerobot pickle)#251
shantanuparab-tr wants to merge 3 commits into
06-15-policy-client-02-neutral-typesfrom
06-15-policy-client-03-codecs

Conversation

@shantanuparab-tr

@shantanuparab-tr shantanuparab-tr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the two wire-format codecs that translate the neutral Observation/ActionChunk to and from each server family's bytes, and introduces the TROSSEN_SDK_ENABLE_POLICY_CLIENT build gate (off by default). No transport or client yet — just the encode/decode primitives, fixture-tested.

Stack: PolicyClient stack, based on #248. Review bottom-up (#250 → here).

Changes

  • In include/trossen_sdk/hw/policy/msgpack_ndarray.{hpp} + src/hw/policy/msgpack_ndarray.cpp: openpi msgpack-numpy ndarray encode/decode.
  • In include/trossen_sdk/hw/policy/lerobot_codec.hpp + src/hw/policy/lerobot_codec.cpp: a pinned, self-contained LeRobot pickle/torch reader/writer (no libtorch dependency) — decodes the server's pickled action chunks and emits the pickled policy-setup/observation payloads.
  • In CMakeLists.txt + cmake/policy_client.cmake: introduce the TROSSEN_SDK_ENABLE_POLICY_CLIENT option (default OFF) and FetchContent of msgpack-cxx; append the codec sources to trossen_sdk behind the gate.
  • In tests/test_msgpack_ndarray.cpp, tests/test_lerobot_codec.cpp, tests/fixtures/lerobot_codec/*, tests/CMakeLists.txt: round-trip + parity tests against pinned fixtures captured from the real LeRobot version (capture_fixtures.py + versions.json document provenance); malformed-input/whitelist-safety cases.

Test Plan

  • Builds cleanly with -DTROSSEN_SDK_ENABLE_POLICY_CLIENT=ON
  • Tests pass — test_msgpack_ndarray, test_lerobot_codec (fixture parity exact)
  • Lint passes (pre-commit run --all-files)
  • Hardware — N/A (pure codecs; exercised end-to-end by policy_client: stationary examples (openpi + lerobot) #255)

Breaking Changes

None. New gated sources; the build gate defaults OFF so existing builds are unaffected.

Related

Based on #248. Stacked on #250; followed by #252#255.

shantanuparab-tr commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch 2 times, most recently from 8960bf7 to ea1db70 Compare June 15, 2026 18:45
@shantanuparab-tr shantanuparab-tr added the enhancement New feature or request label Jun 15, 2026 — with Graphite App
@shantanuparab-tr shantanuparab-tr self-assigned this Jun 15, 2026
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-02-neutral-types branch from 295906a to b7572cd Compare June 16, 2026 21:51
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch from ea1db70 to b334671 Compare June 16, 2026 21:51
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-02-neutral-types branch from b7572cd to 9c329c3 Compare June 16, 2026 21:57
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch from b334671 to 9758bde Compare June 16, 2026 21:58
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-02-neutral-types branch from 9c329c3 to 03a323a Compare July 16, 2026 15:12
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch from 9758bde to 346766b Compare July 16, 2026 15:12
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-02-neutral-types branch from 03a323a to 9d8fa58 Compare July 16, 2026 15:41
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch from 346766b to 909b956 Compare July 16, 2026 15:41
Adds the two codecs that translate the neutral Observation/ActionChunk to and
from each server family's wire bytes: msgpack_ndarray (openpi msgpack-numpy)
and lerobot_codec (pinned LeRobot pickle/torch, fixture-tested). Introduces the
TROSSEN_SDK_ENABLE_POLICY_CLIENT build gate (FetchContent msgpack-cxx).
- The lerobot emit path (encode_observation, encode_policy_setup) shipped
  with no automated test while decode had a byte-exact tripwire, so any
  future edit or numpy pin bump would silently corrupt the wire format.
  Add EmitObservationParity / EmitPolicySetupParity comparing emitter
  output against reviewed goldens (structurally verified against the
  CPython disassembly; emitter omits the memo table by design, so the
  goldens are emitter-produced, not the CPython .pkl) (PR251-F1/F2).
- Guard pack_ndarray against >4 GiB payloads that would truncate the
  msgpack bin32 length prefix (PR251-F7).
- Document that emitted numpy._core.multiarray requires the server run
  numpy >= 2.0 (PR251-F3); correct the emit fidelity comment that wrongly
  claimed byte-identical numpy output (PR251-F5).
Update the codec pin comment and captured codec fixtures to LeRobot v0.6.0
(commit 30da8e68).
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-02-neutral-types branch from 9d8fa58 to b869979 Compare July 17, 2026 14:17
@shantanuparab-tr
shantanuparab-tr force-pushed the 06-15-policy-client-03-codecs branch from 79b4728 to 03e39a7 Compare July 17, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant