Cette page est affichée en anglais. Une traduction française est en cours.
WorkflowsMay 7, 2026·3 min de lecture

Modal Volumes — Persistent Storage for AI Workloads

Modal Volumes are content-addressed persistent storage for Modal. Mount as a Linux filesystem, share across runs, version with .commit().

Modal
Modal · Community
Prêt pour agents

Cet actif peut être lu et installé directement par les agents

TokRepo expose une commande CLI universelle, un contrat d'installation, le metadata JSON, un plan selon l'adaptateur et le contenu raw pour aider les agents à juger l'adaptation, le risque et les prochaines actions.

Native · 98/100Policy : autoriser
Surface agent
Tout agent MCP/CLI
Type
Skill
Installation
Single
Confiance
Confiance : New
Point d'entrée
Asset
Commande CLI universelle
npx tokrepo install af427a6d-eecc-4a38-ade8-69caf6274e0b
Introduction

Modal Volumes give your Modal Functions and Sandboxes persistent storage that survives across runs. Mount as a regular Linux filesystem, share between Functions and Sandboxes, version checkpoints with .commit(). Best for: caching pip packages and model weights, ML training datasets, agent workspaces that span multiple runs. Works with: Modal SDK. Setup time: 1 minute.


Create + mount

import modal

app = modal.App("ml-pipeline")
volume = modal.Volume.from_name("model-cache", create_if_missing=True)

@app.function(volumes={"/cache": volume})
def download_model():
    import huggingface_hub
    huggingface_hub.snapshot_download(
        "meta-llama/Llama-3-8B",
        cache_dir="/cache",
    )
    volume.commit()  # checkpoint to durable storage

Cache pip packages across runs

pip_cache = modal.Volume.from_name("pip-cache", create_if_missing=True)

image = modal.Image.debian_slim().run_commands(
    "pip install --target=/pip-cache transformers torch",
).env({"PYTHONPATH": "/pip-cache"})

@app.function(image=image, volumes={"/pip-cache": pip_cache})
def train(): ...

Cold starts drop from minutes to seconds because packages are already on the volume.

Share data between Function and Sandbox

data_vol = modal.Volume.from_name("ingest", create_if_missing=True)

@app.function(volumes={"/data": data_vol})
def ingest():
    download_csv_files("/data/raw/")
    data_vol.commit()

@app.function(volumes={"/data": data_vol})
def analyze():
    data_vol.reload()  # pick up the latest committed snapshot
    return run_analysis("/data/raw/")

Use as agent workspace

workspace = modal.Volume.from_name("agent-runs", create_if_missing=True)

# Each agent run gets its own subdirectory
sb = modal.Sandbox.create(
    image=image,
    volumes={"/work": workspace},
    workdir="/work/run-{run_id}",
)

sb.exec("python", "agent.py")
workspace.commit()  # save the work

Later runs read the workspace history; the agent has long-term memory across sessions.


FAQ

Q: How is Volume different from S3? A: Volumes mount as a Linux filesystem (no S3 API translation). Faster random reads, integrated with Modal's image cache. For purely archival or external access, S3 is still the right choice.

Q: Are Volumes versioned? A: Yes — every .commit() creates a new version. You can read prior versions with volume.reload(commit_id=...). Useful for rollbacks and reproducibility.

Q: How big can a Volume be? A: Practically unlimited. The hot tier is fast (NVMe-class); colder data is offloaded transparently. You're billed for storage used, but the limit isn't hard.


Quick Use

  1. pip install modal
  2. volume = modal.Volume.from_name("my-vol", create_if_missing=True)
  3. Mount in any Function or Sandbox via volumes={"/path": volume}, call .commit() to checkpoint

Intro

Modal Volumes give your Modal Functions and Sandboxes persistent storage that survives across runs. Mount as a regular Linux filesystem, share between Functions and Sandboxes, version checkpoints with .commit(). Best for: caching pip packages and model weights, ML training datasets, agent workspaces that span multiple runs. Works with: Modal SDK. Setup time: 1 minute.


Create + mount

import modal

app = modal.App("ml-pipeline")
volume = modal.Volume.from_name("model-cache", create_if_missing=True)

@app.function(volumes={"/cache": volume})
def download_model():
    import huggingface_hub
    huggingface_hub.snapshot_download(
        "meta-llama/Llama-3-8B",
        cache_dir="/cache",
    )
    volume.commit()  # checkpoint to durable storage

Cache pip packages across runs

pip_cache = modal.Volume.from_name("pip-cache", create_if_missing=True)

image = modal.Image.debian_slim().run_commands(
    "pip install --target=/pip-cache transformers torch",
).env({"PYTHONPATH": "/pip-cache"})

@app.function(image=image, volumes={"/pip-cache": pip_cache})
def train(): ...

Cold starts drop from minutes to seconds because packages are already on the volume.

Share data between Function and Sandbox

data_vol = modal.Volume.from_name("ingest", create_if_missing=True)

@app.function(volumes={"/data": data_vol})
def ingest():
    download_csv_files("/data/raw/")
    data_vol.commit()

@app.function(volumes={"/data": data_vol})
def analyze():
    data_vol.reload()  # pick up the latest committed snapshot
    return run_analysis("/data/raw/")

Use as agent workspace

workspace = modal.Volume.from_name("agent-runs", create_if_missing=True)

# Each agent run gets its own subdirectory
sb = modal.Sandbox.create(
    image=image,
    volumes={"/work": workspace},
    workdir="/work/run-{run_id}",
)

sb.exec("python", "agent.py")
workspace.commit()  # save the work

Later runs read the workspace history; the agent has long-term memory across sessions.


FAQ

Q: How is Volume different from S3? A: Volumes mount as a Linux filesystem (no S3 API translation). Faster random reads, integrated with Modal's image cache. For purely archival or external access, S3 is still the right choice.

Q: Are Volumes versioned? A: Yes — every .commit() creates a new version. You can read prior versions with volume.reload(commit_id=...). Useful for rollbacks and reproducibility.

Q: How big can a Volume be? A: Practically unlimited. The hot tier is fast (NVMe-class); colder data is offloaded transparently. You're billed for storage used, but the limit isn't hard.


Source & Thanks

Built by Modal. Commercial product with free tier.

modal.com/docs — Volumes documentation

🙏

Source et remerciements

Built by Modal. Commercial product with free tier.

modal.com/docs — Volumes documentation

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires