Skip to content

Cache Sessions Guide

This guide explains cache utilities available in AMMM for PyTensor compilation artifacts.

  • ammm-cache CLI usage
  • SessionManager for explicit cache isolation in custom scripts
  • Practical cache hygiene

AMMM provides a cache management CLI:

Terminal window
ammm-cache info
ammm-cache prune
ammm-cache clear

Default cache root:

  • ~/.ammm/compiled

Useful options:

Terminal window
ammm-cache info --verbose
ammm-cache prune --max-size 3000 --max-count 20 --max-age 14
ammm-cache prune --dry-run --verbose
ammm-cache clear --force
ammm-cache info --cache-root /custom/path

For advanced workflows, you can isolate compilation caches per config hash using SessionManager.

from pathlib import Path
from src.utils.session_manager import SessionManager
config = {
"media": [{"spend_col": "tv_spend"}, {"spend_col": "search_spend"}],
"extra_features_cols": ["competitor_sales"],
"ad_stock_max_lag": 8,
}
with SessionManager(config=config, cache_root=Path.home() / ".ammm" / "compiled", verbose=True):
# Run model fitting code here
pass

This is most useful when you run many shape-varying configurations in one Python process.

Current runme.py does not expose a documented AMMM_CACHE_MODE flag. Treat cache session management as:

  • automatic runtime behaviour handled internally where applicable; and/or
  • explicit control in custom scripts via SessionManager.
  1. Use ammm-cache info weekly if you run many experiments.
  2. Use ammm-cache prune with bounded size/age.
  3. Use clear --force before benchmark reruns if you need a cold start.
  • If cache directories grow unexpectedly, verify --cache-root.
  • If custom script runs exhibit shape reuse issues, use explicit SessionManager contexts per configuration family.