sequence_ai.network is the connection between a robot and the GPU its policy runs on. On the robot, connect()
applies the client-side components to one connection. On the server, one_write and ping wrap a uvicorn or a WebSocket server. sequence_ai.engine
is the inference layer on the GPU: seq serve serves a policy with the server's side of both layers on, optimize
shortens one inference with the speed-ups that keep its outputs exactly the same, and share a GPU among robots, and runs one process per GPU. measures a link before anything is added to it.
batcher
slack
replicas
bench/
Install
pip install sequence-ai
The same package goes on the GPU and on the robot: Python 3.10 or later, on Linux or macOS (a robot can connect() from
3.9). The speed-ups use your model's own torch (2.4 or later) or JAX.
Quick start
On the GPU, save this as policy.py in a folder of its own:
import numpy as np
import seq
@seq.policy(hz=15, action_chunk_valid_len=8, action_chunk_replan_at=5)
class QuickstartPolicy_user:
@seq.sample
def sample_user(self):
observation_user = {"image": np.zeros((224, 224, 3), dtype=np.uint8), "state": np.zeros(7, dtype=np.float32)}
return [("observe", observation_user), ("act",)] * 3 # an observation, then an act, three times
@seq.infer
def infer_user(self, observation_user):
frame_user = observation_user["image"] # your model here: the next 10 steps, 7 joints each
return {"actions": np.full((10, 7), float(frame_user.mean()), dtype=np.float32)}
Then serve it from that folder:
seq serve
serving quickstart-policy-user on port 8000, each robot held and seated by its time at 15 Hz: a robot connects with sequence_ai.connect("http://<this machine>:8000")
On the robot:
import numpy as np
import sequence_ai
with sequence_ai.connect("http://127.0.0.1:8000") as policy_user: # your GPU's address
policy_user.wait_until_ready() # once, before the robot moves
frame_user = np.zeros((224, 224, 3), dtype=np.uint8) # your camera's frame, streamed as video
policy_user.observe({"image": sequence_ai.Video(frame_user), "state": np.zeros(7, dtype=np.float32)})
print(policy_user.act()["actions"].shape) # (10, 7)
The robot plays 15 steps a second (hz), uses the first 8 steps of each chunk (action_chunk_valid_len), and asks for
the next chunk at step 5 (action_chunk_replan_at). Quickstart has the whole loop. Names ending in
_user are yours to change.
An official template: seq init pi05-libero my_pi05_user, then seq serve in that folder
(how).
Both halves on one machine: in a clone of this repository, seq serve examples/quickstart_policy & python examples/quickstart_robot.py.
A server you already run: its parts, one file each.
A robot policy built on a vision-language-action (VLA) model runs each inference on a GPU, and a robot without a
suitable GPU on board sends its observations over a WAN to a remote one. Each layer of that path has its own problem.
The model is most of the latency. Across thirteen model and network configurations, the model is 68 to 96% of a
request's latency. The time of one inference is therefore the main lever, and optimize shortens it without changing
the model's output.
One robot leaves its GPU mostly idle. One robot keeps a GPU busy 21 to 55% of the time, so several robots can share
one, provided that no robot's action chunk runs out while its request waits. batcher batches the requests that are
waiting, slack computes how long each may wait and how many robots a replica can serve, and replicas runs one
replica per GPU.
A robot pauses, and Linux restarts its connection. A robot executes a chunk between requests, and Linux restarts a
TCP connection's congestion window after an idle period. The upload after a pause then takes one extra round trip, at
every RTT measured from 12 ms up but the longest. window, ping and connect keep the window open.
A request carries more round trips and bytes than it needs. A response split across writes can wait a round trip
behind a tunnel, and a camera frame is 50 to 100 KB. one_write sends each response in one write, connect() sends each
camera as video and compresses a large array only when that shortens the upload, and frames resizes a frame before it
is sent.
GPUs are in short supply. Few are near any given robot, and every millisecond of round-trip time comes out of the
slack an action chunk leaves. Getting a GPU near the robot is the routing layer, which is outside this package.
Serves a @seq.policy class to robots elsewhere: on a thread of its own, pings answered at once, a warm-up on its @seq.sample, pictures and compressed arrays restored, a @seq.concurrent policy's acts in batches.
Makes a policy faster on its GPU: each speed-up is kept only when its outputs on your observations stay exactly the same and acts are at least 10% faster. seq serve runs it on the @seq.sample episode. The speed-ups that change the outputs run with the difference you accept.
Reads a model's weights onto the GPU from one contiguous file in parallel reads, through the page cache where memory holds it: in about 60% of the time of a checkpoint read tensor by tensor from a cold disk, every tensor the bytes it was packed with.
Schedules by the slack an action chunk leaves: how many robots a replica can serve, each by its own round-trip time (RTT), how long a request may wait for a batch, and which requests are dispatched first.
a few calls in your server's loop
nothing
from sequence_ai.engine import optimize, slack
from sequence_ai.engine.batcher import Batcher
from sequence_ai.engine.replicas import ReplicaPool
optimize(model_user, examples_user) # 32 or more of your robot's observations
batcher_user = Batcher(model_on_a_list_user, sizes=[1, 2, 4, 8], wait_ms=2.0)
pool_user = ReplicaPool(load_user, replicas=2, devices=[0, 1]) # one replica per GPU
table_user = slack.measure(forward_of_user, sizes=[1, 2, 4]) # forward_of_user(n): one forward pass of n requests
play_user = slack.playback(hz=20, valid_len=15, replan_at=8) # 15 valid steps, the next requested at the 8th
seating_user = slack.Seating(table_user, play_user["buffer_s"] * 1000, sizes=[1, 2, 4],
cycle_ms=(play_user["play_s"] - play_user["buffer_s"]) * 1000)
seats_user, over_user = seating_user.seat([("near-1", 30.0), ("near-2", 30.0), ("near-3", 30.0), ("near-4", 30.0),
("far", 60.0)]) # (robot, its RTT in ms)
optimize tries cuda_graphs on every module that repeats and whole_graph on a run's whole call, keeps
each where the outputs stay exactly the same and acts get faster, and reports why each is on or off.
torch_compile, fused_kernels, tensorrt and precision change the outputs and need tolerance=.
How do I make a policy faster without changing its outputs, and what does each switch change?
Its graphs speed up PyTorch policies whose time goes to launching kernels. XLA already compiles each jitted
function of a JAX policy such as π0.5 whole and puts most of its work in command buffers, so on a JAX policy they are
tried only when you turn them on.
cuda_graphs replays each module called many times per run with the same shapes from CUDA graphs of its own eager
kernels, and checks each new shape against eager mode byte for byte. A shape whose capture fails or differs runs in eager mode from then on. The module stays the same
object of the same class, with its weights, state_dict and hooks unchanged.
How do I make a PyTorch robot policy faster without changing its outputs?
batcher dispatches a batch as soon as it is full, or wait_ms after its first call while the model is free.
While the model is busy, waiting calls accumulate and are dispatched together. Only the listed sizes are used, and a
batch in which the model raised is re-run call by call.
How many robots can one GPU serve?
replicas runs each replica in its own process on its own GPU, so a forward pass never blocks the server's
event loop. ReplicaError is the model's own error, and the replica takes the next call. ReplicaDied is a process
that has exited, and it is replaced.
Should I run two replicas of a policy on one GPU?
slack computes a replica's capacity from the playback time an action chunk leaves when its robot requests
the next one, each robot by its own RTT, and tells a server how long the open batch may wait.
slack: scheduling by the slack an action chunk leaves
sequence_ai.connect(url): the same policy a deployed one's name gives, on the robot's stream to your own server: each observation as it is made, a sequence_ai.Video item as video, each act after them.
connect(url, lines=["eth0", "wwan0"]): the robot's stream over each of its uplinks, each line bound to its own network interface, every observation and act on every line and the first answer used.
seq check <url>, or a deployment's name on GS's platform (python -m sequence_ai.check where seq does not run): which defaults are on between a robot and its server, and what the server is.
sequence_ai.chat() and Conversation (an agent's history and its tool calls) take server="openrouter" with your
own OpenRouter key, or the address of a server of your own with the OpenAI chat completions API:
result_user = sequence_ai.chat("qwen/qwen3-next-80b-a3b-instruct", [{"role": "user", "content": "Plan the next step."}],
server="openrouter") # your key in OPENROUTER_API_KEY
Across thirteen model and network configurations, the time a request spends outside the model is 4 to 32% of its
latency. A remote GPU is therefore close to an on-board GPU of the same type, and inference time is the main lever.
Inference layer:
Component
Result
Measured on
cuda_graphs
1.54× faster (224 → 146 ms), exactly the same outputs
GR00T N1.7's diffusion transformer, one L4, 2026-11-01
cuda_graphs against torch.compile
1.54×, against 1.45× with different outputs (inductor) and 1.00× (cudagraphs)
the same model and GPU
cuda_graphs
6.7× faster (16.1 → 2.4 ms), byte for byte
a small model of many small kernels, one T4
Batching
up to 1.78× the requests per second (5.99 → 10.66)
π0.5, one L4, batch 16
slack
94.1% of responses in time, against 85.7% with all robots on one replica
four robots, a model paced like a 15 Hz policy
Network layer:
Component
Result
Measured on
window, ping
an upload after a pause in 1.0 round trips, not 2.0
a 24 KB upload, every RTT measured from 12 ms up but the longest
window: BBR
no extra round trip after a pause, also with 1% loss
a 24 KB upload, RTT about 21 ms
ping, the server's
1.1 to 1.25 round trips, not 3.0
100 KB to 1 MB after 500 ms of silence
window.Warm, the robot's ping
an upload arrived in under 1 ms, not in over a round trip
162 KB uploads 3 s apart, a long RTT
one_write
a response in about one round trip, not two
a GET through a tunnel
sequence_ai.Video
about 2.5 KB a frame, not 921,600 bytes as an array
a 640×480 camera, a textured background and three moving discs
Measurements lists the network layer's commands, and bench/ measures your own link.
Repository layout
sequence_ai/
engine/ inference layer: serve · optimize · load · cuda_graphs · batcher · replicas · slack
network/ network layer
client: connect · window · frames · wifi_power
server: one_write · ping · tcp_link
both: msgpack_io · latency_stats
chat/ chat() and Conversation: on General Sequences, or at a server of your own (server=)
check.py python -m sequence_ai.check: which defaults are on between a robot and its server
seq/ seq init, seq serve and seq weights get, and the decorators a policy is written with
bench/ measures a link: a TCP client and server, WebSocket, Zenoh
examples/ the quick starts, and one runnable file per component
docs/ one page per question, the measurements, the FAQ
tests/ the components' tests: Python 3.9 to 3.12, on a machine with no GPU
tools/ writes llms-full.txt
llms.txt is a map of the repository for a coding assistant, and llms-full.txt is
this README and every page of docs/ in one file.
A note on the numbers
Every number in this README is given with the model, the GPU or the link it was measured on, and
Measurements lists the command behind each of the network layer's. What a network component saves depends on the
link, so bench/ measures yours before you add anything. Each module's docstring states what the component
does in one sentence, why, and what was measured.
The tests are the components', and run on Python 3.9 to 3.12 on a machine with no GPU. Each release is published here
from General Sequences' own repository: CONTRIBUTING.md has what that means for a pull request.
Apache-2.0. Copyright 2026 General Sequences Company. Parts of five components and one example are adapted from three other
projects: THIRD_PARTY_NOTICES.md.
Alternatives
Use instead of sequence-ai: tools that do the same job, closest first.