The @seq.policy class
A policy is a class decorated with @seq.policy: the arguments declare what it
needs (image, weights, the rate it plays at), and seq deploy --gpu the card it runs on; the methods mark what runs when. seq init pi05-droid
clones a decorated policy template to repoint at your own checkpoint (toy-policy, the smallest, needs none). Each declaration past those is optional and
unlocks one thing; once robots use the policy, the console says in a figure’s tip (and
seq policy status in a hint: line under it) which one its measurements say is
worth adding next, and an eval says it of what it measured in
seq eval report. In the examples, everything ending in _user is yours, and so are the
strings.
# everything ending in _user is yours import seq @seq.policy( hz=15, # required: the steps a second its answers play at action_chunk_valid_len=15, action_chunk_replan_at=8, # an answer's valid steps; the step its next act goes at image=( seq.Image.debian_slim() # a small Debian 12 base (debian:12-slim) .apt_install("git", "libgl1", "libglib2.0-0") .run_commands("git clone https://github.com/Physical-Intelligence/openpi /opt/openpi") .uv_pip_install("/opt/openpi") # openpi installs from source ), weights=seq.Volume.from_name("my_checkpoint_user"), # your checkpoint: an uploaded volume, hf://, or a template's secrets=[seq.Secret.from_name("hf")], # optional, by name only — see Secrets init={"weights_dir": "{weights}"}, # the constructor's arguments; "{weights}" is where the weights are ) class MyPolicy_user(seq.Policy): def __init__(self, weights_dir): # cold start, once: pull the checkpoint into VRAM self.model_user = ... @seq.infer # per act: its inputs -> what its robot gets, as returned def infer_user(self, obs, *, seed=None): return self.model_user(obs) @seq.on_episode # optional: as each episode begins and as it ends def on_episode_user(self, episode): ... # episode.phase: "start" or "end"; episode.id names it @seq.shutdown # optional: cleanup before the worker stops def shutdown_user(self): ...
Decorator and lifecycle
@seq.policy holds the policy’s own settings (its weights, image, rate and the rest below;
its card and scaling are seq deploy flags) and names no method: each method the platform calls carries its own decorator (the second
table). The decorator arguments:
| argument | what it declares |
|---|---|
gpu | not a @seq.policy argument: a policy’s card is seq deploy --gpu ("A100", "A100-40GB", "H100", "L4" or "RTX-PRO-6000") or "cpu", which its first deploy needs (a later one keeps the card of the version serving); seq gpus lists them with their memory and prices. A benchmark names its card on @seq.benchmark(gpu=...): "cpu" puts its physics on CPU machines, one environment per core; a benchmark that names a card must simulate on it, which registration checks. Any other name is refused at deploy with the list. A deployment runs on the one card it names: a worker’s start waits for it, which can take more than 10 minutes with nothing billed (the platform’s wait, the same for every policy), and never takes another card. --gpu H100:2 asks for two cards per worker, billed for each, at most 8, on one machine (see One machine per worker) |
cpu, memory | not @seq.policy arguments: seq deploy --cpu CORES --memory GIB, a worker’s CPU cores and GiB of memory, each what it requests. Unset, it requests the minimum (0.125 core and 128 MiB) and may use more; a policy that loads a large model should request the memory it needs. A worker asking more than 16 cores or 336 GiB is refused at deploy; your plan caps what all your running workers ask for at once (Starter: 120 cores, 512 GiB), checked as each starts |
image | the container image, declared (see Images) |
weights | an official template’s weights (seq.Weights.template("<template>", version=1)), an hf://org/model[@revision] repo, or a sub-folder of one (hf://org/model@<revision>/<sub/folder>), copied and billed at what it holds, which counts toward your storage limit (at most 10 000 files, a technical limit); or a volume you uploaded (seq.Volume.from_name(...) / vol://name), copied to /data at deploy; or a dict of named parts, each from its own origin. See Volumes and weights |
init | what the worker builds your class with, once at cold start: the constructor’s arguments by name (init={"weights_dir": "{weights}"}), or a list by position. In any string "{weights}" is the directory the declared weights were copied to, "{weights.<name>}" a named part’s; seq.config(path, **keys) is a YAML or JSON file of your project with keys set over it (A class you already have). Without it, the class is built with no arguments, and one whose constructor needs some is refused when you deploy |
timeouts | not a @seq.policy argument: the limits are the platform’s. A worker may take 1800 s to start (building your class, counted from when it begins loading; its wait for a GPU before that is not counted [Which GPU a worker gets]) and one inference 300 s; a version whose check measured a slower load is given three times it (up to 18 000 s), and one whose check measured slower inferences ten times its slowest p95 (up to 3 600 s). A request over its limit answers a timeout while its call runs on: the episode’s next act waits for that call, and one still running at twice the limit ends its copy, a fresh one taking its place. An episode may go 300 s without an act (or three times its robot’s usual time between acts, where that is longer, up to a day) before its place on a replica may go to a new episode (Episodes). A start is billed from the moment its machine starts, however long it takes (What keeping a deployment costs) |
volumes | not a @seq.policy argument: volumes= is refused where it is written, as any unknown argument is; a checkpoint goes in weights= |
name, models | its deployment’s name (seq deploy --name overrides it; the class’s name in lower case with hyphens, MyReacher as my-reacher, when neither is given); and the platform models it calls as it runs, the only ones its robot key may call (Planning). What it takes and returns is its own code’s, and the console draws its icon from the template it came from |
secrets | credentials referenced by name (see Secrets) |
max_gpus | not a @seq.policy argument: seq deploy --max-gpus N, the most GPUs the deployment holds at once, counted in cards, one worker’s cards when unset; seq policy set changes it with no new deploy (see Scaling) |
min_workers, buffer_workers | not @seq.policy arguments: seq deploy --min-workers N and --buffer-workers N, 0 unless set. Workers kept running with no robot connected, and idle workers kept beside the busy ones while robots are connected (a missing one is started at once, and up in about 4 minutes or more): no cold start, billed while they run; with buffer_workers of 1 or more, each robot also holds a connection to a copy with a free seat on another worker, its standby, one already serving robots first, then an idle one (A standby copy). At most 256 kept warm a deployment, never more than its max_gpus, and never more GPUs or machines than your plan may hold |
gpus_per_replica, replica_start | not @seq.policy arguments: seq deploy --gpus-per-replica N --replica-start one_by_one. On a worker of several cards, one copy of the model on each group of N cards (by default one copy sees every card; copies never share a card), started all at once (together, the default) or each after the one before is serving (one_by_one). A copy too large for its card fails the deploy with what it measured |
@seq.concurrent(sizes=[1, 2, 4, 8]), on infer | the batch sizes infer is called with, the ones your model is built for: it takes the acts that run together as one batch, their inputs stacked, and returns one batch, a row an act (collate=False: a list in, a list out). A copy seats as many robots, 64 at most, as the largest size whose batch answers, with its robots’ round trip (a default until measured) and 50 ms to spare, within what its robots leave before their answers run out, the steps from action_chunk_replan_at to action_chunk_valid_len, each size timed on your @seq.sample episode, which it needs; and fewer where that many, run together on a simulated clock, would have an answer late in any of its runs, or batches that fill over 90% of the time between a robot’s asks (see Batching requests). Without it, one robot a copy |
hz, action_chunk_valid_len, action_chunk_replan_at | how its answers play: hz, required, the steps a second they play at; action_chunk_valid_len the steps of one answer that are valid; action_chunk_replan_at the step, counted from when its act is sent, at which its robot asks for the next answer (unset: the last valid step). A worker seats a copy’s robots by them; the two chunk lengths change with seq policy set, no new deploy (below) |
robot | the robot it was made for, named as a benchmark names its robots
(robosuite’s Panda or UR5e, say): a benchmark that takes the robot it is
played with as "{policy.robot}" is built with this one unless the eval picks another (Parameters in an eval); unset, it names none, and such a benchmark
keeps its own default |
max_wait_for_batch | how long, in seconds, a robot waits for an answer from when it sends its act, so that its act can share a batch with other robots’ (unset: a robot waits only while the answer it plays lasts). A worker seats a copy’s robots by it and by their load alone, with no run on the clock; it changes with seq policy set, no new deploy (Waiting for a batch) |
tensors | not a @seq.policy argument: annotate the observation torch.Tensor (def infer(self, obs: torch.Tensor), or dict[str, torch.Tensor], on the @seq.observe method where there is one), and each numpy array in its inputs reaches its code as a torch tensor on its device (float64 as float32, other values as they are) a batch dimension of 1 first (a @seq.concurrent act: none), and the tensors it answers with go back as arrays |
The class is built by its constructor, once, with what init= says; the methods bind to lifecycle
stages, each by its decorator, on a class written for the platform, or on a short subclass of one you have
(A class you already have). Only @seq.infer is required; the rest are opt-in.
Without the decorator, a method named infer is used.
| decorator | when it runs |
|---|---|
__init__, with no decorator | once at cold start: build the model, from the directory the declared weights were copied to when init= hands it "{weights}" (see How it is built and called) |
@seq.sample | returns one episode’s calls, in order, as your robot makes them: a list of 1 to 1024, each ("observe", x) for an observe(x) or ("act",) for an act(). seq deploy plays them on the card and says how long the first act and the ones after took (Your own inputs and outputs). Before a worker serves, it plays your sample episode’s first act on each copy, so a robot’s first act finds the act path warm; the build check times each batch size @seq.concurrent(sizes=[...]) lists, and a worker on another card serves one robot a copy until it has timed them beside its robots; anything else to set up goes in the constructor |
@seq.observe | every observe(): handed what it sent, as it was sent, in the order sent, before the act after it (observe() and act()). One that declares episode is handed its episode’s seq.Episode too. Without one, @seq.infer is handed the latest observe() at each act |
@seq.infer | every act: what to send back, which its robot gets as it is returned. It is handed nothing after an @seq.observe method, or else the latest observe(). One that declares episode is handed its episode’s seq.Episode: id, steps, a state dict the platform keeps for the episode and saves for a standby, and a local dict that never leaves its worker (Episodes) |
@seq.plan(every_s=2.0) | optional: in the background for each robot, its next step, which the act reads from its episode (Planning) |
@seq.on_episode | optional: twice an episode, as it begins on its replica, before its first observe() or act reaches the policy (episode.phase is "start"), and once it is over ("end"), handed its seq.Episode both times: def on_episode(self, episode). At the start it sets up what the episode needs, in episode.state or episode.local; at the end it reads or frees what the policy kept. One that raises as an episode begins fails that episode: every act of it is answered with that error until it ends, and in an eval the episode is an error; one that raises at the end is said in seq policy logs, and the episode ends anyway. When it runs: Episodes. A class that marks @seq.reset is refused at deploy: @seq.on_episode runs as each episode begins |
@seq.shutdown | optional: your cleanup, run on each copy before its worker stops, with 10 s at most, whatever stops the worker: you (seq policy stop, seq policy rm), no robot connected to it for its idle timeout, a new version taking over, its 23 hours served (a fresh worker takes its robots), its monthly budget reached, or your account out of credit. The worker takes no new request from then, each going to another worker. What the hook prints is in seq policy logs, marked (shutdown); a hook that raises says so there, and a copy whose hook runs past its 10 s is ended, with a line saying so |
How it is built and called
Your class and its infer are your code; the platform decides when they run. It puts the weights you
declared in a directory (a copy of your own, or an official template’s read-only copy),
builds your class once with what init= says, "{weights}" being that directory, then
calls infer for every request. Reading the files and building the model are the
constructor’s job.
| when | who | what |
|---|---|---|
seq deploy | you | the decorator’s declaration and the folder you deploy, whole, go to the platform |
| a worker starts | the platform’s code in the worker | imports your file: the decorator registers the class, and the methods marked @seq.infer and the rest are found |
| cold start, once | the worker | MyPolicy_user(weights_dir=…): your class built with init=, weights_dir the directory the declared weights were already copied to |
every observe() | the worker | the @seq.observe method, handed what it sent |
| every act | the worker | infer() after an @seq.observe method, or else infer(inputs), inputs being the latest observe(); in an eval, with seed=… |
"{weights}"is the directoryweights=is copied to before the worker starts, such as/srv/ckpt/my_policy_user: read it from the argument your class is handed, never write the path in. Where it is depends on the machine the worker runs on, and its last part is the policy’s name with each character but a letter, a digit or_made_, those at either end dropped andp_put before one that starts with a digit (my-policy-userloads from…/my_policy_user). Weights in named parts (weights={"base": …, "lora": …}) are each their own instead:init={"base_dir": "{weights.base}", "lora_dir": "{weights.lora}"}.- With no weights declared, nothing is copied, and
"{weights}"ininit=is refused when you deploy. A class that needs no checkpoint takes noinit=and is built with no arguments. - Building it may take up to the platform’s startup limit (1800 s, or more where an earlier version’s check measured a slower load; see the table above).
infergets the robot’s latestobserve(), as it was sent, unless an@seq.observemethod takes them (Your own inputs and outputs).
Your own inputs and outputs
A policy defines its own inputs and outputs, and the platform converts nothing of them but what the policy’s annotations ask for (an observation annotated torch.Tensor, below) and a torch tensor in an answer: it hands
the @seq.observe method what each observe() sent (or, with none, infer
the latest at each act) unchanged, and sends back whatever infer returns. It guarantees three
things and nothing more: an episode’s observes reach the observe method in order before the act after them,
an episode of a class that keeps it on itself stays on one copy of the policy, and the data arrives as it was sent
(observe() and act()). The
format is yours to choose, so write it where callers will look: infer’s docstring and your
README. toy-policy takes {"state": [x], "target": [t]} and returns
{"delta": [dx]}.
- From a robot or a script,
observe()that dict, thenact(), and get the outputs back asinferreturned them: withpolicy = sequence_ai.connect("my_toy_user"), afterpolicy.observe({"state": [0.0], "target": [0.5]})theoutputsofpolicy.act()are{"delta": [0.1]}. An observe function the policy names gets eachobserve()as it was sent, before the act that follows it; a policy with none, liketoy-policy, is handed the episode’s latest one at the act. A template’sclient.pybuilds the dict for you. - Inputs travel as they are: the platform carries them opaquely. Every
observe()goes as msgpack, whatever it holds (a camera’s JPEG, a stack of uint8 frames), by sequence-ai and by an eval alike, andinfergets the bytes as bytes and each array as an array of its own dtype and shape; every act’s answer comes back the same way. A torch tensorinferanswers with, alone or in a dict or list, comes back as a numpy array of its dtype (as its lists in a JSON answer), except the ones numpy has no dtype for: bfloat16 and the float8 types come back as float32 and complex32 as complex64, each value exactly as it was. So every value must be one msgpack carries (a tuple arrives as a list). A camera frame wrapped insequence_ai.Videotravels compressed, as lossy video, and reaches the policy as an array of its shape and dtype (markers). - In an eval, the eval’s adapter turns the env’s observation into your inputs and your answer into the env’s actions; with no adapter your policy gets the env’s observation as it is, and its answer, which must then be a sequence of actions, plays one a step. A dict needs an adapter (see Adapters).
- A wrong key is not caught before
inferruns, because nothing knows your format:inputs["state"]on a request that sentarm_xraises inside your code, and the caller gets that error: a Python built-in exception comes back as itself, hereKeyError: 'state', with your code’s traceback on.remote_traceback(any other type arrives asPolicyError, its name in.exception_type). It is a500 policy_error, so a caller can tell your code’s failure from the platform’s. Check the keys you need at the top ofinferand raise an error that names them, astoy-policydoes.
Parts it can add on top, each on its own; a policy needs none of them:
- Its history: an
@seq.observemethod is handed eachobserve()as it was sent, in the order sent, before the act after it, on a robot and in an eval alike. What an act needs of the steps before it (a camera’s last frames, say) the method keeps inepisode.local, or inepisode.statewhen it must come over to a standby, and the act reads it there (the example after this list). Without one,inferis handed the episode’s latestobserve(). - Several frames at once: a camera’s frame wrapped in
sequence_ai.Videotravels compressed, as lossy video (markers). Several (a stack of frames, or several cameras) go in oneobserve()as a list ofVideoitems, or a list of lists, and arrive as that list, each item the array it was:np.stackmakes them one array. - A sample episode: a method marked
@seq.samplereturns one episode’s calls, in order, as your robot makes them (("observe", x)for eachobserve(x)and("act",)for eachact()) with real frames rather than blank ones, read from a file in your folder if you like. The build check plays them as one episode on one copy, as a robot’s calls go: each observation as a robot’s is sent (through msgpack, bytes arriving as bytes and arrays as arrays) and each act calling your act function with what came before it. It fails the deploy at the first call that fails, naming it, and otherwiseseq deploysays each act’s time (the first, then the steady) and the most GPU memory it held. Every worker plays its first act on each copy too, each time it starts, before it serves, so a robot’s first act finds the copy warm (Episodes). Without one, nothing stands in for your inputs and the check cannot callinfer. - On a robot,
act()returns whatinferreturned, and your loop plays it (your own loop). - Acts exactly k steps apart:
action_chunk_replan_at=ksays the step, counted from when an act is sent, at which an eval sends the next one, k steps on; it switches to that answer at theaction_chunk_valid_lenstep, the world held still until the answer comes. On a robot, when the next act goes is your loop’s: a policy that checks each act’s step against its own timeline, its next act exactly k steps on, needs a loop that counts the k steps from when it sent the act (your own loop). An act takes no step of its own: it comes after its episode’s lastpolicy.observe(), so handobserve()each step’s observation between two acts.
@seq.observe
def keep_user(self, obs, episode):
frames_user = episode.local.setdefault("frames_user", [])
frames_user.append(obs["image_user"]) # an array: a Video arrives decoded
del frames_user[:-8]
@seq.infer
def act_user(self, episode):
return self.predict(np.stack(episode.local["frames_user"]))
A class you already have, as it is
A policy class that already runs on your machine (one that builds its model in its constructor)
stays as it is. A short subclass of it, in a file of its own, marks the methods the platform calls with the same
decorators as any policy, and @seq.policy on the subclass says how it deploys. The class keeps
running locally as before; its packages go in its image:
import seq from my_robot_user.model import MyModel as MyModel_user # your class, unchanged @seq.policy(hz=15, weights="hf://my_org_user/my_checkpoint_user", init={"cfg": seq.config("config.yaml", ckpt_dir="{weights}")}) class Policy_user(MyModel_user): @seq.observe def update_obs_user(self, obs, episode): episode.state["obs"] = obs @seq.infer def act_user(self, episode): # a list of actions return self.predict(episode.state["obs"])
- Building it: the worker calls
Policy(**init)(your class’s constructor, its own code not a line changed) once, at cold start, its weights on disk.initis a dict by name, or a list by position (init=[cfg]). In any string,"{weights}"is the weights directory ("{weights.base}", a named part’s).seq.config(path, **keys)is a YAML or JSON file’s contents withkeysset over them, read on the worker from this file’s folder: the file goes up with your code. - An episode: each
observe()the robot sends goes toupdate_obs_useras it was sent, in the order sent; anact(), which carries nothing, then callsact_user, after every observe before it (observe() and act()). An eval handsupdate_obs_usereach observation since the last act, oldest first, then callsact_user. What they keep goes inepisode.state, the platform’s dict for that episode, or inepisode.localfor what is large and of its worker alone, not onself: on a robot a replica serves that one robot, and in an eval one replica plays several episodes in turn, so what one episode left onselfwould reach the next one’s act. A subclass whose methods call your class’s own instead (super().update_obs(obs), which keeps the episode on the class) holds a replica for each episode, and calls your class’s reset in its@seq.on_episodemethod as each begins:if episode.phase == "start": self.reset()(Episodes). - Without
@seq.observe, the@seq.infermethod is handed the episode’s latestobserve()at each act, whole, or each key by name (below); anact()before anyobserve()is refused,400no_observation. - A chunk an act, not an action a step: an act crosses the network
to a model that infers in about 230 ms
(Pacing on a real robot), so mark with
@seq.infera method that returns a whole chunk of actions, and leave playing it to the robot’s own loop (your own loop); an eval sends its next act at the policy’saction_chunk_replan_atstep, its rows playing athz. A method that returns one action each control step, from a queue it keeps, would wait out that round trip every step, which no 10–30 Hz loop has time for. A LeRobot policy has both:select_actionreturns one action, callingpredict_action_chunkfor the next chunk when its queue runs out. Mark a method that answers withpredict_action_chunk’s: its(1, T, D)answer plays asTrows when it annotates its observationdict[str, torch.Tensor], which hands it torch tensors on its device and takes the batch dimension off its answer. LeRobot normalizes outside the policy, in its processors (make_pre_post_processors), so run them aroundpredict_action_chunkin that method.seq deploywarns when the@seq.infermethod isselect_action. - Its inputs by name: an
@seq.observemethod (or, with none, the@seq.inferone) that takes two or more arguments without a default besides the platform’s own (episode, andstepfor@seq.observeorseedfor@seq.infer),def update_obs_user(self, image, state, prompt=""), is handed each key of the inputs as the argument of that name, one with a default only when the key is there. Inputs that are not a dict, lack a key it needs, or hold one it takes no argument for (unless it takes**kwargs) are refused with a400that names each key. One that takes a single argument is handed the inputs whole, an@seq.inferor@seq.observemethod’s other arguments with a default being inference parameters; one that takes its inputs by name has none. - Checked when you deploy:
seq deployreads your file and refuses, before anything is uploaded, a method that does not take what it is handed, aninitits constructor does not take, a config file that is not there, or"{weights}"with noweights=. What the constructor raises fails the deploy’s check, with your traceback.
A class of the repository needs nothing but its method marked. Awomo’s policy class builds its model from a checkpoint in its constructor and answers with a torch tensor; this file is all it adds:
import seq from awomo.policy import AwomoPolicy as AwomoPolicy_user @seq.policy(hz=15, weights="hf://my_org_user/awomo", init={"ckpt": "{weights}/model.pt"}) class Policy_user(AwomoPolicy_user): @seq.infer def predict_user(self, request): # a torch tensor return super().predict(request)
A class the repository builds with a function of its own rather than its constructor is held by a short class
instead: its __init__ calls that function, and its @seq.infer method answers with what
it built.
- Where it goes: the worker imports
seq_policy.py, andseq deployimports it on your machine too, so what it imports must be installed there. Put it where your code is run from: beside the class’s own when that one imports its neighbours by their bare names. - Its answer: the tensor
predict_userreturns comes back as an array of its dtype, a bfloat16 one as float32 (see Your own inputs and outputs).
How its answers play
What infer returns is its own: the platform checks only that it can be sent (JSON values with string keys, numpy arrays and bytes; anything else fails the act), converts a torch tensor to a numpy array (above) and a tuple to a list, and its robot
gets the rest as it was returned. Turning a row into a command for a controller is the robot’s own code
(your own loop). Three numbers on the policy say how its answers play,
@seq.policy(hz=15, action_chunk_valid_len=15, action_chunk_replan_at=8):
hz, required: the steps a second its answers play at (the policy’s rate, never the robot’s).action_chunk_valid_len: the steps of one answer that are valid (a model that answers 25 rows of which 15 are meant to play says 15, and the rest are never played);action_chunk_replan_at: the step, counted from when its act is sent, at which the next answer is needed, no later than the last valid step, which it is when unset. An eval sends the next act at that step and switches to its answer at the valid length, the world held still until it comes (when the next act goes).- The steps between the two are the time a robot can wait for its next answer, and the time the platform has to answer several robots in one batch: the earlier the replan step, the more of it (Batching requests). A policy that asks at its last valid step has its robots wait for every answer, none of them in a batch, unless it sets how long they may wait for one (Waiting for a batch). A robot that plays past the valid steps, or asks later than the policy was trained to be asked, fails quietly: the arm moves, and never completes the task.
- The two chunk lengths change with no new deploy:
seq policy set <name> action_chunk_replan_at=12, andaction_chunk_replan_at=puts it back to what the code says. A robot takes them with its next connect (one already on, as its lease renews), and each running worker seats and batches its robots by them within a minute. An eval plays by the values in effect when it starts, and its report says whether each was set or is the code’s. A replan step past the valid steps is refused.
Inference parameters
A keyword argument of infer with a default is an inference parameter, except the ones the platform
passes itself: episode and, in an eval, seed. What its @seq.plan returns for its
robot is in its episode (see Planning). A robot’s task comes in its observation, and so
does its embodiment: which arm it is goes in what it observes, and connect() takes no
embodiment=. Annotate it
int, float, bool or str; seq deploy --dry-run
lists them. Their defaults are the policy’s settings, the same for every robot (below); what differs between
robots goes in their observations, policy.observe(x). An eval sets one with --param or
compares values with --sweep (an adapter’s and a benchmark’s too:
Parameters in an eval). A name the policy did not declare is
refused before inference, and each value is cast to its declared type.
A parameter can also say which values it takes: bound a number with
Annotated[int, seq.Range(1, 10)] (or seq.Range(min=0.0)), or list its values with
Annotated[str, seq.OneOf("fast", "careful")]. Any other value is refused before inference, saying
what is allowed, by seq policy set, and by an eval before anything is reserved;
seq deploy --dry-run shows the range beside each parameter.
An @seq.observe method declares them the same way, beside the frame and the
step the platform passes: each method is handed the values it takes, the episode’s, so a
camera’s crop is applied as each frame comes. A name both declare is declared the same in both. A parameter
may also be a list of numbers, list[float], at most 64 of them, a seq.Range bounding
each; set one as numbers separated by commas, seq policy set <name> params.crop=0.4,0.2,0.8.
A list is not swept; an eval sets one with --param, for each method that takes it.
@seq.observe def observe_user( self, frame, *, step=None, crop: Annotated[list[float], seq.Range(0.0, 1.0)] = (0.42, 0.18, 0.82), ): self.image_user = crop_user(frame["front"], crop) # $ seq policy set my_policy_user params.crop=0.40,0.18,0.82
A policy’s defaults change without a redeploy: seq policy set <name> params.replan_steps_user=10.
Each running worker takes them within a minute, and every robot’s episode begun after that runs with them;
an episode under way keeps the ones it began with. A robot’s act carries none of its own. An eval of the policy runs with them
too unless it sets its own with --param, and its report marks those values
deployment’s default. params.replan_steps_user= puts one back to the code’s default,
and seq policy settings <name> shows each beside what the policy declares.
@seq.infer def infer_user(self, obs, *, seed=None, replan_steps_user: Annotated[int, seq.Range(1, 10)] = 5, temperature: float = 0.0): ... # $ seq eval run my_policy_user --benchmark libero_custom_user --param replan_steps_user=3 # $ seq eval run my_policy_user --benchmark libero_custom_user --sweep replan_steps_user=3,5,8
Pacing on a real robot
Four numbers decide whether an arm keeps moving between chunks. The control rate (actions per
second, the policy’s hz) belongs to the model and the data it was trained on: each
action means “move this much in this step”, so it is not a knob. The robot asks for the next chunk at
the policy’s replan step, action_chunk_replan_at steps after it sent the last act, and
plays on to its valid steps, action_chunk_valid_len, while the answer comes. One call’s
round trip is the policy’s inference plus the network. The steps from the replan step to the valid
length, over the control rate, are the time the next answer has to arrive in; when a round trip is longer, the arm
stops and waits on every chunk (your own loop).
| a policy on an L4, 15 Hz, 15 valid steps | time for the next answer | one round trip | result |
|---|---|---|---|
action_chunk_replan_at=12 | 200 ms | about 230 ms inference + the network: 300–350 ms measured from one robot | a pause on every chunk |
action_chunk_replan_at=8 | 467 ms | the same | the next chunk arrives while the arm moves |
An eval models no network: each episode sends an act at the replan step and switches to its answer at the valid length, the world held still until it comes (Run an eval), so it scores the policy as its own timing plays it. On a robot the round trip is the network’s too: ask early enough that the valid steps left cover it.
On a Linux robot the network can add round trips of its own: with
net.ipv4.tcp_slow_start_after_idle at 1, the default, a connection’s send window starts small
again after each pause, so a large observation sent after one (frames from several cameras, say)
goes up in several round trips rather than one. Set it to 0 with
sudo sysctl -w net.ipv4.tcp_slow_start_after_idle=0 (a line in /etc/sysctl.d/ keeps it
after a reboot), or load BBR with sudo modprobe tcp_bbr, which sequence-ai then uses on its
connections. sequence-ai warns once a process, at the first observation over 256 KiB on such a machine.
A standby copy
With buffer_workers above 0, each robot that connects also holds a connection to a standby: a copy
of the policy on another worker with a free seat for it, one that already serves robots first, the robot
joining its batch there, and an idle worker only once those are full (a missing one is started at once). The
robot’s act goes to its standby at once, with no connect between, and the episode goes on there from its
state as saved, when the copy it acts on:
- is cut off (its worker’s process or machine went away): the act that was on it moves as its connection drops;
- is going away (its worker says so): at the robot’s next act;
- answers nothing (an act goes unanswered for three of the robot’s control periods [1.5 times its slowest recent round trip, when that is longer], and its worker then answers nothing to a check sent on another connection): as that check goes unanswered. The check starts once 20 of the robot’s acts have been answered on that worker;
- is stuck (its worker answers, but the policy is stuck in the act): once the act has run 10 times
as long as that copy usually takes for a batch of that size (the 99th percentile of its last 100; its slowest,
before it has answered 20) and at least 10 seconds, the worker answers it
copy_stuck, starts the copy again, and every robot on that copy moves: the robots whose acts it held at once, the others at their next act. A copy’s first act at a batch size is never held to this, as it may compile. The deployment’s request timeout still comes first where it is shorter (Scaling).
That one act takes longer, as the standby first reads the episode’s state back (0.6 to 1.6 seconds when we
measured it); the acts after it take as long as before. The platform saves each episode’s
episode.state every 2 seconds, each save the keys of it that changed, so at most the last 2 seconds
of what the policy changed in it are lost, and the robot sends again the observations since that save; sequence-ai warns once that it switched, and
why: for a stuck copy, how long the act ran. The episode goes on there rather than begins: its
@seq.on_episode start does not run again, and its episode.local, never saved, begins
empty. A policy fills it again from the observations that follow, or keeps in episode.state
what must come over. The robot then gets a new standby, never on the worker it left.
None of the robot’s observations and none of its acts’ answers is saved, whether its Record is on
or off: on the standby, episode.state["seq.observations"] and "seq.actions" begin again
with the observations the robot sends it, from a few seconds before the switch, not the episode’s last
minute.
seq policy logs says which copy was stuck, how long the act ran and how long that copy usually
takes. A robot that loses its own network loses both connections, and reconnects through the platform once its
network is back, as it would without a standby.
Without a standby (buffer_workers 0, or no worker with room), the robot reconnects through
the platform in the same cases: it takes a free seat on another worker that serves robots, then an idle worker,
and only when none has room does a new worker start for it (about 4 minutes or more on a new machine). The
episode starts anew there, unless its worker was on a spot machine (below). A robot whose copy was stuck that
finds no free seat stays on its worker, where its copy starts
again in about the time the policy takes to load.
On a spot machine (one the cloud it runs on can take back at any time), a worker saves its episodes
as with a standby, every 2 seconds, whether or not the policy keeps spare workers. When the machine is taken back,
the robot’s act goes to its standby, or with none to another worker as above, and the episode goes on there
from its state as saved, at most 2 seconds before; sequence-ai warns once where its act went, and why.
A spare worker (buffer_workers=1) lets them move at once.
What the policy keeps in episode.state goes with the episode when it can be stored: numbers, text,
arrays, tensors, bytes, and lists and maps of them. A model object, an open file or any other handle is skipped,
said once in the worker’s log, and is not there after a switch: a policy keeps such things on itself, built
in its constructor, and keeps only data in episode.state. An episode’s state may hold
16 MiB as saved, arrays and bytes taking a third more than their size; one past it is not saved, the
worker’s log says so with its size, and a standby a robot switches to begins the episode anew, its
@seq.on_episode start run there. What is large and needed on the worker alone (a frame
history, a cache on the GPU) goes in episode.local: the episode’s own, like its state,
and never saved, sent or stored.
Batching requests
With @seq.concurrent(sizes=[1, 2, 4, 8]) on infer the worker runs acts that are waiting
together as one call, in the sizes it lists: the batch sizes your model is built for, each 1 to 256,
ascending, 1 first, as an act that finds no other robot’s to join goes as a batch of 1 (a JAX policy
compiles each). The worker stacks their inputs into one batch: each array, tensor
or number along a new first axis, a dict key by key, text as a list; arrays whose first axis differs (a
window shorter at an episode’s start) are padded with zeros, <key>_mask beside them,
True where real; a key not every act sends comes as a list, None where an act sent none. infer returns one batch, each array a row an act (or a list of answers in order),
and each act gets its row.
Each inference parameter is one value: acts that carry others (a setting
changed with seq policy set, an eval’s --param) go in calls of their own,
each padded to a listed size with its last act’s inputs and seed, rows no act gets back;
seed is a list of the batch’s rows and episode of its acts’ own episodes. Acts that fill no listed size go as
the sizes that fit them: three of [1, 2, 4] as 2, then 1. When a call raises, the worker runs each of its acts again on its own: only an act that fails on its own
gets an error, and the log says the batch was run again.
A batch raises throughput, not one robot’s speed: a policy on an L4 answers one observation in 232 ms and sixteen in 2270 ms, 1.6 times the requests per second, each of them slower. (The model’s own time inside a warm worker, no network. What one robot waits for is more: Where an act’s time goes.) Nearly all of that time is the forward pass on the card, not the work done for each request: timed again piece by piece, the policy at sixteen spent 2.03 of its 2.15 s there, and decoding the frames, the transforms and the hand-off to the model’s process the other 0.11 s, about the same with 8 cores as with 1.25.
- A deployment serving robots: the build check times each listed size on your sample episode
(
@seq.sample). A worker on the card it ran on seats by that timing and runs only its sample’s first act, a batch of 1, before it serves, so another size your framework compiles, as JAX does, compiles at its first batch. A worker on another card serves at once, one robot a copy, and times the sizes beside its robots, whose acts on that copy wait behind each size’s run; then it seats by what it timed. - How many robots a copy seats: a copy seats a robot in a batch of a size, 64 robots at most, while two things hold. Its latency: the
batch’s time in the worker (the 95th percentile its timing measured, plus the worker’s own handling once it serves; once 8 of its acts have been answered in batches of that size, the 90th percentile of what those batches took), the robot’s own round trip and 50 ms to spare answer within the time the
robot can wait for an answer, the steps from
action_chunk_replan_attoaction_chunk_valid_len, athz. Its robots, as they run together: a copy runs one batch at a time and each robot asks on its own clock, so an act that comes while another robot’s batch runs waits for it. To count them the platform runs 2 robots, then 3, and so on, on a simulated clock. No model runs: each batch takes the time its size was timed at, each robot has its own round trip, and acts are batched as the worker batches them. How far apart the robots’ acts fall is not fixed, so the clock is run many times, the robots started at evenly spaced offsets across the time between a robot’s asks (action_chunk_replan_atsteps athz). A number of robots is seated when, in every one of those runs, each answer is back before the answer its robot plays runs out, and their batches fill no more than 90% of the time between a robot’s asks. The first number that fails ends the count. Every run, not most of them: each episode a robot’s loop starts its asks again from the moment it is called, and robots’ clocks drift, so two robots can spend a whole episode in any of the ways their acts can fall. A robot’s round trip is what its acts spend outside the worker, which each of its acts tells the worker: a default until it has said, and in whatseq deploysays, before any robot connects. - A copy seats one robot without
@seq.concurrent, asinferthen takes one act at a time and robots never take turns on a copy; when an episode holds its copy, the policy keeping each episode’s state on the class (Episodes); when the policy declares no valid length, or asks at its last valid step and sets no wait (Waiting for a batch); and when two robots do not pass the count above.seq deploy, on itsseatsline,seq policy status, under itsrobots per worker, and the console’s Workers, in the tip on a worker’s robots (“1 of 1”), say which of the first three it is: “one robot a copy: …”. Of the last, a hint says where not even a batch of two answers in time (below), and the worker’s own log line says the rest (Logs). - When no copy can take a new robot, another worker starts, within
max_gpus. - Waiting for a batch:
@seq.policy(max_wait_for_batch=1.7)lets each robot wait up to that many seconds for an answer, from when it sends its act, so that its act can share a batch. A copy then seats robots by that wait in place of the steps they play while an answer comes: the largest size whose batch, the robot’s round trip and 50 ms to spare answer within it, while their batches fill at most 90% of a robot’s time between asks (its replan step after its wait for the answer), by its load alone, with no run on the clock. A policy that asks at its last valid step seats one robot a copy without it, and as many as answer within the wait with it: one whose batches of 1, 2, 4 and 8 take 1.09, 1.16, 1.28 and 1.61 s (the 95th percentile) on an L4 seats 1 robot a copy unset, 2 at 1.3 s, 4 at 1.4 s and 8 at 1.75 s, its robots 47 ms from their worker. A robot whose answer is not in hand stops for up to that long; what it does meanwhile is its own code’s (connect(on_stale=)), and an answer counts as late only past the wait. As its batches take longer a worker seats fewer robots, and the others move at the end of their episodes;seq policy statussays each robot’s wait, and a hint says one that went past it. It changes with no new deploy:seq policy set <name> max_wait_for_batch=1.7, each running worker within a minute, a robot with its next connect. An eval plays as before, its world held still for every answer. Unset, nothing changes. - In an eval, the episodes’ acts run together in the sizes it lists; the platform times every
batch itself. To batch your own simulator, run it as an eval with
seq eval.
When not even a batch of two answers in time, a copy seats one robot, and seq deploy,
seq policy status and the version’s row in the console say why in a hint, here for
hz=15, action_chunk_valid_len=15, action_chunk_replan_at=8:
hint: A copy seats one robot: a batch of 2 takes about 518 ms here - 368 ms in the policy, 100 ms for its robots' network (none of this policy's robots has acted yet) and 50 ms to spare - and a robot has one act on its way at a time, so each answer has to come within half of the 1000 ms a whole answer plays (15 steps at 15 Hz): asking earlier does not help; a longer action_chunk_valid_len or a shorter round trip does.
The hint times each robot by its own network: the 90th percentile of what its acts on this policy spent outside the worker over the last 7 days, among the policy’s newest 2000 acts, once it has 20 acts among them; until then (and for every robot of a new or forked policy), a default round trip. A robot far from its worker changes no other robot’s time, nor another policy’s: where only some of a policy’s robots get their answers late, the hint names the one whose answers come latest, by its key’s name, and says how many are late.
@seq.concurrent(sizes=[1, 2, 4, 8, 16]) # the sizes it is built for; a copy seats what it answers on time @seq.infer def infer_user(self, obs, *, seed=None): return self.model_user(obs) # obs {"front": (B, 224, 224, 3), ...}; (B, 50, 7) back
To batch the acts in your own code (a model whose inputs are read one sample at a time, as openpi’s
transforms are) declare collate=False: each argument of infer then receives a list
with one entry an act (the observations, the seeds, and each inference parameter, one an act left out coming as
infer’s own default), and it returns a list in the same order.
@seq.concurrent(sizes=[1, 2, 4, 8], collate=False) @seq.infer def infer_user(self, obs, *, seed=None): return [self.model_user.one(o_user, s_user) for o_user, s_user in zip(obs, seed)] # a list in, a list out
A policy with @seq.concurrent needs a sample episode (@seq.sample). A copy serves
several robots’ episodes at once, so each robot’s own state goes in its episode (below): an
@seq.on_episode method is handed each episode as it begins and as it ends, one at a time.
Beside an infer that takes episode, it is handed episode: list[seq.Episode], one for
each act in the batch’s order (episode[i] is row i’s), and a batch holds
at most one act of an episode. When such a call raises, only the acts of episodes that had no act before on that
copy run again on their own, on an empty state; the other episodes end, since the call may have written into their
state: that act is answered 503 with details.reason batch_failed and a later one 409
episode_lost, and sequence-ai goes on in a new episode and says so on stderr
(Episodes).
@seq.concurrent(sizes=[1, 2, 4, 8]) @seq.infer def infer_user(self, obs, *, episode: list[seq.Episode]): for ep_user in episode: # one per observation, in order ep_user.state["acts"] = ep_user.state.get("acts", 0) + 1 return self.model_user.batch(obs)
CUDA graphs
A torch policy’s act (torch 2.4 or later) replays the module it calls several times with the same shapes, a diffusion or flow head’s denoiser, from CUDA graphs of that module’s own kernels, so the card no longer waits for Python to launch each kernel. The answers do not change: a graph replays the very kernels the module ran, and it is used only where it answered exactly as the module did, bit for bit. GR00T N1.7 on an L4 went from 149.9 to 117.5 ms an act so, about 1.3 times faster. There is nothing to declare: the check of every policy that holds a torch module once loaded tries them. A JAX policy gains nothing: XLA already fuses its kernels and replays them as graphs (π0.5’s card was busy 98% of its act), and its check does not try them.
Each version’s check tries them before it starts the worker it checks, on your @seq.sample
episode, which it needs: it counts the calls each module gets in an act, captures the outermost ones called more
than once with one shape, then plays the episode with and without the graphs on inputs they were not captured on,
and, for a @seq.concurrent policy, in a batch of another size. They are on only when every
answer was the same, bit for bit, and acts were at least 10% faster; the build log says which, in one line:
optimize: cuda_graphs on - infer._policy.model.action_head.model (4 calls a run), infer._policy.model.action_head.action_encoder (4 calls a run), infer._policy.model.action_head.action_decoder (4 calls a run): the same outputs, bit for bit, on 8 runs; act 149.9 → 117.5 ms speed-ups: off - 3% faster (act 100.0 → 97.0 ms), under the 10% it needs speed-ups: off - no module is called more than once a run with the same shapes
A worker captures each input shape the first time it meets one (a new prompt’s length, a batch of
another size), answering that act from the module itself and keeping the graph only when the two answers are
the same; a shape whose graph is not, or that cannot be captured, runs without one, and the worker’s log says
so once. That first act takes 0.1 to 0.4 s more; on GR00T the graphs held no more of the card’s memory. A
check that tries them loads your policy twice, and is billed for that time as any check is.
seq policy status and the policy’s page in the console say
CUDA graphs: on (acts 1.54× faster), or off and why.
Images
Each seq.Image method returns a new image; the chain is a spec, and the step
order you write is the build order.
| method | what it declares |
|---|---|
seq.Image.debian_slim() | a small Debian 12 base (debian:12-slim), the default when you declare no image and your project has no dependency files |
seq.Image.from_project(exclude=[...], extra=[...], requirements="...") | start from your project’s own dependency files, installed for Linux and the worker’s card, the default when you declare no image= and the project has them (below) |
seq.Image.from_registry("...") | start from any registry tag, carried through verbatim |
seq.Image.from_dockerfile("Dockerfile", context=".") | build from your own Dockerfile; its COPY lines read from context, uploaded when you deploy |
.add_local_file("config.yaml", "/root/config.yaml") / .add_local_dir(...) | ship a file or directory with the deploy and place it in the image at an absolute path |
python="3.12" / "image" | on any of the four: the Python the image runs (below) |
.apt_install(*pkgs) | system libraries (apt-get install) |
.uv_pip_install(*pkgs) | Python packages (uv pip install) |
.run_commands(*cmds, secrets=[...]) | arbitrary build commands, run in order. secrets= (a private repo, a package index token) is not taken by a policy’s build yet: the build stops at that step, naming the secret. Where a benchmark’s build takes it, the credential is present for that step only, never in the running machine, and the build’s copy of it is deleted when the build ends |
.template_files("toy-benchmark", version=4) | an official template version’s frozen build files (its sources at their pinned commits, its Python and system packages, the assets it downloads), read-only at /seq/frozen for each run_commands after it, so the template builds the same whether or not the sites they came from still serve them; nothing of them stays in the image unless a step installs it. One template version an image |
.env(...) | build-time environment variables (never secrets: those travel by name) |
Your project’s own dependencies. A policy that declares no image= gets its
image from its project’s own dependency files when it has any.
seq deploy reads them from the entry file’s folder up to the folder you deploy: a lock first
(uv.lock, poetry.lock, pdm.lock, Pipfile.lock, a
requirements*.lock, or a requirements.txt whose every line pins a version), else
pyproject.toml’s dependencies, requirements.txt or setup.py. A folder
with none of these reads its one requirements-<name>.txt or
requirements_<name>.txt as a requirements.txt; of several, seq deploy
stops and names them until you name one, read in the nearest folder that holds it:
seq.Image.from_project(requirements="requirements-gpu.txt"). A package
your code imports from a folder of its own (one with its own pyproject.toml or
setup.py) is installed too. With image= the image is exactly what you write. To
have both, start the image with seq.Image.from_project(): the steps you chain after it run after the
project’s install.
A lock’s versions are installed exactly. Without one, a range is held to the version your machine has
installed, when that version is inside the range and your machine runs the worker’s Python. Without a lock or
such a version, a range resolves to the newest version it allows: OpenWAM asks for torch>=2.5,<3
and gets the newest torch 2 (2.14.1 when we tried it), where its README recommends 2.7.1. Pin the versions you tested in
[tool.seq] extra (below), or bring a lock. As the image builds, the platform fits the files to
Linux and the worker’s card. torch comes with the CUDA libraries for the card, or as its CPU build for
--gpu cpu. Packages only macOS has are left out, and opencv-python becomes
opencv-python-headless, held to the version or the range it was asked for. flash-attn, causal-conv1d and
mamba-ssm come from the prebuilt wheel their release page has for the torch installed. The Python is
your project’s .python-version; else the one your machine runs, when the worker runs it (3.11,
3.12 or 3.13) and the project allows it; else 3.11, or, for a project that does not allow 3.11, the lowest it allows.
[tool.seq] # never installed, whatever asks for them exclude = ["deepspeed", "wandb"] # added after the project's own extra = [ "torch==2.7.1", "causal-conv1d @ https://…/causal_conv1d.whl", ]
The same lists go to from_project(exclude=..., extra=...). seq deploy and
seq deploy --dry-run say what they read before anything is sent:
dependencies from the project's own files (the policy declares no image=): pyproject.toml 8 requirement(s) policy/OpenWAM/OpenWAM/ the package openwam the code imports, with its 30 requirement(s) Python 3.11 the worker's default - this machine's 3.14 is not one the worker runs the platform fits these to Linux and the worker's machine as the image builds; the build log's first lines say how
A package that cannot be installed ends the build with one line saying which package, why, and what to change in the project’s files.
A local path in an image (the Dockerfile and its context, and every
add_local_file / add_local_dir) is read from the directory of the file that
declares the image, not the directory you run seq deploy from. So
from_dockerfile("Dockerfile", context=".") in my_bench_user/benchmark.py finds the
Dockerfile beside it whether you deploy from that folder or its parent. An absolute path is taken as
written.
The worker runs on the Python the image gives it. From debian_slim() or a registry base the platform
adds Python 3.11, except an official python:* image, which keeps its own.
python="image" uses the interpreter already on the base’s PATH;
python="3.12" adds that version instead (an error on an official python:* base, which has its own; then
python="image" is what you want). A from_dockerfile image owns its Python, and the
platform adds none unless python= names one.
Your own image can reach upstream as it builds: .run_commands has the network, so a package too
large to upload with your code (a deploy uploads at most 8 MiB compressed, from a folder of at most
64 MiB) installs from where it is published, by its URL. A wheel on a GitHub release, for instance:
.run_commands("pip install https://github.com/<org>/<repo>/releases/download/<tag>/<wheel>.whl").
It is downloaded again each time a version builds, from that URL as it is then.
Bringing a fully-provisioned base. When the base is a large third-party image (a
simulator engine, say), the platform keeps its packages for you: it installs its own runtime set over the
base but keeps the base’s version of each where it meets the platform’s minimum, so a base that pins,
say, numpy below 2.0 is not forced past it. You write nothing for that. One option is yours to set:
clear_entrypoint=True on from_registry / from_dockerfile
(sequence-ai 0.38.13 or newer) drops the base’s ENTRYPOINT so the
platform’s start command runs directly, off by default, because some images use their ENTRYPOINT to
prepare the environment and clearing it would break them. If the base’s own Python is not on
PATH, a small Dockerfile wrapper puts it there.
Using Isaac Lab is the whole recipe.
Every image has a C and C++ compiler. The platform adds gcc and g++ 12, with OpenMP, to every image it
builds, before its own packages and your steps: Triton builds with it as your policy runs (and
torch.compile on a GPU runs through Triton), Inductor’s CPU kernels are C++ built with it,
and a uv_pip_install of a package with no wheel for the worker builds it from source with it. When
your image has a compiler of its own (an NVIDIA image, a -devel base, or gcc you add with
apt_install), that one is used: the platform’s comes last on PATH.
Planning
A policy can plan. Give its class an @seq.plan method, and it runs in the background for each robot
connected to the policy: what it returns is that robot’s next step, and the act function reads the newest
from its episode. It runs on the policy’s own machine, out of the act’s way, and each robot has its
own: it sees that robot alone and writes to that robot alone. A robot connects as to any policy,
sequence_ai.connect("pick_user"). A policy with no @seq.plan has nothing running in the
background, and its act reads what the robot observes. In the examples, everything ending in _user
is yours, and so are the strings.
import seq import sequence_ai # models= names the models its plan calls @seq.policy(hz=15, models=["qwen3-8-27b"]) class Pick_user(seq.Policy): def __init__(self): self.model_user = ... @seq.plan(every_s=2.0, wake_on=["say_user"]) def plan_user(self, robot): # def or async def seen_user = robot.state["seq.observations"][-1] return sequence_ai.chat("qwen3-8-27b", [{"role": "user", "content": [ sequence_ai.image(seen_user["image_user"]), {"type": "text", "text": "Its next step, in a few words?"}]}], max_tokens=40, reasoning={"effort": "none"}).content @seq.infer def act_user(self, obs, episode): plans_user = episode.state.get("seq.plans") # none until its first plan returns step_user = plans_user[-1]["value"] if plans_user else obs["task_user"] return self.model_user(obs["image_user"], step_user)
import sequence_ai # its robot key, as for any policy policy_user = sequence_ai.connect("pick_user") policy_user.observe({"image_user": frame_user, "task_user": "pick up a cup"}) actions_user = policy_user.act() # "say_user" is in its wake_on: it plans now policy_user.observe({"image_user": frame_user, "say_user": "red cups first"})
# in its plan: stop this robot and ask for a person @seq.plan(every_s=2.0) def plan_user(self, robot): if stuck_user(robot.state): return seq.ask_human("it dropped the cup twice") # at the robot's own console op_user = sequence_ai.teleop(key=ROBOT_KEY_user, operator="alice_user") for ask_user in op_user.requests(): print(ask_user["reason"]) # ask_user["frame"]: a JPEG op_user.take()
- What it sees.
robot.id, its episode’s id, new with each episode, androbot.state, read for each call and read-only: every key its act keeps inepisode.state, with"seq.observations"and"seq.actions"as tuples, oldest first, each holding about the episode’s last minute, and"seq.plans", its plans. It sharesselfwith the act, on another thread: what the two both touch there is yours to guard. - What it returns. Any value but
Noneis added to the robot’sepisode.state["seq.plans"], as{"step": its newest observation’s step, "value": value};Nonechanges nothing. The act never waits for a plan, so its first may come before the first plan: it reads them with.getand decides what to do without one. - When.
every_s, which it must have, is the time from one call’s start to the next’s;seq policy set pick_user plan.every_s=5changes it with no new deploy.wake_on, a list of top-level keys of an observation, calls it as soon as one comes, or straight after the call it finds running. Each robot has one call at a time, and only when it has sent a new observation: a robot that sends none is not planned and costs nothing, and its first call comes with its first observation. A call that raises is written to the policy’s logs, its newest plan stays, the next tick calls again, and the act goes on. When the episode ends the calls stop, and a call still running has its result dropped. - What it takes. One
@seq.planat most,plan(self, robot), plain orasync, that returns rather than yields, beside an act function that takesepisode:seq deployrefuses anything else, and a policy with a plan deployed on more cards than one machine holds, as each machine would plan on its own. Anasync defplan shares one event loop with the other robots’ plans on its copy, so a blocking call in it (time.sleep, the synchronoussequence_ai.chat) holds theirs up, never the act, where a plaindefhas a thread of its own. A catalogue model the plan calls is declared inmodels=. With an@seq.sample, a deploy’s check plays its act, plans once and plays its act again with the plan, and a plan that raises fails the deploy with its words. - Keys that are the platform’s. A top-level key that starts
seq.cannot be observed:observe({"seq.plans": …})is refused before it goes, so what a robot sends never writes a plan. To give a plan words from outside, observe them under a key of your own (External agents). - Asking for a person. A plan returns
seq.ask_human(reason)to ask for a person in place of a next step. A robot with"teleop"among the names it connected to is stopped, as a console’sstop()stops it, and every console connected to the robot hears of it through itsrequests()(Teleoperation), each a dict: which robot ("robot"),"reason","policy", when it first asked ("at", epoch seconds),"hold", and"frame", a small JPEG of its latest frame (Nonewhen there is none). Withhold=Falseits policy drives on while it waits. Ask in every plan for as long as you want a person: a console hears of a robot once, and again only for a new reason, or when a request made withhold=Falseis asked again held. The request is answered once someonetake()s the robot; once it is handed back, the next ask is a new request. A plan never stops a robot a person drives. A reason is up to 500 characters. - What it costs. Nothing for itself: it runs on the policy’s worker, which is billed as it is. Each
model call is billed as any chat call. A model that reasons by default, as
qwen3-8-27bdoes, is told not to withreasoning={"effort": "none"}: a plan wants its short answer now (see Reasoning). - In an eval.
seq eval run pick_user --benchmark reach_userruns the plan on each episode’s own clock and keeps every plan (Evaluate a policy that plans).
Where your code runs
The platform runs your benchmark code as an unprivileged user, not root, in a locked-down environment, as below. A policy’s worker is a machine of its own: your policy’s code runs in its container as the image’s own user, with the image’s environment. On a benchmark’s machine this matters most when you bring a third-party image, whose files may be owned by root or by a user that is not yours: your code cannot read or write them unless the image makes them accessible.
- An unprivileged user. A benchmark’s code runs as UID 10001 (GID 10001), with no power over
anything
rootowns. A brought image whose files are root-owned and not world-readable, for example a base that ends onUSER someonewith a750home, is unreadable until the image opens it up (chmod o+rx), which is why the Isaac recipe does exactly that. - What is writable. A home your code owns (
HOME,/srv/home), a temporary directory (TMPDIR), and the compile-cache directories the platform points the frameworks at ($SEQ_JIT_CACHE_DIR, andJAX/torch/Tritonunder it). The base image’s own directories are writable only where the image made them so. On a policy’s worker the frameworks’ compile caches are set for you, andHOMEis the image’s. - A trimmed environment. On a benchmark’s machine, subprocesses you start inherit an allowlisted environment, and the
loader variables
LD_PRELOADandLD_LIBRARY_PATHare dropped, so an image that needs them (Isaac does) must set them from inside a wrapper or bake its libraries onto the loader path withldconfigat build, not rely on anENVthat reaches a child. A policy’s worker keeps the image’s environment, and neither a deployment’s env nor an image’s env step may name a loader variable.
Volumes and weights
weights= copies the checkpoint once, at deploy, into a volume the worker mounts at
/data; every cold start reads that copy. The volume is billed as storage at the size actually
copied. An official template’s weights are the exception while its code is unchanged: they are not copied;
its deployment reads the platform’s one read-only copy of each part, which is not billed to you. Change
any of the template’s code and they are copied for the deployment, and billed, as any weights are. Being shared,
they cannot be written to: code that writes into its weights
folder fails to load and says why. Have it write elsewhere, under /tmp, or deploy with
weights of your own. It names one of three things:
- An official template’s weights.
seq.Weights.template("<template>", version=1)(the string form is"template://<template>@v1"): the unmodified checkpoint a template ships with, plus what it loads at runtime (the policy’s tokenizer). A published version never changes; leaveversion=out to take the newest one at each deploy. No key is needed. This is whatseq init <template>writes. - Hugging Face.
hf://org/model,hf://org/model@<revision>, or only a part of the repo: a sub-folderhf://org/model@<revision>/<sub/folder>, or one filehf://org/model@<revision>/model.safetensors(the first two segments are the repo, the rest is the path inside it). The revision is resolved to a commit at deploy and exactly that commit is copied, so a re-deploy is deterministic; with a sub-path, only its files are copied and billed: a repo you use only a part of (one checkpoint among several, say) costs for the part, not the whole, each worker downloads only the part, and it mounts at the sub-path’s own root. A private or gated repo needs a token:seq secret set hf --env HF_TOKEN, thensecrets=[seq.Secret.from_name("hf")]. The copy runs with only that token; declaring it also handsHF_TOKENto your policy at runtime. A repo that cannot be read is refused when you deploy, in seconds, with what to fix. A public model your code downloads itself as it loads goes without a token unlessHF_TOKENis declared (its log says “You are sending unauthenticated requests to the HF Hub”), and Hugging Face limits such downloads by network address, which your workers share with others on the platform: declare the token, or name the model inweights=, a part of its own, so that it is copied once, at deploy. - Your own files. Upload a checkpoint directory once with
seq volume put my_checkpoint_user ./checkpoints/my_checkpoint_user(resumable: run it again after an interruption), then deploy it by name:weights=seq.Volume.from_name("my_checkpoint_user"), orweights="vol://my_checkpoint_user@v2"to name the version it is at now: a volume keeps its latest version alone, so a deploy naming one a later upload replaced is refused (“only the latest version is kept”). Every file’s md5 is checked when the upload completes; only then is the version active and billed as storage. Changed some files? Run the same command again: only the changed files are sent, as a new version, and the version it replaces is no longer billed; with nothing changed it says the volume is already up to date.seq volume lslists them and what uses each,seq volume show <name>one of them;seq volume rmis refused while a deployment’s weights, or a registered benchmark’s assets, use the volume. - Several parts. A dict of named parts, each from its own origin and read with its
own declared secret;
init=names each part’s directory as"{weights.<name>}". Up to 8 parts, named[a-z][a-z0-9_-]:weights={"base": "hf://my_org_user/base_model_user", "lora": seq.Volume.from_name("my_lora_user"), "norm_stats": seq.Volume.from_name("droid-norm")}.
Weights from your own storage bucket or an https URL are not supported. Move the files into a
volume once (download them, then seq volume put <name> <dir>) and deploy
weights=seq.Volume.from_name("<name>"), or point at the Hugging Face repo they came from.
A policy with no checkpoint (a closed-form controller, say) leaves weights= out:
nothing is copied or mounted, and nothing is billed as storage. seq deploy --dry-run shows
weights none.