#!/usr/bin/env python3 """Capacity and cost calculator for the article "Design a multimodal RAG pipeline for 1 billion documents". Pure Python 3 stdlib. Every input is in ASSUMPTIONS below. Items marked "[SPEC]" come from SPEC.md; items marked "[ASSUMPTION]" are round, defensible numbers chosen for the calculator; items marked "[PRICE]" come from an official pricing page (URL + date in PRICE_SOURCES). Run: python3 rag_capacity.py -> prints report, writes ../capacity.json """ import json import os ASSUMPTIONS = { # ---------------- corpus [SPEC] ---------------- "docs_total": 1_000_000_000, "changed_docs_per_day": 2_000_000, "mix": {"text": 0.70, "pdf": 0.20, "image": 0.08, "av": 0.02}, # text docs [SPEC] "text_doc_tokens": 2000, "text_chunk_tokens": 500, "text_chunks_per_doc": 4, # PDFs / office [SPEC] "pdf_pages_per_doc": 12, "pdf_scanned_page_share": 0.15, "pdf_page_chunk_tokens": 450, "pdf_tables_per_page": 0.4, "pdf_figures_per_page": 0.3, "pdf_page_image_vectors_per_page": 1, "table_chunk_tokens": 300, # [ASSUMPTION] markdown table + 1-line summary "figure_caption_tokens": 80, # [ASSUMPTION] VLM caption chunk # standalone images [SPEC] "image_caption_tokens": 80, # audio / video [SPEC] "av_minutes_per_doc": 15, "av_words_per_minute": 150, "av_tokens_per_doc": 3000, "av_chunks_per_doc": 6, "av_video_share": 0.5, # [ASSUMPTION] half of AV docs are video (keyframes only for video) "keyframes_per_video": 10, "keyframe_caption_tokens": 40, # [ASSUMPTION] # ---------------- embedding spaces [SPEC] ---------------- "text_dim": 1024, "text_dim_coarse": 256, # Matryoshka truncation for coarse pass "image_dim": 768, "pq_bytes_per_vector": 64, # ---------------- tiers [SPEC + ASSUMPTION] ---------------- "hot_share": 0.10, "hot_vectors_per_node": 20_000_000, "warm_vectors_per_node": 50_000_000, "copies": 3, # 1 primary + 2 replicas "hnsw_M": 32, # [ASSUMPTION] layer-0 links = 2*M ids of 4 B "hnsw_upper_layer_overhead": 0.10, # [ASSUMPTION] +10% of layer-0 links for upper layers/locks "id_meta_bytes_per_vector": 16, # [ASSUMPTION] 8 B id + 8 B tier/tenant/acl bitmap ref in RAM "diskann_R": 64, # [ASSUMPTION] max out-degree on SSD graph, 4 B per neighbour id "diskann_ram_cache_share": 0.05, # [ASSUMPTION] 5% of SSD node records cached in RAM (hot nodes near entry point) "ram_headroom": 1.3, # [ASSUMPTION] 30% headroom for OS, query buffers, rebuilds "fresh_window_docs": 2_000_000, # [SPEC] ~24 h of writes # ---------------- archive raw files [ASSUMPTION] ---------------- "raw_bytes": {"text": 20e3, "pdf": 1.5e6, "image": 500e3, "av": 100e6}, "parsed_elements_bytes_per_chunk": 3e3, # [ASSUMPTION] JSON element + text + bbox per chunk # ---------------- BM25 [ASSUMPTION] ---------------- "bytes_per_token": 4, # ~4 bytes of UTF-8 text per token "bm25_index_share_of_text": 0.30, # inverted index w/ positions ~30% of raw text bytes # ---------------- one-time costs ---------------- # [PRICE] API embedding price, USD per 1M tokens (see PRICE_SOURCES) "api_embed_usd_per_m_tokens": 0.13, "api_embed_small_usd_per_m_tokens": 0.02, # [PRICE] text-embedding-3-small (1536-d) for comparison # [ASSUMPTION] self-hosted "gpu_usd_per_hour": 2.50, # on-demand-ish H100/A100-class cloud price, round "gpu_text_embed_tokens_per_sec": 50_000, # ~0.5B-param 1024-d encoder, fp16, large batches, per GPU "gpu_image_embed_images_per_sec": 500, # SigLIP/CLIP ViT-L class, per GPU "gpu_layout_pages_per_sec": 10, # layout + table structure model, per GPU (all PDF pages) "gpu_ocr_pages_per_sec": 10, # self-hosted OCR on scanned pages, per GPU "api_ocr_usd_per_1000_pages": 1.50, # [PRICE] Google Document AI Enterprise OCR, 1K-5M pages/month "api_ocr_usd_per_1000_pages_over_5m": 0.60, # [PRICE] same, 5M+ pages/month "ocr_backfill_months": 3, # [ASSUMPTION] OCR backfill spread over 3 months (tiers reset monthly) "gpu_vlm_captions_per_sec": 20, # small (~7B) VLM, batched, ~60 output tokens per caption "gpu_asr_realtime_factor": 50, # Whisper-large-class batched: 50 audio-hours per GPU-hour "api_asr_usd_per_minute": 0.006, # [PRICE] OpenAI Whisper API # ---------------- query side ---------------- "peak_qps": 500, "avg_to_peak_ratio": 0.3, # [ASSUMPTION] average load = 30% of peak "rerank_candidates": 200, "rerank_pair_tokens": 512, # [ASSUMPTION] query + chunk "gpu_rerank_pairs_per_sec": 1_000, # [ASSUMPTION] ~0.5B cross-encoder, fp16, per GPU at p95-safe batch "semantic_cache_hit": 0.20, # [ASSUMPTION] 20% answers served from cache "llm_input_tokens": 8_000, "llm_output_tokens": 400, "llm_usd_per_m_input": 2.00, # [PRICE] Claude Sonnet 5.5 base input "llm_usd_per_m_output": 10.00, # [PRICE] Claude Sonnet 5.5 output "llm_small_usd_per_m_input": 0.10, # [PRICE] Claude Haiku 5.5 (prompts <= 100K tokens) "llm_small_usd_per_m_output": 0.50, # [PRICE] } PRICE_SOURCES = { "api_embed_usd_per_m_tokens": "https://developers.openai.com/api/docs/pricing (checked 2026-11-26: text-embedding-3-large $0.13, text-embedding-3-small $0.02 per 1M input tokens; no batch price listed for embeddings)", "api_ocr_usd_per_1000_pages": "https://cloud.google.com/document-ai/pricing (checked 2026-11-26: Enterprise Document OCR Processor $1.50 per 1,000 pages for 1,000-5,000,000; $0.60 above 5,000,000)", "api_asr_usd_per_minute": "https://developers.openai.com/api/docs/pricing (checked 2026-11-26: Whisper $0.006 / minute)", "llm_usd_per_m_input": "https://platform.claude.com/docs/en/about-claude/pricing (checked 2026-11-26: Claude Sonnet 5.5 $2 / MTok input, $10 / MTok output; Claude Haiku 5.5 $0.10 / $0.50 for prompts up to 100K tokens; Batch API 50% off)", } A = ASSUMPTIONS T, G, M, K = 1e12, 1e9, 1e6, 1e3 def human_bytes(b): for unit, size in (("PB", 1e15), ("TB", 1e12), ("GB", 1e9), ("MB", 1e6)): if b >= size: return f"{b / size:,.2f} {unit}" return f"{b:,.0f} B" def human_n(n): for unit, size in (("T", 1e12), ("B", 1e9), ("M", 1e6), ("K", 1e3)): if abs(n) >= size: return f"{n / size:,.2f}{unit}" return f"{n:,.0f}" def ceil_div(a, b): return int(-(-a // b)) def ocr_api_cost(pages): months = A["ocr_backfill_months"] per = pages / months low = min(per, 5e6) return months * (low / 1000 * A["api_ocr_usd_per_1000_pages"] + max(per - 5e6, 0) / 1000 * A["api_ocr_usd_per_1000_pages_over_5m"]) def compute(): D = A["docs_total"] n = {k: D * v for k, v in A["mix"].items()} out = {"docs": n} # ---------- elements and chunks ---------- pages = n["pdf"] * A["pdf_pages_per_doc"] scanned = pages * A["pdf_scanned_page_share"] tables = pages * A["pdf_tables_per_page"] figures = pages * A["pdf_figures_per_page"] videos = n["av"] * A["av_video_share"] keyframes = videos * A["keyframes_per_video"] asr_hours = n["av"] * A["av_minutes_per_doc"] / 60 text_chunks = { "text_doc_chunks": n["text"] * A["text_chunks_per_doc"], "pdf_page_chunks": pages, "pdf_table_chunks": tables, "pdf_figure_caption_chunks": figures, "image_caption_chunks": n["image"], "av_transcript_chunks": n["av"] * A["av_chunks_per_doc"], "keyframe_caption_chunks": keyframes, } text_tokens = { "text_doc_chunks": text_chunks["text_doc_chunks"] * A["text_chunk_tokens"], "pdf_page_chunks": pages * A["pdf_page_chunk_tokens"], "pdf_table_chunks": tables * A["table_chunk_tokens"], "pdf_figure_caption_chunks": figures * A["figure_caption_tokens"], "image_caption_chunks": n["image"] * A["image_caption_tokens"], "av_transcript_chunks": n["av"] * A["av_tokens_per_doc"], "keyframe_caption_chunks": keyframes * A["keyframe_caption_tokens"], } image_vectors = { "pdf_page_images": pages * A["pdf_page_image_vectors_per_page"], "pdf_figures": figures, "standalone_images": n["image"], "video_keyframes": keyframes, } tv = sum(text_chunks.values()) iv = sum(image_vectors.values()) tok = sum(text_tokens.values()) vlm_captions = figures + n["image"] + keyframes out["elements"] = { "pdf_pages": pages, "ocr_pages": scanned, "tables": tables, "figures": figures, "videos": videos, "keyframes": keyframes, "asr_hours": asr_hours, "vlm_captions": vlm_captions, } out["text_chunks"] = text_chunks out["text_tokens"] = text_tokens out["image_vectors"] = image_vectors out["totals"] = { "text_space_vectors": tv, "image_space_vectors": iv, "all_vectors": tv + iv, "text_tokens_to_embed": tok, "images_to_embed": iv, "vectors_per_doc_avg": (tv + iv) / D, } # ---------- raw vector storage ---------- dims = {"text": A["text_dim"], "image": A["image_dim"]} counts = {"text": tv, "image": iv} def bpv(space, prec): d = dims[space] return {"float32": 4 * d, "float16": 2 * d, "int8": d, "binary": d / 8, "pq64": A["pq_bytes_per_vector"]}[prec] storage = {} for prec in ("float32", "float16", "int8", "binary", "pq64"): row = {s: counts[s] * bpv(s, prec) for s in counts} row["total"] = sum(row.values()) storage[prec] = row storage["text_matryoshka256_float16"] = tv * A["text_dim_coarse"] * 2 out["raw_vector_storage_bytes"] = storage # ---------- tiers ---------- links0 = 2 * A["hnsw_M"] * 4 hnsw_graph = links0 * (1 + A["hnsw_upper_layer_overhead"]) hot = {} hot_ram = 0 for s in counts: v = counts[s] * A["hot_share"] per = bpv(s, "int8") + hnsw_graph + A["id_meta_bytes_per_vector"] hot[s] = {"vectors": v, "bytes_per_vector": per, "ram_bytes": v * per} hot_ram += v * per hot_vectors = (tv + iv) * A["hot_share"] hot_shards = ceil_div(hot_vectors, A["hot_vectors_per_node"]) hot["total_vectors"] = hot_vectors hot["ram_bytes_one_copy"] = hot_ram hot["ram_bytes_all_copies"] = hot_ram * A["copies"] hot["shards"] = hot_shards hot["nodes"] = hot_shards * A["copies"] avg_hot_per = hot_ram / hot_vectors hot["ram_per_node_bytes"] = A["hot_vectors_per_node"] * avg_hot_per * A["ram_headroom"] hot["hnsw_graph_bytes_per_vector"] = hnsw_graph warm = {} warm_vectors = (tv + iv) * (1 - A["hot_share"]) ssd_rec = {s: bpv(s, "int8") + A["diskann_R"] * 4 for s in counts} warm_ssd = sum(counts[s] * (1 - A["hot_share"]) * ssd_rec[s] for s in counts) warm_ram_pq = warm_vectors * (A["pq_bytes_per_vector"] + A["id_meta_bytes_per_vector"]) warm_ram_cache = warm_ssd * A["diskann_ram_cache_share"] warm_ram = warm_ram_pq + warm_ram_cache warm_shards = ceil_div(warm_vectors, A["warm_vectors_per_node"]) warm.update({ "total_vectors": warm_vectors, "ssd_bytes_per_vector": ssd_rec, "ram_bytes_one_copy": warm_ram, "ram_pq_bytes": warm_ram_pq, "ram_cache_bytes": warm_ram_cache, "ssd_bytes_one_copy": warm_ssd, "ram_bytes_all_copies": warm_ram * A["copies"], "ssd_bytes_all_copies": warm_ssd * A["copies"], "shards": warm_shards, "nodes": warm_shards * A["copies"], "ram_per_node_bytes": warm_ram / warm_vectors * A["warm_vectors_per_node"] * A["ram_headroom"], "ssd_per_node_bytes": warm_ssd / warm_vectors * A["warm_vectors_per_node"], }) fresh_vectors = A["fresh_window_docs"] * (tv + iv) / D fresh_ram = fresh_vectors * (A["text_dim"] * 2 + hnsw_graph + A["id_meta_bytes_per_vector"]) # float16, small fresh = {"vectors": fresh_vectors, "ram_bytes_one_copy": fresh_ram, "ram_bytes_all_copies": fresh_ram * A["copies"]} parsed_bytes = (tv + iv) * A["parsed_elements_bytes_per_chunk"] raw_files = sum(n[k] * A["raw_bytes"][k] for k in n) archive = { "float16_vectors_bytes": storage["float16"]["total"], "raw_files_bytes": raw_files, "parsed_elements_bytes": parsed_bytes, "total_bytes": storage["float16"]["total"] + raw_files + parsed_bytes, } out["tiers"] = {"fresh": fresh, "hot": hot, "warm": warm, "archive": archive} # ---------- BM25 ---------- text_bytes = tok * A["bytes_per_token"] bm25 = text_bytes * A["bm25_index_share_of_text"] out["bm25"] = {"text_bytes": text_bytes, "index_bytes_one_copy": bm25, "index_bytes_all_copies": bm25 * A["copies"]} # ---------- one-time ingest cost ---------- gpu = A["gpu_usd_per_hour"] gh = { "text_embedding": tok / A["gpu_text_embed_tokens_per_sec"] / 3600, "image_embedding": iv / A["gpu_image_embed_images_per_sec"] / 3600, "layout_parsing_all_pages": pages / A["gpu_layout_pages_per_sec"] / 3600, "ocr_scanned_pages": scanned / A["gpu_ocr_pages_per_sec"] / 3600, "vlm_captions": vlm_captions / A["gpu_vlm_captions_per_sec"] / 3600, "asr": asr_hours / A["gpu_asr_realtime_factor"], } gh_total = sum(gh.values()) one_time = { "gpu_hours": gh, "gpu_hours_total": gh_total, "gpu_usd": {k: v * gpu for k, v in gh.items()}, "gpu_usd_total": gh_total * gpu, "api_text_embed_usd": tok / M * A["api_embed_usd_per_m_tokens"], "api_text_embed_small_usd": tok / M * A["api_embed_small_usd_per_m_tokens"], "api_ocr_usd": ocr_api_cost(scanned), "api_asr_usd": asr_hours * 60 * A["api_asr_usd_per_minute"], "gpus_for_30_day_backfill": gh_total / (30 * 24), } out["one_time"] = one_time # ---------- daily steady state ---------- f = A["changed_docs_per_day"] / D daily = { "docs": A["changed_docs_per_day"], "text_vectors": tv * f, "image_vectors": iv * f, "vectors": (tv + iv) * f, "text_tokens": tok * f, "gpu_hours": gh_total * f, "gpu_usd": gh_total * f * gpu, "gpus_running_24x7": gh_total * f / 24, "vectors_per_sec_avg": (tv + iv) * f / 86400, } out["daily"] = daily # ---------- query side ---------- qps = A["peak_qps"] miss = 1 - A["semantic_cache_hit"] pairs = qps * miss * A["rerank_candidates"] rerank_gpus = ceil_div(pairs, A["gpu_rerank_pairs_per_sec"]) llm_in_tps = qps * miss * A["llm_input_tokens"] llm_out_tps = qps * miss * A["llm_output_tokens"] per_q = (A["llm_input_tokens"] * A["llm_usd_per_m_input"] + A["llm_output_tokens"] * A["llm_usd_per_m_output"]) / M q_day = qps * A["avg_to_peak_ratio"] * 86400 per_q_small = (A["llm_input_tokens"] * A["llm_small_usd_per_m_input"] + A["llm_output_tokens"] * A["llm_small_usd_per_m_output"]) / M out["query"] = { "peak_qps": qps, "cache_hit": A["semantic_cache_hit"], "rerank_pairs_per_sec_peak": pairs, "rerank_tokens_per_sec_peak": pairs * A["rerank_pair_tokens"], "rerank_gpus_peak": rerank_gpus, "llm_input_tokens_per_sec_peak": llm_in_tps, "llm_output_tokens_per_sec_peak": llm_out_tps, "llm_usd_per_uncached_query": per_q, "queries_per_day": q_day, "llm_usd_per_day": q_day * miss * per_q, "llm_usd_per_month": q_day * miss * per_q * 30, "llm_small_usd_per_uncached_query": per_q_small, "llm_small_usd_per_month": q_day * miss * per_q_small * 30, "reranker_gpu_usd_per_month_if_peak_24x7": rerank_gpus * A["gpu_usd_per_hour"] * 24 * 30, } return out def report(o): L = [] p = L.append t = o["totals"] p("=" * 72) p("MULTIMODAL RAG FOR 1 BILLION DOCUMENTS - CAPACITY AND COST") p("=" * 72) p("\n[1] Documents by modality") for k, v in o["docs"].items(): p(f" {k:<8} {human_n(v):>10}") p("\n[2] Elements") for k, v in o["elements"].items(): p(f" {k:<28} {human_n(v):>10}") p("\n[3] Text-space chunks (1024-d) chunks tokens") for k in o["text_chunks"]: p(f" {k:<36} {human_n(o['text_chunks'][k]):>9} {human_n(o['text_tokens'][k]):>11}") p(f" {'TOTAL':<36} {human_n(t['text_space_vectors']):>9} {human_n(t['text_tokens_to_embed']):>11}") p("\n[4] Image-space vectors (768-d)") for k, v in o["image_vectors"].items(): p(f" {k:<36} {human_n(v):>9}") p(f" {'TOTAL':<36} {human_n(t['image_space_vectors']):>9}") p(f"\n ALL VECTORS: {human_n(t['all_vectors'])} (~{t['vectors_per_doc_avg']:.1f} per document)") p("\n[5] Raw vector storage (one copy) text image total") for prec, row in o["raw_vector_storage_bytes"].items(): if isinstance(row, dict): p(f" {prec:<30} {human_bytes(row['text']):>12} {human_bytes(row['image']):>13} {human_bytes(row['total']):>13}") p(f" text Matryoshka-256 float16 {human_bytes(o['raw_vector_storage_bytes']['text_matryoshka256_float16']):>12}") h, w, fr, ar = (o["tiers"][k] for k in ("hot", "warm", "fresh", "archive")) p("\n[6] Tiers") p(f" FRESH delta : {human_n(fr['vectors'])} vectors, RAM {human_bytes(fr['ram_bytes_one_copy'])} x3 = {human_bytes(fr['ram_bytes_all_copies'])}") p(f" HOT (10%) : {human_n(h['total_vectors'])} vectors, int8 + HNSW M={A['hnsw_M']} " f"(layer-0 links 2*M*4 = {2*A['hnsw_M']*4} B, +10% upper layers = {h['hnsw_graph_bytes_per_vector']:.0f} B/vector)") p(f" text {h['text']['bytes_per_vector']:.0f} B/vec, image {h['image']['bytes_per_vector']:.0f} B/vec") p(f" RAM one copy {human_bytes(h['ram_bytes_one_copy'])}, x3 = {human_bytes(h['ram_bytes_all_copies'])}") p(f" shards {h['shards']} (20M/node) x3 = {h['nodes']} nodes, ~{human_bytes(h['ram_per_node_bytes'])} RAM per node incl. 30% headroom") p(f" WARM (90%) : {human_n(w['total_vectors'])} vectors, DiskANN: PQ 64 B + 16 B id/meta in RAM + 5% SSD-record cache") p(f" SSD record = int8 vector + R={A['diskann_R']}*4 B links: text {w['ssd_bytes_per_vector']['text']:.0f} B, image {w['ssd_bytes_per_vector']['image']:.0f} B") p(f" RAM one copy {human_bytes(w['ram_bytes_one_copy'])} (PQ {human_bytes(w['ram_pq_bytes'])} + cache {human_bytes(w['ram_cache_bytes'])}), x3 = {human_bytes(w['ram_bytes_all_copies'])}") p(f" SSD one copy {human_bytes(w['ssd_bytes_one_copy'])}, x3 = {human_bytes(w['ssd_bytes_all_copies'])}") p(f" shards {w['shards']} (50M/node) x3 = {w['nodes']} nodes, per node ~{human_bytes(w['ram_per_node_bytes'])} RAM, ~{human_bytes(w['ssd_per_node_bytes'])} NVMe") p(f" ARCHIVE : float16 vectors {human_bytes(ar['float16_vectors_bytes'])} + raw files {human_bytes(ar['raw_files_bytes'])}" f" + parsed elements {human_bytes(ar['parsed_elements_bytes'])} = {human_bytes(ar['total_bytes'])}") p(f" Index nodes total (hot + warm, 3 copies): {h['nodes'] + w['nodes']}") b = o["bm25"] p(f"\n[7] BM25: text {human_bytes(b['text_bytes'])} -> index ~30% = {human_bytes(b['index_bytes_one_copy'])}, x3 = {human_bytes(b['index_bytes_all_copies'])}") ot = o["one_time"] p(f"\n[8] One-time ingest (self-hosted GPUs at ${A['gpu_usd_per_hour']}/GPU-hour)") for k, v in ot["gpu_hours"].items(): p(f" {k:<28} {v:>12,.0f} GPU-h ${ot['gpu_usd'][k]:>12,.0f}") p(f" {'TOTAL':<28} {ot['gpu_hours_total']:>12,.0f} GPU-h ${ot['gpu_usd_total']:>12,.0f}") p(f" -> {ot['gpus_for_30_day_backfill']:,.0f} GPUs to finish the backfill in 30 days") p(" Managed-API alternatives:") p(f" text embedding API (${A['api_embed_usd_per_m_tokens']}/1M tok) ${ot['api_text_embed_usd']:>12,.0f} (3-small at $0.02: ${ot['api_text_embed_small_usd']:,.0f})") p(f" OCR API ($1.50 then $0.60 /1000 pages, over {A['ocr_backfill_months']} months) ${ot['api_ocr_usd']:>12,.0f}") p(f" ASR API (${A['api_asr_usd_per_minute']}/min) ${ot['api_asr_usd']:>12,.0f}") d = o["daily"] p(f"\n[9] Daily steady state ({human_n(d['docs'])} changed docs/day)") p(f" vectors/day {human_n(d['vectors'])} (text {human_n(d['text_vectors'])}, image {human_n(d['image_vectors'])}), ~{d['vectors_per_sec_avg']:,.0f} vectors/s avg") p(f" text tokens/day {human_n(d['text_tokens'])}; GPU-hours/day {d['gpu_hours']:,.0f} (${d['gpu_usd']:,.0f}/day) = {d['gpus_running_24x7']:,.0f} GPUs 24x7") q = o["query"] p(f"\n[10] Query side ({q['peak_qps']} QPS peak, {q['cache_hit']:.0%} semantic-cache hit)") p(f" rerank pairs/s {q['rerank_pairs_per_sec_peak']:,.0f} ({human_n(q['rerank_tokens_per_sec_peak'])} tok/s) -> {q['rerank_gpus_peak']} GPUs at {A['gpu_rerank_pairs_per_sec']} pairs/s/GPU") p(f" LLM input {human_n(q['llm_input_tokens_per_sec_peak'])} tok/s, output {human_n(q['llm_output_tokens_per_sec_peak'])} tok/s at peak") p(f" LLM cost ${q['llm_usd_per_uncached_query']:.3f} per uncached query; {human_n(q['queries_per_day'])} queries/day -> ${q['llm_usd_per_day']:,.0f}/day, ${q['llm_usd_per_month']:,.0f}/month (Sonnet-class)") p(f" small-model answerer: ${q['llm_small_usd_per_uncached_query']:.4f}/query -> ${q['llm_small_usd_per_month']:,.0f}/month (Haiku-class)") p(f" reranker fleet if sized for peak 24x7: ${q['reranker_gpu_usd_per_month_if_peak_24x7']:,.0f}/month") p("\nAssumption sources (prices): ") for k, v in PRICE_SOURCES.items(): p(f" {k}: {v}") return "\n".join(L) if __name__ == "__main__": o = compute() print(report(o)) here = os.path.dirname(os.path.abspath(__file__)) with open(os.path.join(here, "..", "capacity.json"), "w") as fh: json.dump({"assumptions": ASSUMPTIONS, "price_sources": PRICE_SOURCES, "results": o}, fh, indent=2)