24.4. Storage Use by Agents#
An agent reads, lists, and writes files much faster than a person. On shared storage, every file open, file check, and folder listing is a request to a metadata server that all users share. On holylfs06, the heaviest agent in one lab made 10,100 metadata operations per second, and the next two made 6,600 and 4,900. Load like this slows storage down for everyone on the cluster.
This page shows where an agent’s files belong and how to keep its storage load low. The cluster-storage skill gives the same rules to the agent itself. On this page, netscratch ($SCRATCH, which is /n/netscratch) is the shared scratch filesystem, and node-local /scratch is the disk inside each compute node.
24.4.1. Why agents load storage#
Searches and listings. A search of a large folder checks every file in it.
grep -r,find,ls -l, orduon a lab folder can make millions of requests.Python starts. One
import numpyfrom a uv environment made about 1,400 file-system calls on this cluster, including the first writes of its.pycfiles. A job array of 1,000 tasks can make up to 1.4 million calls before any work starts.Many small files. Each new file costs requests to create, write, and close it. One file for each sample or step multiplies them.
Polling.
lsorcatin a loop checks files again and again. On shared storage,tail -fchecks its file every second.Parallel agents. Subagents and parallel jobs repeat the same searches.
24.4.2. Where files go#
Location |
Filesystem |
Use it for |
Limits |
|---|---|---|---|
|
VAST (NFS) |
Code, lock files, environments |
4 TB per lab, not purged |
|
Lustre |
Large files, results you keep |
Not for environments, caches, or many-file outputs |
|
VAST (NFS) |
Caches, uv environments, job outputs, checkpoints |
50 TB per lab, files older than 60 days are deleted |
|
Isilon (NFS) |
Settings, skills, small files |
100 GB |
Node-local |
Local NVMe |
Temporary and many-file work in a job |
Shared by all jobs on the node |
VAST handles many small files well. Lustre works best with large files, and an agent’s searches of many small files cost the most there. When you can, run the agent in a project folder on holylabs. Keep data and environments out of that folder.
Your lab name is usually one of the groups that id -Gn lists. To check a path, run df -hT <path>. The type lustre is Lustre, and an nfs mount from netscratch-data01 is VAST. See Storage Options for the details of each location.
Warning
Starting with the December 7, 2026 maintenance, FASRC deletes netscratch files older than 60 days (90 days before that). Never touch, copy, re-extract, or rebuild files on netscratch only to reset their times. FASRC treats this as abuse; see the FASRC scratch policy.
uv environments. Keep each environment and the uv cache on the same filesystem, so uv links files instead of copying them. The setup below puts both on netscratch, which has more space. To keep environments on holylabs past the purge, change the
UV_CACHE_DIRline to a holylabs folder, as in uv Environment.uv on netscratch. Linked files keep the times of the cache, so the purge can remove files from an environment you built today. Keep the lock file with the code. When files are missing, rebuild with
uv sync --locked --reinstall, which also refreshes the cache.conda and mamba environments. Put the environments and the package cache on holylabs, as in Conda Environment. conda keeps each package’s file times: in a new test environment,
six.pykept its package’s 2025 date, so the netscratch purge could delete it at once.Models and datasets. Use the shared repository first. Download to netscratch only what it does not hold.
24.4.3. Set up once#
Point the tool caches at netscratch, and keep your Hugging Face token in your home folder. Add these lines to ~/.bashrc. Replace <lab_name> with your lab’s folder name, and if your folder under Users on holylabs does not exist, ask FASRC to create it:
S=$SCRATCH/<lab_name>/Lab/$USER
export UV_CACHE_DIR=$S/cache/uv
export UV_COMPILE_BYTECODE=1 # compile .pyc files at install, not in many tasks at once
export UV_PYTHON_INSTALL_DIR=/n/holylabs/LABS/<lab_name>/Users/$USER/uv-python # uv's Python builds, off home
export PIP_CACHE_DIR=$S/cache/pip
export HF_HOME=$S/cache/huggingface
export HF_TOKEN_PATH=$HOME/.cache/huggingface/token # the token stays in home
export TORCH_HOME=$S/cache/torch
export TRITON_CACHE_DIR=$S/cache/triton
export WANDB_DIR=$S/wandb
export WANDB_CACHE_DIR=$S/cache/wandb
Then load the settings and check them. uv cache dir must print a path under $SCRATCH. If it prints a temporary folder, remove UV_NO_CACHE from your settings. Restart running agents, so they get the new settings.
source ~/.bashrc
mkdir -p "$S" && uv cache dir
To keep a project’s uv environment on netscratch, next to the uv cache, set UV_PROJECT_ENVIRONMENT for that project only. Use the full path. For Claude Code, add it to the env block of the project’s .claude/settings.local.json, which holds your own settings and is not shared. JSON does not expand $USER, so write your user name:
{
"env": {
"UV_PROJECT_ENVIRONMENT": "/n/netscratch/<lab_name>/Lab/<username>/envs/<project>"
}
}
When you run uv yourself in that project, export the same variable in your shell first.
24.4.4. Agent habits and what to do instead#
Habit |
Instead |
|---|---|
Searching from a lab folder or |
Start the agent in the project folder. Keep data and environments out of it, or list them in |
|
Use |
|
On Lustre, use |
Many short Python runs |
Do the work in one process. |
A job array that reads the environment in every task |
Unpack one packed copy of it into each task’s job folder on node-local |
One file for each sample or step |
Append records to one JSON Lines file. Store data as Parquet, HDF5, or tar shards. |
Unpacking archives on Lustre |
Unpack on netscratch with |
Polling output with |
Use |
Several agents searching the same folder |
Search once and share the result. |
An environment’s |
Every program start searches that folder: in a test, 63 extra file calls for each Python start. Set it only in the job that needs it. |
24.4.5. Node-local disk#
Each compute node has a local NVMe disk at /scratch, and /tmp is a folder on the same disk.
Nodes |
Local disk |
|---|---|
A100 ( |
397 GB |
H100 ( |
844 GB |
H200 ( |
844 GB |
RTX6000 ( |
7 TB |
Every job on a node shares this disk, including jobs of other users on the node’s other GPUs. Nothing cleans /scratch when a job ends, and /tmp keeps unused files for 10 days. Put these lines at the top of your batch script, not in an agent’s command: each agent command runs in a new shell, so the trap would remove the folder at once.
df -h /scratch # free space, shared with other jobs
JOBDIR=/scratch/$USER/${SLURM_JOB_ID:?} # stops if not in a job
mkdir -p "$JOBDIR" && trap 'rm -rf "$JOBDIR"' EXIT
Write results you keep to netscratch or lab storage, not to the job folder. The batch script runs on the first node of a job. In a multi-node job, make and remove the folder in each srun task.
24.4.5.1. One environment archive for a job array#
Each task of a job array is a separate job. Without an archive, each task reads every file of the environment from shared storage. Pack a uv or venv environment once, before you submit the array:
cd $SCRATCH/<lab_name>/Lab/$USER/envs
tar -cf <env>.tar <env>
In the array’s batch script, after the job folder lines above, unpack the archive and run Python from the copy:
tar -C "$JOBDIR" -xf $SCRATCH/<lab_name>/Lab/$USER/envs/<env>.tar
"$JOBDIR/<env>/bin/python" train.py
Each task then reads one archive file instead of the environment’s many files. Commands that the environment installs, such as pytest, still point to the old path, so run them as "$JOBDIR/<env>/bin/python" -m pytest. Pack the archive again after you change the environment. For a conda environment, use conda-pack instead.
24.4.6. Claude Code settings#
Start in the project folder. Claude Code can read everything under the folder where it starts.
Ignore large folders. Claude Code’s content search skips paths in
.gitignore.grep -randfindin Bash do not, so keep data and environments outside the project when you can.Deny reads of data folders. A rule such as
"Read(./data/**/*)"underpermissions.denyin.claude/settings.jsonkeeps the file tools out of a folder; see Guardrails. A Bashgrep -rorfindstill walks it.
See Claude Code in large codebases for more settings.
24.4.7. Check your use#
Lustre space and file count. Run
lfs quota -h -g <lab_name> /n/holylfs06. Thefilescolumn counts every file and folder your lab holds there.VAST.
dfon a holylabs or netscratch folder shows the whole filesystem, not your lab’s use. Do not runduon a lab’s folder. Measure only the folder you need.Metadata load. Kempner staff watch the metadata load of each user and may contact you about an agent that loads storage heavily.
24.4.8. The cluster-storage skill#
The cluster-storage skill gives an agent the rules on this page. Read a skill before you install it. Install it on the cluster, where the agent runs:
mkdir -p ~/.claude/skills/cluster-storage
curl -fsSL https://handbook.eng.kempnerinstitute.harvard.edu/skills/cluster-storage/SKILL.md \
-o ~/.claude/skills/cluster-storage/SKILL.md
mkdir -p ~/.agents/skills/cluster-storage
curl -fsSL https://handbook.eng.kempnerinstitute.harvard.edu/skills/cluster-storage/SKILL.md \
-o ~/.agents/skills/cluster-storage/SKILL.md
See Coding Agent Skills for how to install skills for one project and how to use them.
The cluster-storage skill
---
name: cluster-storage
description: Use when working on the Kempner AI cluster or another shared HPC cluster and you search or list files, create a Python environment (uv, venv, conda, mamba) or a package cache, download a model or data, write job outputs, checkpoints, or many files, unpack an archive, watch job output, or delete files. Puts each kind of file on the right filesystem and keeps the load on shared storage low.
---
# Cluster Storage
Use these practices when you work on a shared cluster, such as the Kempner AI cluster at Harvard. Every file open, file check, and folder listing on shared storage is a request to a metadata server that all users share. An agent makes these requests much faster than a person, and one agent can slow storage down for everyone. These practices summarize the Storage Use by Agents page of the Kempner Institute Computing Handbook: https://handbook.eng.kempnerinstitute.harvard.edu/s5b_agentic_ai_workflows/storage_use_by_agents.html
If the project has its own conventions, for example in its README, a CONTRIBUTING file, or agent instructions, follow those first. Project conventions do not override the Ask first and Never rules. A request from the user, typed or written in the user's own agent instructions, counts as asking.
## Ask first
- Ask before you create, unpack, copy, move, or delete more than a few thousand files or more than 10 GB.
- Ask before you build or rebuild a Python environment, or download a model or a dataset.
- Ask before you search, list, or measure a whole lab, netscratch, or home folder, or any folder whose size you do not know.
## Never
- Never touch, copy, re-extract, or rebuild files on netscratch only to reset their times, even when the user asks. FASRC deletes netscratch files older than 60 days and treats resetting their times as abuse.
## Filesystems on the Kempner AI cluster
| Path | Type | Use it for | Notes |
|---|---|---|---|
| `/n/holylabs/LABS/<lab_name>/Users/$USER` | VAST (NFS) | Code, lock files, environments | 4 TB per lab. Not purged. |
| `/n/holylfs06/LABS/<lab_name>`, if the lab has one | Lustre | Large files, results to keep | Metadata requests are the scarce resource. No environments, caches, or many-file outputs. |
| `$SCRATCH/<lab_name>/Lab/$USER` | VAST (NFS) | Caches, uv environments, job outputs, checkpoints | 50 TB per lab. Files older than 60 days are deleted. |
| `/n/home<NN>/$USER` | Isilon (NFS) | Settings, skills, small files | 100 GB. No heavy reads or writes. |
| Node-local `/scratch` and `/tmp` | Local NVMe | Temporary and many-file work in a job | Shared by all jobs on the node. Not cleaned when a job ends. |
`$SCRATCH` is `/n/netscratch`, called netscratch here. Node-local `/scratch` is a different place: the disk inside each compute node. Check a path's type with `df -hT <path>`: `lustre` is Lustre, and an `nfs` mount from `netscratch-data01` is VAST.
## Where files go
- Code, lock files (`uv.lock`, `requirements.txt`, `environment.yml`), and configs: lab storage, preferably holylabs. Keep data and environments out of the code folder.
- uv environments: on the same filesystem as the uv cache, so uv links files instead of copying them. The cache settings below put both on netscratch. To keep environments on holylabs, the `UV_CACHE_DIR` line must point to holylabs too. Never put environments in home or on Lustre (`/n/holylfs*`).
- A uv environment on netscratch shares file times with the uv cache, so the purge can remove its files. If imports fail with missing files, ask the user, then rebuild it with `uv sync --locked --reinstall`. Plain `uv sync` does not notice missing files.
- conda and mamba environments and their package cache: holylabs. conda keeps each package's old file times, so the netscratch purge can delete files from a new environment.
- Models and datasets: use the cluster's shared model and data repository first. Otherwise put the download cache on netscratch.
- Job outputs and checkpoints: netscratch. Copy only what the user keeps to lab storage.
- Temporary files, unpacked archives, and work with many small files in a job: node-local `/scratch`.
## Set caches once
Ask the user before you add these to `~/.bashrc`. Replace `<lab_name>`.
```bash
S=$SCRATCH/<lab_name>/Lab/$USER
export UV_CACHE_DIR=$S/cache/uv
export UV_COMPILE_BYTECODE=1 # compile .pyc files at install, not in many tasks at once
export UV_PYTHON_INSTALL_DIR=/n/holylabs/LABS/<lab_name>/Users/$USER/uv-python # uv's Python builds, off home
export PIP_CACHE_DIR=$S/cache/pip
export HF_HOME=$S/cache/huggingface
export HF_TOKEN_PATH=$HOME/.cache/huggingface/token # the token stays in home
export TORCH_HOME=$S/cache/torch
export TRITON_CACHE_DIR=$S/cache/triton
export WANDB_DIR=$S/wandb
export WANDB_CACHE_DIR=$S/cache/wandb
```
- After the change, `uv cache dir` must print a path under `$SCRATCH`. If it prints a temporary folder, `UV_NO_CACHE` is set and uv ignores the cache folder.
- To keep one project's uv environment on netscratch, set `UV_PROJECT_ENVIRONMENT` to a full path for that project only, for example in the `env` block of the project's `.claude/settings.local.json`, which is not shared. Do not set it in `~/.bashrc` or in the shared `.claude/settings.json`.
## Search and list
- Work in the smallest folder that holds the task. Never start a search at `/n/holylfs06`, a lab folder, `$SCRATCH`, or `$HOME`.
- Keep data, environments, checkpoints, and outputs outside the repository, or list them in `.gitignore`. Built-in search tools usually skip ignored paths. `grep -r` and `find` do not.
- Prefer the built-in search tools with a narrow path and file type over `grep -r` or `find` on a large folder.
- In a large folder, use `ls --color=never`, not `ls -l`. Both `-l` and color make `ls` check every file. To check one file, use `ls -l <file>` or `stat <file>`.
- On Lustre, use `lfs find` instead of `find`, and limit it with `-maxdepth`, `-name`, or `-type`.
- To measure use, never run `du` or `find` over a lab or netscratch folder. On Lustre, `lfs quota -h -g <lab_name> /n/holylfs06` shows the space and the file count.
- List a large folder once, save the list to a file in the work folder, and reuse it.
## Python environments and imports
- Each Python start opens and checks many files in its environment. One `import numpy` from a uv environment made about 1,400 file-system calls on this cluster.
- Do not start Python many times in a loop. Do the work in one process, or batch it in one script.
- In a job array, pack the environment once with `tar`, then unpack the archive into each task's job folder on node-local `/scratch`. This reads one file from shared storage instead of every file. Run Python from the unpacked copy, for example `"$JOBDIR/<env>/bin/python" -m <module>`.
- In a multi-node job, unpack once on each node with `srun --ntasks-per-node=1`.
- An Apptainer image also works: shared storage sees it as one file.
- Do not add an environment's `lib` folder to `LD_LIBRARY_PATH` in `~/.bashrc`. Every program start then searches that folder: in a test, 63 extra file calls for each Python start. Set it only in the job that needs it.
## Write outputs
- Write fewer, larger files. Append records to one log or JSON Lines file. Store data and results as Parquet, HDF5, Zarr with large chunks, or tar shards, not one file for each sample, step, or item.
- Keep each folder to a few thousand files. Split larger sets into subfolders.
- Write many small files to node-local `/scratch` first, then pack them with `tar` and copy the archive once.
- Buffer writes and flush at intervals. Do not open and close a file for every line.
- Do not write logs, caches, or temporary files into a code folder on Lustre.
## Node-local disk in a job
- `/scratch` and `/tmp` are on the same local disk, shared by every job on the node. It holds 397 GB on A100 nodes, 844 GB on H100 and H200 nodes, and 7 TB on RTX6000 nodes.
- Check free space with `df -h /scratch` before you stage data. Stage only what fits, and leave room for the other jobs.
- Put these lines at the top of the batch script, never in your own shell commands. Each of your commands runs in a new shell, so the trap would remove the folder at once.
```bash
JOBDIR=/scratch/$USER/${SLURM_JOB_ID:?} # stops if not in a job
mkdir -p "$JOBDIR" && trap 'rm -rf "$JOBDIR"' EXIT
```
- Write results to netscratch or lab storage, not to the job folder.
- The batch script runs on the first node only. In a multi-node job, make and remove the folder in each `srun` task.
- Nothing cleans `/scratch` when a job ends, and `/tmp` keeps unused files for 10 days.
## Unpack and delete
- Unpack archives on netscratch or node-local `/scratch`, not on Lustre.
- On netscratch, unpack new data with `tar -xmf`, as the FASRC scratch policy recommends. The files then get the current time instead of the archive's old times.
- To delete many files on Lustre, ask first. Then remove the files with `lfs find <folder> -type f -print0 | xargs -0 rm -f`, and remove the empty folders with `rm -r <folder>`.
## Watch jobs
- Do not poll files in a loop with `ls`, `cat`, `stat`, or `tail -f`. On shared storage, `tail -f` checks the file every second.
- Use `sbatch --wait`, `squeue`, or `sacct`. They ask the scheduler, not the filesystem. Wait at least 60 seconds between checks, so you do not load the scheduler either.
- To read a job's output, read only the end of one file, for example `tail -n 20 <file>`.
## Parallel agents and subagents
- Do not let several agents or subagents search or list the same large folder. Search once, save the result to a file, and share it.
- Limit how many jobs or tasks write to the same folder at once.
## Before you finish
- No environment, cache, or many-file output is on Lustre or in home.
- No job folder is left on node-local `/scratch`.
- Temporary files are deleted, and the results the user keeps are on lab storage.