10.3 Batch Inference & Bedrock Intelligent Prompt Routing
Key Takeaways
- Batch output ordering is not guaranteed, so correlate input and output with record IDs.
- Configured prompt routers choose exactly two supported models in the same family and use a fallback plus quality-difference criterion.
- Application routing remains necessary when policy, modality, residency, or tool support determines model eligibility.
10.3 Batch Inference & Bedrock Intelligent Prompt Routing
Batch inference and intelligent prompt routing solve different optimization problems. Batch moves noninteractive work into an asynchronous job. Prompt routing chooses between supported models for each interactive request. Neither feature removes the need to validate model support, IAM, quotas, output quality, or cost.
Batch inference workflow
Use batch inference for large offline workloads such as nightly classification, document summarization, synthetic-data generation, or evaluation preparation. The application writes request records to Amazon S3, submits a model invocation job with a service role, monitors job status, and reads output JSON Lines files from S3.
Each input line contains a modelInput object whose schema matches the selected invocation type. A recordId is useful for correlation; current Bedrock documentation says that if it is omitted, Bedrock adds one to the output. Output order is not guaranteed to match input order, so join by record ID rather than array position. If records reference S3 media, follow the model and input-folder rules exactly.
| Batch concern | Correct design response |
|---|---|
| Large input set | Split within current file, record, and job quotas; validate every JSONL line before submission |
| Sensitive S3 data | Restrict the job role to exact input/output prefixes and required KMS keys |
| Partial failures | Parse per-record results and retry only eligible failed records with idempotent IDs |
| Cost | Confirm that the selected model receives current batch pricing; AWS advertises lower batch pricing for select models |
| Completion time | Treat batch as asynchronous; do not use it for a user waiting on a response |
Batch inference has its own service quotas and supported-model table. This separation makes it suitable for offline load, but avoid claiming that a batch job can never affect any other workload. Design each path to its documented quotas and observe both.
Job lifecycle and error recovery
Validate the entire input folder before submission. Check JSONL syntax, unique record IDs, modelInput schema, referenced media paths, file sizes, record counts, and encryption access. The submitting identity needs permission to create and inspect jobs; the service role needs the exact S3 and KMS access required to perform them. These are different trust relationships.
Write outputs to a job-specific prefix. When the job completes, parse success and error records, verify expected record counts, and create a retry file containing only eligible failures. Preserve the original record ID and add an attempt identifier outside the model payload so downstream processing remains idempotent. Do not resubmit successful state-changing work.
Monitor queue time, run time, success rate, failure categories, tokens, output size, and cost. Set an operational deadline after which the workflow alerts or falls back; asynchronous does not mean unbounded. Lifecycle rules can archive or delete input and output only after audit and consumer requirements are satisfied.
Batch inference uses a selected model for the job. It is not intelligent prompt routing over each line. If records need different models, partition them through application logic or separate jobs and retain correlation across the workflow.
Data quality gates for batch
Run a preflight sample through the exact model and parser before submitting the full corpus. Validate not only job acceptance but downstream output schema, language, safety, and token size. A syntactically successful job can generate unusable business records at scale.
Partition sensitive and nonsensitive records when they require different roles, keys, retention, or output destinations. Keep each job's manifest and configuration so a result can be reproduced. If input data changes during a long job, decide whether the output represents the submission snapshot or must be invalidated.
Use a completion event or controlled poller to start downstream processing once. Duplicate job-completion notifications must be harmless. Verify counts and checksums before marking the business batch complete, and surface a partial-completion state rather than silently dropping failed records.
Batch security boundary
Block public access on input and output buckets, require transport encryption, use customer-managed keys when policy calls for them, and restrict the Bedrock service role with source-account and source-ARN conditions where supported. Review generated outputs for sensitive material before distributing them to a wider analytics bucket.
Keep model access explicit in the job role and review it when the batch model changes. A broad wildcard permission can make a future, more expensive or less appropriate model invokable without the evaluation and budget approval that the workflow requires.
A nightly job summarizes a large S3 corpus and no user is waiting for the result. Which Bedrock path best fits?