Durable execution around vLLM for large-scale data generation
Crash-safe coordination for model-driven pipelines on shared GPU clusters
Anirudh Srinivasan · Team Lead - Vision
Srihari Bandarupalli · Generative AI Engineer - Vision
What we do
We build sovereign vision foundation models
Patram: vision-language models for Indian documents, and the whole stack that builds them.
Evaluation
PatramBench · Patram-Eval
Serving infrastructure
Patram-Serve
Models
Patram Suite
Training infrastructure
Patram-Core
Training data generation
Patram-Ingest · this talk
Raw data collection
Patram-Scraper · Patram-Syn
Annotation & visualization
DarshinAI
Storage
Patram-FS · Patram-DB
Patram Suite
Multi-task foundation models
Patram series
Task-specific models
Patram-GrounderPatram-LayoutPatram-CoT
Agents
PatramParse
Scale
A foundation model needs data at this scale
100TB+of image data
100M+training examples
100B+tokens of model output
500+GPUs generating them
Day 1Week 1Week 2Week 3Week 4
one data-generation run
One data-generation run takes weeks, and must not stop.
Training data
What one training example looks like
The model learns from millions of examples like this one.
One training example, for this page
“What is the payment due date?”
“15 July 2015”
the box on the page that shows it
Made automatically, in a chain
Understandan electricity bill›Askwrite a question›Answerfrom the page›Verifymatches the page ✓
× 100 million+ pages, in 22+ languages.
0
Part zero
The problem
A run must go on for weeks. What gets in the way?
On a shared cluster
Three things that interrupt a weeks-long run
1
Nodes die and restart
The run has to recover on its own: notice, restart what died and continue, with nobody watching.
2
GPUs are lent out
GPUs are lent to other jobs for a while. When they return, the run has to use them again without a restart.
3
Work spans nodes
Complex workloads need pipeline parallelism: every step running at once, split across nodes.
Requirements
Three requirements for the engine
1
Keep the GPUs busy
The GPUs are the expensive part. They should never wait for anything.
2
Be crash safe
Nodes die, GPUs come and go. Every record is still written exactly once.
3
Any workflow, in little code
A new pipeline should take a few lines of code to define, and one command to run on every node.
1
Part one
Keeping the GPUs busy
The GPU is the expensive part. How do we keep it from waiting?
Where the time goes
The model run is one of three steps
CPU · before
Prepare
build the prompt read and check the image
→
GPU
Run the model
the only step the GPU does
→
CPU · after
Finish
parse and validate write to disk, record progress
One batch at a time
the GPU waits whenever the host is working
Overlapped
the host prepares the next batch and finishes the last one while the GPU works
The host work is unchanged. It now overlaps with GPU time.
The architecture
Inside one node
All of these run at the same time. Each needs the right kind of parallelism.
Background
Three kinds of concurrency in Python
Process
Separate programs
Truly parallel, even for Python code
A crash stays inside it
Heavier, and data is copied between them
Use forCPU-heavy work, anything that may crash, anything that owns a GPU
Thread
Helpers in one program
Easiest: they share memory, so a hand-off is just passing an object
One at a time in Python (the GIL)
A crash takes the whole program down
Use forwaiting on the disk, the network or the database
Event loop
One thread, many waits
Hundreds of calls in flight, almost free
No locks: one thing runs at a time
One slow step blocks every call
Use formany model calls at once
Rule of thumbcomputing → process
Rule of thumbwaiting → thread
Rule of thumbmany waits → event loop
Your turn
Which kind of parallelism for each piece?
Process?truly parallel, a crash stays inside
Thread?cheap helpers, good at waiting
Event loop?one thread, many calls in flight
Our choice
What we chose for each piece
Processesthe orchestrator, the pool, each worker: CPU work, crashes stay apart, one GPU each
Threadsprepare, collect, write, upload, dispatch, supervise: they mostly wait
Event loopinside each worker: many calls in flight at once
Load balancing
Sharing requests between workers
The simplest design: one shared queue that every worker pulls from.
Inside every pull
1Take the lock
2Pull one request
3Release the lock
Simple, and self-balancing: a fast worker pulls more often.
The lock is never released
A killed process runs no cleanup, so it never lets go. Every other worker waits forever.
pool statushealthy ✓throughput0
No error and no timeout. Throughput is zero.
What we changed
One inbox per worker
One dispatcher is the only reader of the shared queue. Each worker reads only its own inbox.
No shared lock
Only the dispatcher touches the shared queue, and it is a thread that does not get killed on its own.
A worker dies
It can only block its own inbox, which is thrown away. The dispatcher stops sending to it. The others keep working.
A replacement starts
The supervisor starts a new worker with a fresh inbox. Its unfinished requests are sent again.
No shared lock between processes that can be killed. Since this change, the pool has not hung.
What runs in a worker
A worker can call any backend
The pool, the inboxes and the crash handling are the same for all of them.
Hosted vLLM
Shared vLLM servers, called over HTTP. The node itself needs no GPU.
Hugging Face models
Any model loaded on this node’s own GPU.
CPU work
Rendering pages in a headless browser, image processing.
Vision models
SAM3, YOLO and other detectors and segmenters.
A backend is three functionsinit()·call(request)·terminate()
2
Part two
Crash safe
Any process can die at any moment. What happens next?
Many nodes
Coordinating across nodes, with minimal overhead
Each box is one image. A node claims a batch, and the boxes take its colour. If a node dies, its batch goes back.
Problems 1 and 2, revisited
Recovery and scaling without intervention
1
Recovery
A process or node dies. It is restarted, and its work is not lost.
1 · Recovery
Each layer is restarted by the layer around it
A worker dies→ the supervisor starts a new oneits requests are sent again
The program stops, or the node reboots→ the watcher starts it againits samples go back to the table
A vLLM server crashes→ its own watcher restarts itrequests go back to the queue
2
Scaling
GPUs come and go. The run adjusts without a restart.
2 · Scaling
Pipelines do not own model servers
One day of a production run · samples per second · illustrative shape
1Launched before the models were upwork starts as each server comes online
2A colleague borrows GPUsworkers there drain and wait
3The GPUs are returnedworkers fetch from the database again
4A server crashesits requests go back; it restarts
5More GPUs become freenew servers; the run spreads onto them
Errors
Every error is followed through
At this scale, something fails every minute. Each error is sorted into one of two kinds.
An error
The sample’s fault
Retrying will not help
corrupt imageimage too largeunreadable fileanswer never parses
Discard itmark it failed and record why
The system’s fault
The sample is fine
server crashedout of memoryprocess killednetwork blipserver asleep
Retry iton another node, or later
3
Part three
Graphs of stages
Each page takes its own path through many models. How do we describe such a workflow, and run it across nodes?
One example needs many models
One pipeline, a different route for every page
The full pipeline
The whole pipeline is one graph
Every page enters at the left. Each box is a model, a tool or a check. Three simple rules decide where a page goes and when a box may start.
1 · Routing After Understand, a small function looks at the page and picks the next box. A text page goes to two boxes at once.
2 · Needs both Grounded Q&A needs the text and the layout of the same page. It starts only when both have arrived.
3 · Either one is enough A page is a table or a chart, never both. So “Write a question” starts as soon as one arrives.
Every pipeline we run is built from these three rules. needs every input one input is enough
What our pipelines have in common
Three properties shared by all our pipelinesA dynamic DAG covers almost all our workloads
Graph
Declared once, in code
Each stage names its inputs. The engine works out the rest.
Acyclic
No loops
A retry is a bounded decision in a routing function, never a cycle.
Dynamic
Routes decided while it runs
Each sample’s path depends on what earlier stages found in it.
Chains, branches, merges and early exits are all special cases of one dynamic DAG.
How the engine runs a graph
Stages need a shared record of each page
Separate programs. Each stage runs as its own process, often on its own machine, and shares no memory with the others.
No messages. Stages also never talk to each other, so one stage cannot tell another that it has finished a page.
One record per page. The engine keeps it in the DB. Every stage reads it and writes to it, and that is how the graph is coordinated.
How the engine runs a graph
The record is one switch per stage
1 + 2 = 3stored in the DB as the single number 3
A seat number per stage. Every stage in the graph has a seat: its position, counted from 0. The record has one switch for each seat. They all start off.
A switch on means yes. Here the answer is yes for Understand and Text, and no for Layout and Grounded Q&A.
A row of switches is one number. Seat 0 is worth 1, seat 1 is worth 2, seat 2 is worth 4, and so on. Add up the switches that are on. This is called a bit mask.
How the engine runs a graph
Two rows per page: Finished and Ready
In the DB
pagefinishedready481201
One row per page that is still in flight. Two numbers, no more.
Once a page has finished its last stage, its row is deleted, so the DB never holds the whole dataset.
Finished. Which stages have finished this page. It fills up as the page moves through the graph.
Ready. Which stages may start on this page: it is now waiting in their queue.
A new page starts with nothing finished (0) and only Understand ready (1), because it is the first stage.
How the engine runs a graph
Following one page through the graph
The number is the row added up, with seats worth 1, 2, 4, 8. Ready stays on once switched on.
Last stage finished: the row is deleted
1 · A page arrives. Only Understand may start, so only its Ready switch is on.
2 · Understand finishes. Its routing function says this is a text page, so it goes to Text and Layout at once. Their Ready switches go on, then Understand’s Finished.
3 · Text finishes, on node 3. Grounded Q&A needs both Text and Layout, and Layout is not finished, so it waits.
4 · Layout finishes, on node 7, some minutes later. Both inputs of Grounded Q&A are now finished, but nobody has told it yet.
5 · The sweep notices. A background process reads the records every few seconds. It sees both inputs finished and switches Ready on for Grounded Q&A.
6 · Grounded Q&A finishes, the last stage. The page is done, and its row is deleted from the DB.
How the engine runs a graph
When the sweep lets a stage start
The sweep’s check. Each waiting stage has a row of the inputs it needs. Keep only those switches that are also on in Finished (third row). Here Layout is missing, so Grounded Q&A waits.
Layout has finished. Every needed switch is now on in Finished, so the third row matches the first. The stage may start.
Either one is enough. Write a question takes a table or a chart, never both. One needed switch on is enough, so it starts as soon as the chart is finished.
How the engine runs a graph
Ready makes a stage start exactly once
Sweep 1
Inputs finished?Not all of them.
Text ✓Layout
0Ready for Grounded Q&A
Wait
Sweep 2
Inputs finished?Yes, both.
Text ✓Layout ✓
1Ready is off, so switch it on
Start it
Sweep 3
Inputs finished?Yes, both.
Text ✓Layout ✓
1Ready is already on
Skip
Sweep 4, 5, 6 …
Inputs finished?Yes, both. This stays true.
Text ✓Layout ✓
1Ready is already on
Skip
Without the Ready switch, every sweep would match again:startstartstart…
The sweep runs again and again. At sweep 2 both inputs are finished, so it switches Ready on and the stage starts.
The inputs stay finished, so every later sweep matches too. But Ready is already on, so the sweep skips the stage.
Finished says the inputs are there. Ready remembers that the stage was started. Together they give exactly once.
How the engine runs a graph
A crash between writes never loses a page
Our orderwhen Understand finishes a page
1Put the page in the next stage’s queue
2Switch on Ready for that stage
⚡ crash
3Switch on its own Finished
The page survives ✓Finished is still off, so after the restart the page is run again. Repeating a write changes nothing: the queue row and the switch are already there.
The reverse ordershown for comparison
1Switch on its own Finished
⚡ crash
2Put the page in the next stage’s queue
3Switch on Ready for that stage
The page is lost ✕The record says Finished, so nobody runs the page again, and the next stage was never given it.
Three writes to the DB hand a page on. A machine can crash between any two of them, so the order matters.
Crash in the middle. Left: the page is handed on, and Finished is still off. Right: Finished is on, but the page was never handed on.
Hand the page on first, mark yourself finished last, and make every write safe to repeat.
The database holds only state. Results go to files, written in groups.
Above all
The DB is the single source of truth
Any component can restartAny component can crash and restart. It held nothing, so it lost nothing.
Nodes can be added or removedNo handover, nothing to move. A new node just asks the DB for work.
Recovery is a DB queryThe state of the run is always in the DB. There is no recovery procedure to run.
Context
Where Patram-Ingest sits in the stack
Evaluation
PatramBench · Patram-Eval
Serving infrastructure
Patram-Serve
Models
Patram Suite
Training infrastructure
Patram-Core
Training data generation
Patram-Ingest · this talk
Raw data collection
Patram-Scraper · Patram-Syn
Annotation & visualization
DarshinAI
Storage
Patram-FS · Patram-DB
This talkPatram-Ingestturns raw pages into training data, on a shared cluster, for weeks at a time.
Below itStorage and raw dataPatram-FS and Patram-DB hold everything. The scraper and Patram-Syn feed it; DarshinAI lets us annotate and look at it.
Above itFrom corpus to modelsPatram-Core turns that data into our training corpus, and trains the Patram Suite of foundation models. Patram-Serve, our serving infrastructure, sits above the models.
In summary
Describe the pipeline. The engine keeps it busy, crash-safe and scalable.