> For the complete documentation index, see [llms.txt](https://world-models-from-scratch.gitbook.io/wmfs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://world-models-from-scratch.gitbook.io/wmfs/chapters/chapter_02/04-load-and-generate.md).

# 2.4 Load the Model and Generate a Rollout

Readers with the GPU setup can generate the rollout below. The included figure and explorer show the result without requiring local generation.

## Load the Pipeline

Load Cosmos-Predict2.5-2B through Diffusers:

```python
import torch
from diffusers import Cosmos2_5_PredictBasePipeline

from world_models.backends.cosmos import (
    CHECKPOINTS,
    CosmosBackend,
    apply_guardrail_compatibility_patch,
)
from world_models.engine import RolloutEngine

spec = CHECKPOINTS["cosmos-predict2.5-2b-720p"]
apply_guardrail_compatibility_patch()

pipeline = Cosmos2_5_PredictBasePipeline.from_pretrained(
    spec.repo_id,
    revision=spec.revision,
    torch_dtype=torch.bfloat16,
).to("cuda")

engine = RolloutEngine(CosmosBackend(pipeline, spec))
```

`CosmosBackend` adapts the Diffusers pipeline to the frame format used in this chapter. `RolloutEngine` provides the generation interface used below.

## Generate One Future

Use the five-frame `context` prepared in Section 2.3:

```python
prompt = (
    "an aerial view of a sand mining operation; "
    "the machinery keeps moving and the water keeps flowing"
)

future = engine.generate(
    context,
    prompt=prompt,
    seed=0,
    num_frames=29,
    guidance_scale=7.0,
    num_inference_steps=15,
)

print(future.frames.shape)
```

The output is:

```
(29, 704, 1280, 3)
```

This rollout took about two minutes on the NVIDIA A40.

![](/files/1EtwvyLyLe1qcamnXG27)

*Figure 2.1: Six generated frames sampled in temporal order from the first rollout.*

[Open the first rollout in a new tab](https://nahidalam.github.io/world_model_from_scratch/interactive/chapter_02/rollout_explorer.html#observation).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://world-models-from-scratch.gitbook.io/wmfs/chapters/chapter_02/04-load-and-generate.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
