Resumable Pipeline Design for Batch Image Generation

    This article explains how to design a resumable pipeline for batch image generation by treating each visual asset as a stateful, trackable work unit instead of a single bulk request. It covers structuring a job ticket with explicit preserve and mutable constraints, layering quality across preview, editing, and delivery stages, splitting execution into independently rerunnable phases, and applying state machines, idempotent submission, and compensation for recoverability. It also shows how acceptance checks and result records turn vague feedback into traceable issues, along with practical engineering recommendations for stateless generation services and object storage.

    1. The Problem Is Not the Number of Images, but Missing Task State

    In batch visual scenarios such as product images, campaign creatives, and cover images, stakeholders often ask for something like “generate several images per product, then pick two for the campaign version.” If a developer translates this directly into one large batch generation request, the task may look complete on the surface but quickly descends into chaos: images lose their binding to product IDs, previews get mixed with final assets, it becomes unclear which elements must be preserved during revisions, and after a single failure no one knows whether to rerun the whole batch or compensate only the failed item.

    The root cause is not that the model parameters are too small. It is that the task was never modeled as a stateful, trackable, and recoverable work unit. Batch generation is only an execution action. What actually determines production readiness is task context, stage separation, quality strategy, and failure handling.

    2. Define the Job Ticket First: Encode What Can and Cannot Change

    Before entering the generation stage, create a structured job ticket for each visual unit. A job ticket is not just a saved prompt; it stores the full context. An example structure:

    1. {
    2. "job_id": "campaign-2026-spring",
    3. "asset_id": "sku-1042-cover",
    4. "stage": "preview",
    5. "model_family": "fast-image-model",
    6. "size": "1536x1024",
    7. "quality": "low",
    8. "prompt_version": "v3",
    9. "preserve": ["bottle proportions", "label position", "camera angle"],
    10. "mutable": ["background material", "accent flowers"],
    11. "status": "queued"
    12. }

    The most important design decision is splitting constraints into two categories: preserve lists items that must not be broken, and mutable lists items allowed to be explored. During local editing, the program can reassemble the prompt from these fields. When acceptance fails, you can tell whether the problem came from a wrong composition direction or a broken preserved item, instead of recording only “the image looks bad.”

    In addition, job_id aggregates one business campaign, asset_id locates a specific product or asset, stage distinguishes phases such as preview, editing, and delivery, prompt_version tracks prompt evolution, and status drives scheduling and compensation. Field names can change, but the three principles cannot be dropped: complete context, explicit constraints, and trackable status.

    3. Quality Tiering: Use Different Generation Strategies per Stage

    A common mistake in batch tasks is using the highest quality, largest size, and largest quantity during the exploration phase, which leads to slow feedback, high cost, and a large failure blast radius. A safer approach is quality tiering.

    The first tier is direction preview. The goal here is to quickly validate composition, color, whitespace, and subject placement, not final delivery quality. You can use a speed-oriented model tier with lower quality and smaller size, generating a small number of candidates to converge on a direction quickly.

    The second tier is precise editing. Once the direction is set, make local adjustments to preserved and mutable items. This stage should increase constraint precision and emphasize structural consistency and stable element positions, rather than continuing to expand the candidate count.

    The third tier is final delivery. Only after both preview and editing pass should the task enter high-resolution, high-quality output. If the work involves frame sequences or motion assets, create a separate frame-sequence task to ensure cross-frame consistency, instead of treating motion as an ordinary batch image task.

    The core benefit of this tiering is moving uncertainty forward into the low-cost exploration stage, and reserving high-cost output for after results are largely settled.

    4. Staged Execution: Preview, Editing, and Delivery Stay Independent

    The pipeline should be split into three stages that can be rerun independently.

    The preview stage only generates candidate directions. Every candidate binds to the same asset_id but carries a different candidate number. If this stage fails, you only rerun the current candidate without affecting other products.

    The editing stage takes candidates that passed preview and reconstructs the prompt based on preserve and mutable. If editing fails, keep the original preview result and mark the editing task as pending compensation, rather than falling back to a full batch rerun.

    The delivery stage only handles tasks that have passed acceptance. This stage should record final size, quality, output location, and validation results to form an auditable record. Any delivery failure should support single-point retry, because other tasks may already be complete at this point.

    The direct benefit of staging is a controllable failure blast radius, predictable rerun cost, and clear visibility for stakeholders into which stage a task is currently in.

    5. Recoverability Design: State Machine, Idempotency, and Compensation

    A resumable pipeline needs at least three capabilities.

    The first is a state machine. Task status should include at least queued, running, pending review, passed, and failed-pending-compensation. State transitions must be one-way and persisted, so state is not lost after a process restart.

    The second is idempotent submission. When the same asset_id is resubmitted in the same stage, it should hit an existing result or generate a new candidate number, rather than overwriting historical records. This way, network jitter or scheduler retries will not destroy existing artifacts.

    The third is a compensation mechanism. Failed tasks enter a compensation queue and are handled by blast radius: a single image failure compensates only that image, and only a batch-wide anomaly triggers a batch rerun. Compensation tasks should carry the original task context so preserved constraints are not lost.

    An example state transition:

    1. queued -> running -> review -> passed
    2. | |
    3. v v
    4. failed_retry delivered

    6. Acceptance and Records: Turn “The Image Looks Bad” into a Locatable Problem

    Acceptance cannot rely only on subjective human judgment. Split acceptance into two types of checks.

    One type is preserved-item checks, such as subject proportions, key element positions, and whether the viewpoint was broken. These checks determine whether the task needs to go back to the editing stage.

    The other type is direction checks, such as whether the composition matches expectations, whether whitespace is sufficient, and whether the style matches. These checks determine whether the task needs to go back to the preview stage.

    Every acceptance should write a result record, including task identifier, stage, prompt version, failure reason category, and handling action. During later reviews, you can then measure which prompt versions have higher failure rates and which stage sees the most rework, so you can continuously improve prompts and quality tier selection.

    7. Engineering Implementation Recommendations

    In practice, maintain the job ticket, state machine, and compensation queue on the business side, and integrate image generation as a stateless execution unit. The generation service only receives tasks and returns results; it does not carry business semantics. Artifacts should be written uniformly to object storage and indexed by task identifier, while logs and monitoring track queue time, failure rate, and stage duration.

    Also, avoid treating any “fastest latency” as a fixed commitment. Size, quality, and scenario differences vary widely, so engineering should set timeout and retry thresholds based on historical data rather than hardcoding a single value.

    Overall, the stability of batch image production does not come from generating more images in one shot. It comes from trackable tasks, separable stages, and compensable failures. Combining quality tiering with the job ticket model is what builds a truly resumable production pipeline.