Cache Sessions Guide
This guide explains cache utilities available in AMMM for PyTensor compilation artifacts.
What This Guide Covers
Section titled “What This Guide Covers”ammm-cacheCLI usageSessionManagerfor explicit cache isolation in custom scripts- Practical cache hygiene
1. ammm-cache CLI
Section titled “1. ammm-cache CLI”AMMM provides a cache management CLI:
ammm-cache infoammm-cache pruneammm-cache clearDefault cache root:
~/.ammm/compiled
Useful options:
ammm-cache info --verboseammm-cache prune --max-size 3000 --max-count 20 --max-age 14ammm-cache prune --dry-run --verboseammm-cache clear --forceammm-cache info --cache-root /custom/path2. Session Isolation in Python Scripts
Section titled “2. Session Isolation in Python Scripts”For advanced workflows, you can isolate compilation caches per config hash using
SessionManager.
from pathlib import Pathfrom 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 passThis is most useful when you run many shape-varying configurations in one Python process.
3. Important Clarification
Section titled “3. Important Clarification”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.
4. Recommended Hygiene
Section titled “4. Recommended Hygiene”- Use
ammm-cache infoweekly if you run many experiments. - Use
ammm-cache prunewith bounded size/age. - Use
clear --forcebefore benchmark reruns if you need a cold start.
5. Troubleshooting
Section titled “5. Troubleshooting”- If cache directories grow unexpectedly, verify
--cache-root. - If custom script runs exhibit shape reuse issues, use explicit
SessionManagercontexts per configuration family.