CSE Roadmap

Core tier · about 6 hours · 6 parts

Part 3 of 6 · 2 min read

Parallel work and orchestrators

Run independent calls at the same time, or let one call decide how many subtasks there are.

Parallelisation

Two flavours:

  • Sectioning: independent sub-tasks run at the same time (a tone check, a policy check and a length check on one draft).
  • Voting: the same task several times, then the most common answer (module 2).
r = parallel(llm, {"tone": ..., "policy": ..., "length": ...})   # r.results, r.errors, r.seconds

In the demo each call sleeps 0.2 seconds, and three in parallel take about 0.2 seconds, not 0.6. A failing worker lands in r.errors and the others still return, which is how you keep a partial answer.

  • Use when sub-tasks do not depend on each other, or when you want several attempts.
  • Cost: you pay for every call, so parallel saves time, not money. Watch rate limits (Level 2, module 5).
  • Fails by hitting limits, or by merging results badly.

Orchestrator-workers

An orchestrator call decides at run time what subtasks are needed. Workers do them, and a final call combines the results.

o = orchestrate(llm, ticket, "PLAN\n{input}", "WORK\n{task}\n{input}", "COMBINE\n{parts}", max_subtasks=5)

The difference from parallel sectioning is that the number of subtasks is not known in advance. The example ticket has three problems (billing, bug, login), so it plans three subtasks and uses 1 + 3 + 1 = 5 calls. A one-problem ticket uses 3 calls. That variable cost is why max_subtasks exists. A test checks that a ticket with twelve complaints is capped at four workers.

  • Use when the subtasks depend on the input in ways you cannot list in advance.
  • Fails by a bad plan (too many, duplicate or missing subtasks) and an unbounded fan-out. Cap it, and handle an empty plan (a test covers that).
For the curious A bug the first version had

When a worker failed, orchestrate dropped its result without a word and sent the final call only the successful parts. The combined reply then looked complete while one third of the ticket was ignored. Now the failure is returned in errors, and the final call sees [subtask 3 failed: ...] in place of the missing part, so the reply can say what it could not do. Rule: a partial answer must always say it is partial.

Check yourself

A ticket has two problems. How many calls does orchestrate use? (4: one to plan, two workers, one to combine.)