Skip to content

Feat/tensor transport#73

Open
wyeth93 wants to merge 3 commits into
DeepLink-org:mainfrom
wyeth93:feat/tensor_transport
Open

Feat/tensor transport#73
wyeth93 wants to merge 3 commits into
DeepLink-org:mainfrom
wyeth93:feat/tensor_transport

Conversation

@wyeth93

@wyeth93 wyeth93 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

feat(transport): add TensorMessage fast path

Summary

This PR adds TensorMessage, a transport-oriented message type for moving an
ordered set of CPU tensor buffers together with opaque metadata. It introduces
a direct TCP data path for compatible plain connections while preserving the
existing HTTP/2 packed-message path for TLS and explicitly configured legacy
compatibility modes.

The result is a lower-overhead remote tensor path without changing the existing
Message / RPC API for callers that do not opt in.

What changed

Core transport

  • Add TensorMessage { version, metadata, buffers } and the associated
    encode/decode support.
  • Add a raw TCP framing protocol for compatible plain connections (PTR1).
    A checked-out raw connection carries one request/response pair and is then
    returned to the pool; it is intentionally not multiplexed.
  • Keep the HTTP/2 packed-tensor protocol (PTM1) for TLS and explicit HTTP/2
    compatibility modes.
  • Allow the same listener to accept HTTP/2 and raw tensor connections.
  • Use vectored writes and allocate the final receive buffers directly on the
    receive side; add pooling, size limits, and transport statistics.

Python API and dispatch

  • Export pulsing.TensorMessage and pulsing.tensor_transport_stats() when
    the native binding supports them.
  • Add actor-side receive_tensor dispatch and ActorRef.tell / ActorRef.ask
    support for tensor messages.
  • Reserve receive_tensor from generic RPC dispatch so tensor payloads cannot
    accidentally take the normal message handler path.
  • Keep imports safe for the RustPython binding: Tensor APIs are optional there,
    and attempting to convert a TensorMessage through that binding raises a
    clear unsupported error instead of failing an exhaustive Rust match.

Compatibility selection

Connection / setting Tensor transport path
Plain connection with auto, raw, or unset transport Direct TCP (PTR1)
TLS connection HTTP/2 packed tensor (PTM1)
http2, legacy, or off HTTP/2 packed tensor (PTM1)
Mixed-version deployment Force http2 until all peers support raw transport

There is deliberately no silent fallback from a selected raw path to HTTP/2:
configuration and rollout policy should make the wire protocol unambiguous.

Semantics and limitations

  • Tensor buffers must be CPU-resident and C-contiguous. Callers are responsible
    for staging CUDA tensors to CPU and making non-contiguous tensors contiguous.
  • Pulsing treats metadata as opaque; it does not interpret dtype, shape, stride,
    or schema information.
  • Local delivery can retain a read-only alias to the original buffer. Remote
    raw and HTTP/2 deliveries produce independent, writable receive allocations.
  • The direct TCP path avoids assembling user buffers into one combined payload,
    but it is not network zero-copy: the data still traverses application-to-kernel
    and kernel-to-final-buffer copies.
  • tell acknowledgement means transport enqueue, not handler completion or
    durability. Use ask with an application-level acknowledgement when that
    guarantee is required.
  • This PR does not add GPU-direct transport, CUDA IPC, shared-memory transport,
    capability negotiation, automatic downgrade/retry, checksums, compression,
    encryption, request IDs, or streaming tensor responses.

Versioning and documentation

  • Bump the participating workspace crates to 0.1.3.
  • Update the Python and transport documentation/examples for TensorMessage
    and the transport-mode behavior.

Validation

Validated using /home/guoxu1/transferqueue_2/.venv and Maturin 1.11.5:

maturin develop --release --locked --offline \
  --pip-path /home/guoxu1/transferqueue_2/.venv/bin/pip

pytest tests/python/test_tensor_message.py -v
cargo fmt --all -- --check
cargo clippy --offline --locked --workspace \
  --exclude pulsing-py --exclude pulsing-bench-py --all-targets -- -D warnings
cargo test --offline --locked -p pulsing-rpymod
cargo test --offline --locked --workspace \
  --exclude pulsing-py --exclude pulsing-bench-py --lib --bins --tests --examples

The tensor-specific Python suite passes (12 passed), including raw transport,
HTTP/2 fallback, local lifetime behavior, actor dispatch, and reconnect cases.
The full Python suite also passes on a clean Codex-home configuration; the only
failure observed with a pre-populated local Codex cache is an unrelated existing
Forge plugin-catalog attribute mismatch from main.

wyeth added 3 commits July 16, 2026 15:32
Add direct raw-TCP tensor frames with HTTP/2 compatibility, explicit Python buffer ownership, transport statistics, and actor dispatch support. Include bilingual design documentation, a runnable example, and Rust/Python coverage.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.65285% with 399 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/pulsing-actor/src/transport/http2/server.rs 31.81% 120 Missing ⚠️
crates/pulsing-actor/src/transport/http2/client.rs 9.83% 110 Missing ⚠️
crates/pulsing-actor/src/actor/traits.rs 70.95% 79 Missing ⚠️
crates/pulsing-actor/src/transport/tensor.rs 82.73% 58 Missing ⚠️
crates/pulsing-actor/src/transport/http2/mod.rs 5.00% 19 Missing ⚠️
crates/pulsing-rpymod/src/bindings/message.rs 0.00% 7 Missing ⚠️
crates/pulsing-actor/src/system/handler.rs 0.00% 2 Missing ⚠️
crates/pulsing-actor/src/transport/http2/stream.rs 0.00% 1 Missing ⚠️
crates/pulsing-actor/src/watch.rs 0.00% 1 Missing ⚠️
crates/pulsing-rpymod/src/bindings/codec.rs 0.00% 1 Missing ⚠️
... and 1 more
Files with missing lines Coverage Δ
crates/pulsing-actor/src/system_actor/mod.rs 69.54% <ø> (ø)
python/pulsing/__init__.py 78.02% <100.00%> (+1.01%) ⬆️
python/pulsing/core/__init__.py 76.08% <100.00%> (+2.27%) ⬆️
crates/pulsing-actor/src/transport/http2/stream.rs 80.93% <0.00%> (-0.28%) ⬇️
crates/pulsing-actor/src/watch.rs 92.89% <0.00%> (-0.48%) ⬇️
crates/pulsing-rpymod/src/bindings/codec.rs 0.00% <0.00%> (ø)
python/pulsing/core/remote.py 76.87% <92.85%> (+0.57%) ⬆️
crates/pulsing-actor/src/system/handler.rs 74.92% <0.00%> (-0.48%) ⬇️
crates/pulsing-rpymod/src/bindings/message.rs 0.00% <0.00%> (ø)
crates/pulsing-actor/src/transport/http2/mod.rs 84.58% <5.00%> (-4.10%) ⬇️
... and 4 more

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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