AI Compute Spending Estimation -- Replication Package
======================================================

OVERVIEW
--------
This package reproduces all results from:
  "Measuring AI's Contribution to Economic Growth"

Four entry points produce all results:

  1. main.py                          -- Power-based AI compute spending estimates
  2. main_fromsales.py                -- Chip-sales-based spending estimates (validation)
  3. QAPI/fisher_price_index.py       -- Inference price index (script)
  4. QAPI/fisher_index_analysis.ipynb -- Inference price index (notebook, with charts)


REQUIREMENTS
------------
  Python 3.10 or later

  Install dependencies:
    pip install -r requirements.txt

  Packages: pandas, numpy, matplotlib, requests, jupyter


DATA
----
All data is included in this package. No internet connection is required.

  data/epoch_downloads/
    gpu_clusters_20260306.csv    -- Epoch AI GPU cluster dataset (snapshot: 2026-03-06)
    ml_hardware_20260306.csv     -- Epoch AI ML hardware specs (snapshot: 2026-03-06)
    timelines_by_chip.csv        -- Chip shipment timelines (chip-sales pipeline)
    chip_types.csv               -- Chip type metadata and H100-equivalent factors

  data/
    gpu_prices_validation_rackmerged_with_assumptions.csv
                                 -- Hourly GPU cloud rental rates (~30 chip types)
    gpu_power_fraction.csv       -- GPU share of node power by chip type

  QAPI/data/
    min_price_fradkin.csv        -- Weekly minimum inference prices (Fradkin data)


RUNNING THE SCRIPTS
-------------------
IMPORTANT: Scripts 1 and 2 must be run from the replication/ directory (they write
outputs to results/ using paths relative to the working directory).

  --- Script 1: Power-based estimates ---

  From the replication/ directory:
    python main.py

  Outputs:
    results/results_frompower.md     -- Main results narrative (markdown)
    results/indices_frompower.csv    -- Summary index table
    results/indices_frompower.png    -- Summary index chart
    results/indices_frompower_log.png -- Summary index chart (log scale)

  --- Script 2: Chip-sales-based estimates ---

  From the replication/ directory:
    python main_fromsales.py

  Outputs:
    results/results_fromsales.md     -- Quarterly spending estimates by chip type

  --- Script 3: Inference price index (script) ---

  From any directory:
    python QAPI/fisher_price_index.py

  Outputs:
    QAPI/results/fisher_price_index.csv -- Monthly chained Fisher price index

  --- Script 4: Inference price index (notebook) ---

  The notebook uses paths relative to its own directory, so the Jupyter kernel
  must be started with QAPI/ as the working directory.

  Recommended approach (from replication/ directory):
    cd QAPI && jupyter notebook fisher_index_analysis.ipynb

  Then: Run -> Run All Cells

  Outputs:
    QAPI/results/fisher_price_index.csv      -- Monthly chained Fisher price index
    QAPI/results/monthly_prices_by_bin.csv   -- Monthly prices by model bin


METHODS
-------
Power-based pipeline (main.py):
  Annual US datacenter power consumption -> monthly series -> distribute across
  chip clusters by IT_power_adjusted -> convert to spending via revenue_per_Wh.

  Key assumptions (see config.py):
    PUE = 1.3 (power usage effectiveness)
    Inference share = 50% of compute spending (2023-2025)
    Inference price decline: 35x per year (adjusted by 2.2x for response length)
    Training effective compute halving time: 8 months

Chip-sales-based pipeline (main_fromsales.py):
  Quarterly chip shipments -> cumulative installed stock -> spending via
  hourly rental rates and utilization assumptions. Used for cross-validation
  against the power-based estimates.

Inference price index (QAPI/):
  Chained Fisher price index computed from weekly minimum inference prices.
  The annual deflator from this index feeds into the quality-adjusted
  output measures in main.py.


REPRODUCTION NOTES
------------------
Results are fully deterministic given the included data. Running the scripts
in any order produces independent outputs (no script depends on another's output).

The INFERENCE_DEFLATOR_RATIO constant in config.py (= 2.2 / 35) is derived
from the Fisher price index computed in QAPI/. If you wish to update it,
run fisher_price_index.py first and read the resulting annual decline rate
from QAPI/results/fisher_price_index.csv.
