---
title: worker
---

<div class="python-reference">
<a id="fastvideo.entrypoints.streaming.worker-functions"></a>
<a id="fastvideo.entrypoints.streaming.worker"></a>
<p>Per-GPU worker subprocess entry for :class:<code>SubprocessGpuPool</code>.</p>
<p>The pool manages binding, lifecycle, and message dispatch in the parent
process. The worker constructs its :class:<code>VideoGenerator</code> from a typed
:class:<code>GeneratorConfig</code>, runs the two-segment warmup so both
initial-segment and continuation-branch compile graphs are hot, and
then loops on the job queue.</p>
<h2 id="fastvideo.entrypoints.streaming.worker.GeneratorConfig"><code>fastvideo.entrypoints.streaming.worker.GeneratorConfig</code></h2>
<pre class="doc-signature"><code>GeneratorConfig(model_path: str, revision: str | None = None, trust_remote_code: bool = False, engine: EngineConfig = EngineConfig(), pipeline: PipelineSelection = PipelineSelection())</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.GenerationRequest"><code>fastvideo.entrypoints.streaming.worker.GenerationRequest</code></h2>
<pre class="doc-signature"><code>GenerationRequest(prompt: str | list&#91;str&#93; | None = None, negative_prompt: str | None = None, inputs: InputConfig = InputConfig(), sampling: SamplingConfig = SamplingConfig(), runtime: RequestRuntimeConfig = RequestRuntimeConfig(), output: OutputConfig = OutputConfig(), stage_overrides: dict&#91;str, Any&#93; = dict(), state: ContinuationState | None = None, plan: GenerationPlan | None = None, extensions: dict&#91;str, Any&#93; = dict())</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.InputConfig"><code>fastvideo.entrypoints.streaming.worker.InputConfig</code></h2>
<pre class="doc-signature"><code>InputConfig(prompt_path: str | None = None, image_path: str | list&#91;str&#93; | None = None, video_path: str | list&#91;str&#93; | None = None, pose_video_path: str | list&#91;str&#93; | None = None, face_video_path: str | list&#91;str&#93; | None = None, background_video_path: str | list&#91;str&#93; | None = None, mask_video_path: str | list&#91;str&#93; | None = None, animate_mode: str | None = None, audio_path: str | list&#91;str&#93; | None = None, pil_image: Any | None = None, last_image: Any | None = None, references: list&#91;Any&#93; | None = None, latents: Any | None = None, audio_latents: Any | None = None, pose: str | None = None, mouse_cond: Any | None = None, keyboard_cond: Any | None = None, grid_sizes: Any | None = None, c2ws_plucker_emb: Any | None = None, action_path: str | None = None)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.OutputConfig"><code>fastvideo.entrypoints.streaming.worker.OutputConfig</code></h2>
<pre class="doc-signature"><code>OutputConfig(output_path: str = &#x27;outputs/&#x27;, output_video_name: str | None = None, save_video: bool = True, return_frames: bool = True, return_state: bool = False, *, return_samples: bool = False)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.SamplingConfig"><code>fastvideo.entrypoints.streaming.worker.SamplingConfig</code></h2>
<pre class="doc-signature"><code>SamplingConfig(num_videos_per_prompt: int = 1, seed: int = 1024, max_sequence_length: int | None = None, num_frames: int = 125, height: int = 720, width: int = 1280, height_sr: int = 1072, width_sr: int = 1920, fps: int = 24, audio_start_in_s: float | None = None, audio_end_in_s: float | None = None, num_inference_steps: int = 50, num_inference_steps_sr: int = 50, guidance_scale: float = 1.0, batch_cfg: bool = False, guidance_scale_2: float | None = None, guidance_rescale: float = 0.0, true_cfg_scale: float | None = None, use_embedded_guidance: bool | None = None, boundary_ratio: float | None = None, sigmas: list&#91;float&#93; | None = None, pyramid_num_inference_steps_list: list&#91;int&#93; | None = None, history_sizes: list&#91;int&#93; | None = None, num_latent_frames_per_chunk: int = 9, keep_first_frame: bool = True, is_skip_first_chunk: bool = False, use_zero_init: bool = True, zero_steps: int = 1, is_amplify_first_chunk: bool = False)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.WarmupConfig"><code>fastvideo.entrypoints.streaming.worker.WarmupConfig</code></h2>
<pre class="doc-signature"><code>WarmupConfig(enabled: bool = True, prompt: str = &#x27;A cinematic drone shot over coastal cliffs at sunrise, golden light, gentle ocean waves, ultra detailed&#x27;, timeout_seconds: int = 2400)</code></pre>


<h2 id="fastvideo.entrypoints.streaming.worker.init_logger"><code>fastvideo.entrypoints.streaming.worker.init_logger</code></h2>
<pre class="doc-signature"><code>init_logger(name: str) -&gt; _FastvideoLogger</code></pre>
<p>The main purpose of this function is to ensure that loggers are
retrieved in such a way that we can be sure the root fastvideo logger has
already been configured.</p>
<h2 id="fastvideo.entrypoints.streaming.worker.worker_main"><code>fastvideo.entrypoints.streaming.worker.worker_main</code></h2>
<pre class="doc-signature"><code>worker_main(*, gpu_id: int, worker_id: str, generator_config: GeneratorConfig, warmup_config: WarmupConfig, job_queue: mp.Queue, result_queue: mp.Queue, shutdown_event: Any) -&gt; None</code></pre>
<p>Per-worker subprocess entry.</p>
<p>Runs inside the child spawned by <code>SubprocessGpuPool</code>. Blocking
<code>VideoGenerator</code> construction + generation happens here, not in
the parent's event loop.</p>
<details><summary>Source</summary><pre><code>def worker_main(
    *,
    gpu_id: int,
    worker_id: str,
    generator_config: GeneratorConfig,
    warmup_config: WarmupConfig,
    job_queue: mp.Queue,
    result_queue: mp.Queue,
    shutdown_event: Any,
) -&gt; None:  # pragma: no cover - exercised via integration only
    &quot;&quot;&quot;Per-worker subprocess entry.

    Runs inside the child spawned by ``SubprocessGpuPool``. Blocking
    ``VideoGenerator`` construction + generation happens here, not in
    the parent&#x27;s event loop.
    &quot;&quot;&quot;
    import fastvideo.envs as envs

    envs.set_external(&quot;CUDA_VISIBLE_DEVICES&quot;, str(gpu_id))
    try:
        from fastvideo import VideoGenerator
        from fastvideo.worker.executor import reject_external_launcher

        reject_external_launcher(
            generator_config.engine.execution_backend,
            entrypoint=&quot;the streaming worker&quot;,
        )

        generator = VideoGenerator.from_pretrained(config=generator_config)
        if warmup_config.enabled:
            _warmup_worker(generator, warmup_config)
        result_queue.put(&#123;&quot;kind&quot;: &quot;ready&quot;, &quot;worker_id&quot;: worker_id&#125;)
    except Exception as exc:
        result_queue.put(&#123;&quot;kind&quot;: &quot;error&quot;, &quot;error&quot;: repr(exc)&#125;)
        return

    while not shutdown_event.is_set():
        try:
            item = job_queue.get(timeout=0.5)
        except queue.Empty:
            continue
        if item is None:
            break
        job_id = item&#91;&quot;job_id&quot;&#93;
        request = item&#91;&quot;request&quot;&#93;
        try:
            result = generator.generate(request)
            result_queue.put(&#123;
                &quot;kind&quot;: &quot;result&quot;,
                &quot;job_id&quot;: job_id,
                &quot;result&quot;: result,
            &#125;)
        except Exception as exc:
            result_queue.put(&#123;
                &quot;kind&quot;: &quot;error&quot;,
                &quot;job_id&quot;: job_id,
                &quot;error&quot;: repr(exc),
            &#125;)</code></pre></details>
</div>
