Skip to content

Workload

workload {
  arrive poisson(rate);  |  arrive renewal(gap);  |  arrive closed(n);  |  arrive batch(n);  |  arrive none;
  trace "file.csv" [ordered];
  init block
  turn block
  [session block]
  hidden NAME [, NAME]*;
}

How sessions arrive and what each turn brings. init and turn blocks may only set and observe. Random draws in the workload use their own stream.

Clause Description
arrive Choose the arrival process. Default: none.
trace Supply session turns from a CSV corpus.
init Initialize a session once at arrival.
turn Set attributes whenever the session executes turn;.
session Describe how completed turns lead to the next; default: one turn.
hidden Restrict scheduler access to future attributes.

Workload assignments produce Size attributes that a server can read but cannot overwrite. init and turn produce no resource costs. The server interprets request quantities with cost; the session may use costs of client resources.

arrive

Form Argument Sessions arrive
poisson(rate) const, arrivals per clock unit one at time 0, then at exponential gaps of mean 1/rate
renewal(gap) expr of constants and draws after one gap, then at every further gap; gap is evaluated anew for each
closed(n) const, positive integer n at time 0, and a new one whenever a session ends
batch(n) const, positive integer n at time 0, and no more
none never (the default)

poisson and renewal are open: they arrive until the horizon, or until --arrivals N has had its N.

renewal

arrive renewal(~h2(2, 4));     // interarrival times of mean 2, CV² 4
arrive renewal(2);             // one every 2 clock units
Argument Type Description
gap expr The interarrival time. It may read numbers, let constants, functions of them and draws, and not a session attribute, a pool, a stage or a context variable. Each gap must be positive and finite, or the run aborts.

The first arrival is one gap after time 0, where poisson has one at 0: with the same seed, renewal(~exp(1 / rate)) arrives at the same times as poisson(rate) after its first arrival, and has no arrival at 0. Gaps draw from the arrival stream.

trace

trace "file.csv" [ordered];
Argument Type Description
file string Path relative to the program. Columns session,turn,new,out,think[,forced], one row per turn.
ordered flag Replay corpus sessions in order, cycling back to the first when exhausted. Without it, each session samples one corpus session and replays its turns in order.

At every turn; the next turn sets new, out, think and forced, and sets more to 1 while another turn remains (attributes).

init

init { set x = expr; … }

Runs once, when the session arrives. Moment Session.

turn

turn { set x = expr; … }

Runs at every turn; statement of the session. Moment Session.

session

Optional: describes the sequence of turns and the time between them. Without it, each arriving session makes one turn and finishes. See Program. The time between turns, a tool call or a person reading, is tool Z;: with no stage tool declared, it runs on a delay the workload owns (an infinite server, named tool in the report), so the deployment declares nothing for it.

hidden

hidden o;
hidden o, think;
Argument Type Description
NAME session attribute The scheduler may not read it.

Hidden attributes may be read in session expressions and a claim's given condition. They are forbidden in scheduler expressions, including hold headers, queue and eviction keys, and stage scheduling rules. See evaluation moments.

An attribute the scheduler sets (cached, computed) cannot be hidden, and a name nothing sets is an error. The vLLM program hides output length o, preventing admission from reserving memory using future output length.

The server's own statements are the rest of the scheduler, and there a hidden attribute is the target's until a run reveals it. The server may run work by it (run engine decode (cost(engine, o - 1)): the model ends the run, not the scheduler), cache by it at release, and observe it. A run whose work necessarily reads it on every path reveals it when the run ends, since the end of a decode is the EOS the scheduler sees. After that the server may decide on it.

Before it is revealed, these are link errors when they read it, or read an attribute the server set from it (set long = o > 100;): a branch or while condition, a choose, a grow or load amount, or the index that picks a pool or stage. An attribute set from it is revealed with it.

Paths join conservatively: after a branch, the attribute counts as revealed only if both arms reveal it, and a loop's body may not run at all. Loop-carried assignments are checked until no new hidden dependencies reach the next pass. If one branch assigns x = a and another x = b, running work by x does not establish that both hidden inputs were read. Conditional expressions and short-circuit operators follow the same rule; an aggregate body is not assumed to execute. A hold's header is read at admission, where the attribute itself stays refused even after a run (the moment rule above). The workload's statements are the client's and are not subject to the server statement check.

Examples

A complete program:

fn main() {
  stage svc : delay;
  workload {
    arrive batch(2);
    init { set rounds = 2; }
    turn { set duration = ~uniform(1, 2); }
    session {
      loop {
        turn;
        set rounds = rounds - 1;
        branch (rounds == 0) { end; }
      }
    }
  }
  server {
    run svc (cost(svc, duration));
    observe elapsed = now;
  }
}

Save as model.sq, then run:

serq run model.sq --horizon 10 --seed 10

See also

Distributions, attributes, run settings, pyserq.read_trace.