skip to content
==> README.md <==
1# @ajax/mesh-infer-wire
2
3The gpt2 service protocol's wire: frames, key=value messages, checksummed KV layers.
4
5The wire of the inference services (programs/gpt2; docs/plan-disagg-inference.md).
6
7Every gpt2 worker listens on TCP; frames are a u32 length (LE, of what follows), a u8 kind, a payload. A request (K_GEN, K_DECODE, K_PREFILL) carries a Msg: `key=value` lines (sorted by key), a blank line, a body. KV travels as K_LAYER frames (layer, rows, a checksum, the bytes); K_FIRST ends a prefill; K_RESULT and K_ERROR answer.
8
9```c
10#include "mesh/infer_wire.h"
11```
12
13## Ported from
14
15[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT): crates/mesh-host/src/infer.rs: `K_*`, `MAX_FRAME`, `REQUEST_WAIT`, `PROGRAM_*`, `write_frame`, `read_frame`, `read_frame_timed`, `Msg` (set, put, get, need, num, encode, decode), `layer_sum`, `layer_frame`, `parse_layer`.
16
17## Tests
18
19- `tests/wire.c`: infer.rs's `messages_and_layers_round_trip` (over a socketpair), and every error text.
20
21## Differences
22
23- A message holding a NUL byte is refused as not UTF-8 (C strings cannot carry it); Rust would accept it. The workers never send one.
24
25## Licence
26
27MIT. See the repository's LICENSE.