CV-ICRL MiniGrid policies, training seed 0 (our training, not the authors' weights)

The first public checkpoints of a CV-ICRL policy (Context Value Informed In-Context Reinforcement Learning, arXiv 2509.23209), for two MiniGrid tasks: MiniGrid-SimpleCrossingS9N3-v0 and MiniGrid-BlockedUnlockPickup-v0. The authors release their code, their training data and an evaluator, but no trained checkpoint.

These are our checkpoints, not the authors'. We trained them with the authors' release trainer (train_cv_minigrid.py --method cv, Bluixe/CV-ICRL at commit 8b3b44e85ef652678691dba3c4c0a5912b8f1207) on the authors' released training histories (datasets/bluixe/CV-ICRL at commit fefa021a1692670c991f3d63b80412ef2057babc), as part of a reproduction of the paper's Table 11. On both tasks they give returns close to the paper's Table 11 under all three value-token arms (below).

What the model does

CV-ICRL is a causal transformer that plays a task it has never seen and gets better while it plays, by reading its own recent history from its context (in-context reinforcement learning). The weights are fixed during play. Each context position holds what the agent saw (the 7×7×3 MiniGrid view), the action it took and a value token: the model's own running estimate of how well it can do. The model has two heads: action logits and a value prediction (the critic). At deployment the critic's raw prediction v̂t goes through a running maximum, mt = max(mt−1, v̂t) with m−1 = 0, and mt is written back into the context as the next value token.

Files

File Task SHA-256
MiniGrid-SimpleCrossingS9N3-v0/epoch_15.pt SimpleCrossingS9N3 130bb86455ad5f4bbd03f9595e715e4c560593b890a485db934359459f8195c7
MiniGrid-BlockedUnlockPickup-v0/epoch_15.pt BlockedUnlockPickup 39926706d35dfa22d7a646ec600a24e7c0e63d70c135d3e8a5c344524de27271

SHA256SUMS lists both; the files are byte-identical to checkpoints/seed0/<task>/epoch_15.pt in datasets/chans/cvicrl-minigrid-table11-repro. Each file is a plain PyTorch dict: model_state_dict (66 tensors), model_config, method ("cv") and epoch (15). It loads with torch.load(..., weights_only=True).

Training data and settings

  • Data: the authors' stage-2 training histories, one file per task (MiniGrid/<task>/train_traj-relabel.pkl; SHA-256 SimpleCrossingS9N3 d47c5aa70b975db43119ae011423723bebd05558d9d1266a7fff7025db95ef39, BlockedUnlockPickup e73d6530bd07ebc29079769e3d374a955cd23622ed07c137398bb39a14371b29, both equal to the authors' manifest). Each holds 400-step histories collected with the paper's stage-1 PPO checkpoints; the value token in the data is the evaluated return of the PPO checkpoint that produced the history. Range of value tokens in the training data: SimpleCrossingS9N3 0.090–0.953, BlockedUnlockPickup 0.000–0.963.
  • Trainer: the release train_cv_minigrid.py --method cv with its defaults: context H @@train_H@@, 4 layers, 4 heads, 256 dims, 15 epochs, batch 32, AdamW lr 0.001, training seed 0; loss = action cross-entropy + value MSE. Epoch 15 is the released checkpoint (fixed before evaluation; the paper does not say which epoch Table 11 used).
  • Validation: the release has no validation histories, so the last 1,000 rows of each training file stand in (in-sample). Final loss per token, train / validation: SimpleCrossingS9N3 1.2065 / 1.2038, BlockedUnlockPickup 0.2775 / 0.2418.
  • Hardware: one local GPU (NVIDIA GB10, aarch64), torch 2.7.1+cu128 (no aarch64 CUDA wheel of the authors' torch 2.6.0 exists). Training used our uint8 data loader (below), which gives bit-identical batches.

Results: Table 11 value-token interventions

Release evaluator eval_cv_minigrid.py, 20 streams (environment seeds 0–19), 8,000 steps per stream with the context and the write-back state kept across episodes, --torch-seed 0. The authors' MiniGrid keeps a stream's layout fixed across its episodes, so each stream is one maze that the policy learns in context. AER = mean return of the completed episodes of a stream, then mean ± population SD over the 20 streams. A MiniGrid episode that reaches the goal returns 1 − 0.9 × (steps taken / step limit); a timeout returns 0.

  • normal: the running maximum mt is written back (the deployed method);
  • zero: 0 is written at every step;
  • frozen: the first value max(0, v̂0) is written at every step;
  • frozen_final (our exploratory control, not in the paper): each stream's token is held from step 0 at the value the normal arm had written at its last step.
Task Arm Paper AER These checkpoints: AER Success rate Episodes / stream Paired drop vs normal [95% CI]
SimpleCrossingS9N3 normal (deployed) 0.942 ± 0.020 0.942 ± 0.019 0.997 410.9 –
SimpleCrossingS9N3 zero 0.090 ± 0.152 0.079 ± 0.138 0.157 26.6 0.863 [0.800, 0.926]
SimpleCrossingS9N3 frozen 0.286 ± 0.296 0.293 ± 0.289 0.461 44.0 0.649 [0.515, 0.783]
SimpleCrossingS9N3 frozen_final (ours, exploratory) – 0.950 ± 0.016 1.000 478.1 −0.009 [−0.011, −0.007] (normal minus frozen_final)
BlockedUnlockPickup normal (deployed) 0.936 ± 0.027 0.945 ± 0.015 0.996 241.8 –
BlockedUnlockPickup zero 0.097 ± 0.124 0.054 ± 0.094 0.095 14.1 0.891 [0.844, 0.937]
BlockedUnlockPickup frozen 0.241 ± 0.219 0.264 ± 0.239 0.360 22.2 0.681 [0.565, 0.798]
BlockedUnlockPickup frozen_final (ours, exploratory) – 0.943 ± 0.017 0.994 236.4 0.002 [−0.001, 0.006] (normal minus frozen_final)

Paired over the 20 stream seeds, zeroing lowers AER by 0.863 [0.800, 0.926] (SimpleCrossingS9N3) and 0.891 [0.844, 0.937] (BlockedUnlockPickup), and freezing by 0.649 [0.515, 0.783] and 0.681 [0.565, 0.798] (mean drop [95% t interval]). Every one of the 20 streams drops in every cell. Our pre-registered rule called the claim verified (for our checkpoint). The normal arm repeated with --torch-seed 0 / 1 / 2 gives 0.9415 / 0.9416 / 0.9415 (SimpleCrossingS9N3) and 0.9450 / 0.9441 / 0.9456 (BlockedUnlockPickup). The model-index metadata above holds the AER means of these checkpoints.

Load the checkpoint

The model class is the authors' MinigridMultiheadTransformer (nets/net.py). It is not copied here: the author repository has no license file. Get it at the pinned commit and build a Python 3.9 environment with the authors' pins (CPU build of torch shown; on an x86 CUDA machine use --index-url https://download.pytorch.org/whl/cu124 instead):

git clone https://github.com/Bluixe/CV-ICRL.git
cd CV-ICRL
git checkout 8b3b44e85ef652678691dba3c4c0a5912b8f1207
uv venv --python 3.9.15 .venv
uv pip install --python .venv/bin/python --index-url https://download.pytorch.org/whl/cpu torch==2.6.0
uv pip install --python .venv/bin/python -r requirements.txt pandas==2.2.3 cloudpickle==3.1.1 huggingface_hub==0.36.0
uv pip install --python .venv/bin/python --no-deps -e ./Minigrid -e ./stable-baselines3 -e ./stable-baselines3-contrib

pandas and cloudpickle are needed by the vendored stable-baselines3, which the author requirements leave out. Download the checkpoints into the author checkout and check them:

.venv/bin/hf download chans/cvicrl-minigrid-seed0 --local-dir cvicrl-ckpt
(cd cvicrl-ckpt && sha256sum -c SHA256SUMS)

Load one and run a forward pass (from the CV-ICRL folder, so that nets imports):

.venv/bin/python - <<'EOF'
import torch
from nets.net import MinigridMultiheadTransformer

ckpt = torch.load("cvicrl-ckpt/MiniGrid-SimpleCrossingS9N3-v0/epoch_15.pt", map_location="cpu", weights_only=True)
model = MinigridMultiheadTransformer(ckpt["model_config"])
model.load_state_dict(ckpt["model_state_dict"], strict=True)
model.eval()
print(ckpt["method"], "epoch", ckpt["epoch"], f"{sum(p.numel() for p in model.parameters()):,} parameters")

# context of one step: observation [batch, steps, 3, 7, 7], action ids [batch, steps], value tokens [batch, steps, 1]
x = {"context_states": torch.zeros(1, 1, 3, 7, 7),
     "context_actions": torch.zeros(1, 1, dtype=torch.long),
     "context_rewards": torch.zeros(1, 1, 1)}
with torch.no_grad():
    logits, value = model(x)
print("action logits", tuple(logits.shape), "value", tuple(value.shape))
EOF

Evaluate with the authors' evaluator

A short run on CPU: 2 streams, 200 steps, normal arm. It writes the evaluator's JSON (per-stream episode returns, AER) and a trace of the raw value prediction and the written token at every step.

OMP_NUM_THREADS=4 .venv/bin/python eval_cv_minigrid.py \
  --checkpoint cvicrl-ckpt/MiniGrid-SimpleCrossingS9N3-v0/epoch_15.pt --eval-env MiniGrid-SimpleCrossingS9N3-v0 \
  --condition normal --num-envs 2 --num-steps 200 --seed-start 0 --torch-seed 0 \
  --H 400 --embd 256 --layer 4 --head 4 --device cpu \
  --output-json short/normal.json --trace-npz short/normal.npz

We ran every command above, word for word, in a fresh folder: first with a local copy of these files in place of the download, before they were uploaded, then again after the upload, with the download from the Hub. The short evaluation took 6.6 s on 4 threads of an aarch64 CPU with torch 2.6.0+cpu, start-up included (11.6 s in the second run, while other jobs were using the machine's CPU); loading and the forward pass took 4.8 s.

The Table 11 setting is 20 streams × 8,000 steps per arm. Run it on a GPU: it took 7 to 14 minutes per arm and task on ours. Different hardware samples different actions, so expect AER close to, not identical with, the table above.

for task in MiniGrid-SimpleCrossingS9N3-v0 MiniGrid-BlockedUnlockPickup-v0; do
  for arm in normal zero frozen; do
    .venv/bin/python eval_cv_minigrid.py --checkpoint cvicrl-ckpt/$task/epoch_15.pt --eval-env $task \
      --condition $arm --num-envs 20 --num-steps 8000 --seed-start 0 --torch-seed 0 \
      --H 400 --embd 256 --layer 4 --head 4 --device cuda \
      --output-json table11/$task/$arm.json --trace-npz table11/$task/$arm.npz
  done
done

Each JSON's aggregate.aer_mean and aggregate.aer_std are the AER mean and population SD over the streams. Our scripts/aggregate.py applies the decision rule and the token-state checks, and scripts/eval_frozen_at.py runs the frozen_final control.

Retrain with less RAM: the uint8 loader

The author loader (dataset.MinigridDataset) converts a task's whole observation array to float32 when it loads; we measured 57.6 GiB peak RSS on the SimpleCrossingS9N3 file. Our scripts/train_uint8.py runs the author trainer unchanged except for that one class: observations stay uint8 in RAM and each sample is converted to float32 when it is drawn (12.0 GiB peak RSS). uint8 to float32 is exact, and no random number is drawn in the loader, so training is the same. We checked it on 60 batches: every loss, the metrics file and every tensor of the saved checkpoint are bit-identical (results/loader_parity.json). To retrain both tasks end to end (download of the two 11 GB training files, training, every evaluation arm, aggregation; x86 CUDA machine, 64 GB RAM is enough):

git clone https://github.com/goodboychan/hf-neurips-repro.git
cd hf-neurips-repro/papers/2509.23209-cv-icrl
./run.sh                      # LOADER=uint8 is the default; LOADER=author uses the author loader

Limits

  • Not the authors' weights. Our training run with their trainer and data; the trainer is itself a new-run implementation in the release, not the archived one. The paper's own checkpoints may behave differently.
  • One training seed (seed 0) per task. Evaluation noise is small (above), but training-seed variation is not measured.
  • The written token goes above the training range. Under normal write-back the token rises to 0.985 / 1.042 (SimpleCrossingS9N3 / BlockedUnlockPickup, mean over streams at the last step), above the highest value token in the training data (0.953 / 0.963) in all 20 streams; 80.3% / 98.5% of all evaluation steps feed a token above that range. The policy works well there, but it is run outside the values it was trained on.
  • What the token does. In our exploratory frozen_final control, a constant high token held from step 0 does as well as normal write-back: AER 0.950 ± 0.016 against 0.942 ± 0.019 (SimpleCrossingS9N3) and 0.943 ± 0.017 against 0.945 ± 0.015 (BlockedUnlockPickup). On these checkpoints the level of the token matters more than continued write-back.
  • Evaluator. The release evaluator names an archived evaluator commit that is not public, so parity with the evaluator behind the paper's numbers cannot be checked. The training-time validation loss is in-sample.

License and citation

Released under CC BY 4.0, like the training data it was trained on: CV-ICRL training histories by Wenhao Zhang, Shao Zhang, Xihuai Wang, Yang Li and Ying Wen (datasets/bluixe/CV-ICRL, CC BY 4.0). No author code is included; the author repository has no license file. Please cite the paper:

@article{zhang2025cvicrl,
  title   = {Context Value Informed In-Context Reinforcement Learning},
  author  = {Zhang, Wenhao and Zhang, Shao and Wang, Xihuai and Li, Yang and Wen, Ying},
  journal = {arXiv preprint arXiv:2509.23209},
  year    = {2025}
}
Downloads last month

-

Downloads are not tracked for this model. How to track
Video Preview
loading

Dataset used to train chans/cvicrl-minigrid-seed0

Spaces using chans/cvicrl-minigrid-seed0 2

Paper for chans/cvicrl-minigrid-seed0

Evaluation results

  • AER, normal value-token write-back (mean of 20 streams, population SD 0.019) on MiniGrid-SimpleCrossingS9N3-v0
    self-reported
    0.942
  • AER, value token zeroed (mean of 20 streams, population SD 0.138) on MiniGrid-SimpleCrossingS9N3-v0
    self-reported
    0.079
  • AER, value token frozen at the first prediction (mean of 20 streams, population SD 0.289) on MiniGrid-SimpleCrossingS9N3-v0
    self-reported
    0.293
  • AER, value token held at the normal run's final value, exploratory (mean of 20 streams, population SD 0.016) on MiniGrid-SimpleCrossingS9N3-v0
    self-reported
    0.950
  • AER, normal value-token write-back (mean of 20 streams, population SD 0.015) on MiniGrid-BlockedUnlockPickup-v0
    self-reported
    0.945
  • AER, value token zeroed (mean of 20 streams, population SD 0.094) on MiniGrid-BlockedUnlockPickup-v0
    self-reported
    0.054
  • AER, value token frozen at the first prediction (mean of 20 streams, population SD 0.239) on MiniGrid-BlockedUnlockPickup-v0
    self-reported
    0.264
  • AER, value token held at the normal run's final value, exploratory (mean of 20 streams, population SD 0.017) on MiniGrid-BlockedUnlockPickup-v0
    self-reported
    0.943