Run an overnight batch locally when the entire pipeline finishes before the deadline with time left for retries and review. For 12,000 rows in eight hours, you need 12,000 / 480 = 25 accepted rows per minute; reserving one hour raises the working target to 12,000 / 420 = 28.57.
Convert the deadline into an end-to-end throughput target
A generation benchmark excludes several things your batch must do: read records, extract text, assemble prompts, wait for inference, validate answers and save results. Benchmark that complete path. Count a row as finished only after its accepted result is durable. Include validation and durable writes in the morning deadline.
| Illustrative accepted throughput | Time for 12,000 rows | Eight-hour outcome |
|---|---|---|
| 15 rows/minute | 12,000 / 15 = 800 minutes | 13 hours 20 minutes: misses |
| 25 rows/minute | 12,000 / 25 = 480 minutes | Exactly eight hours: no reserve |
| 30 rows/minute | 12,000 / 30 = 400 minutes | Six hours 40 minutes: 80 minutes left |
Use a realistic mix of short, long and difficult rows. If the last tenth contains all the longest documents, the first hour's average is a misleading forecast. Sort or bucket work by estimated size for scheduling, but retain original row IDs so outputs can be restored to their source order.
Measure local concurrency separately. On one local GPU, workers share its throughput, and rows beyond its active capacity wait in line. Watch whether accepted rows per minute improve and whether memory pressure creates failures. Use the shared-throughput guide to tune the serving layer before scheduling an important night.
Make every row restartable before adding workers
Assign each input a stable ID and a content hash. Store the model artifact, prompt version and validation version in a run manifest. A row ID alone is insufficient if the row's text changes tomorrow. A practical result key combines the source ID, input hash and run configuration hash.
Keep durable states such as pending, running, succeeded and failed. A running claim needs an expiry time so another worker can recover it after a crash. Commit the validated result and succeeded status together. If you later publish results into another system, use a separate durable delivery record and make that write idempotent.
CREATE TABLE results (
job_id TEXT PRIMARY KEY,
input_hash TEXT NOT NULL,
config_hash TEXT NOT NULL,
answer_json TEXT NOT NULL,
accepted_at TEXT NOT NULL
);
Pair this result table with the claim and recovery states described above. For a small single-machine coordinator, Python's sqlite3 provides transactions. In Python 3.12 or later, use an explicit transaction policy, then commit a validated result with parameter binding:
import sqlite3
connection = sqlite3.connect("batch.sqlite", autocommit=False)
try:
with connection:
connection.execute(
"INSERT INTO results VALUES (?, ?, ?, ?, ?)",
(job_id, input_hash, config_hash, answer_json, accepted_at),
)
finally:
connection.close()
The variables come from your worker after validation, and the table must already exist. Reconcile a duplicate primary key with the stored hashes before deciding whether to reuse its result. Python's connection context manager commits on success and rolls back on an exception; closing is a separate operation. Keep inference outside the database transaction so a slow model does not hold a write transaction open.
Bound retries and retain useful timing evidence
Separate transport errors from bad answers. A temporary connection failure can be retried with a delay. Missing required facts may need review or a different prompt, and repeatedly sending the same impossible extraction wastes the night. Set an explicit attempt limit, such as three total attempts per row, and place exhausted rows in a review list.
For a local Ollama baseline, replace the model value below with an installed model name. The generate endpoint supports stream: false for a complete response object:
curl -fsS http://localhost:11434/api/generate \
-H 'Content-Type: application/json' \
-d '{"model":"YOUR_INSTALLED_MODEL","stream":false,
"prompt":"Classify this fictional request as billing or technical: I need a receipt."}'
Save application elapsed time beside Ollama's total_duration, load_duration, prompt_eval_count, prompt_eval_duration, eval_count and eval_duration. Durations are nanoseconds. Decode speed is eval_count / eval_duration * 1000000000; use application elapsed time for the complete pipeline and queue wait.
Do not mark a row successful merely because HTTP succeeded. Validate allowed labels, required fields and source agreement. Preserve enough error detail to diagnose failures without duplicating entire sensitive documents into routine logs.
Try it on your workload
Start with 200 representative rows and known expected outputs. Run reading, preprocessing, inference, validation and durable writes together. Interrupt the coordinator after some results commit, then restart it. Confirm completed rows are skipped, expired claims recover, and no source row appears twice in the final export.
Repeat at one, two and four workers. Record accepted rows per minute, retries, longest row duration and energy if ownership cost matters. Project the 12,000-row runtime using the slowest representative interval, not the fastest burst. On macOS or Linux, also verify that your overnight host stays awake under its configured power policy.
For a local worker-pool capacity estimate, suppose a measured trial averages two seconds per row at ten active requests; its ideal capacity is 10 × 60 / 2 = 300 rows per minute and 12,000 / 300 = 40 minutes. Revise this planning calculation using measured errors and retry delays, then compare approved hosted work with the same bounded worker pool.
How to decide
- Use local overnight capacity when the complete run passes quality checks and leaves a recovery margin.
- Fix restartability before scaling: extra workers multiply mistakes as readily as useful output.
- Rent approved overflow when the remaining local work cannot meet the deadline.
Fan out 12,000 rows for about 89 cents
Twelve parallel workers processing 12,000 rows on qwen/qwen3.6-35b-a3b cost about 89 cents in tokens on TrustedRouter for one pass. On 2026-11-22, the live catalog listed approximately $0.0422 per million input and $0.317 per million output tokens. Assign 1,000 rows to each worker, with 1,000 input and 100 output tokens per row. Totals are 12 × 1,000 × 1,000 = 12 million input and 12 × 1,000 × 100 = 1.2 million output. Cost = 12 × $0.0422 + 1.2 × $0.317 = $0.8868, about 89 cents; budget retries separately.
On one local GPU, those workers share throughput, and requests beyond its parallel capacity wait in line; through a per-token API, independent rows can run at the same time for the same token bill as serial execution. Preserve stable IDs and validation rules across workers. This uses ordinary API calls at catalog rates.
Prices change; check the catalog, API setup, agent setup and private API options. Local remains the right destination for rows that must stay offline, even when their deadline requires an earlier start.
Sources
- Ollama generate API: response shape and timing fields
- Python sqlite3: transactions, parameter binding and connection handling
- TrustedRouter live model catalog