What Is an AI Factory? Four Stages From Data to Served Answer
An AI factory turns raw data and GPU-hours into served model output. This diagram breaks it into four stages — feed, shape, serve, restore — plus the control plane that owns them.
Loading…
Topic
41 posts about Cost Optimization. Every summary links to the original.
See the idea
An AI factory turns raw data and GPU-hours into served model output. This diagram breaks it into four stages — feed, shape, serve, restore — plus the control plane that owns them.
Follow one contact through a call center: arrival, routing, handling by a human or AI agent, resolution, and the cost-per-contact math that decides which path to use.
BitNet trades floating-point precision for a tiny, CPU-friendly footprint. This diagram maps the payoff—small memory and local serving—against the constraints that decide when the trade is worth it.
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
Newest first
Financial services firms that run batch data pipelines often conclude they have no real-time workload, but AI agents change that math. Agents convert a single business question into tens of exploratory queries, run in parallel, and never stop, even when querying yesterday’s data. The key property is not data freshness but query efficiency: an engine that finishes a query in 200 ms instead of 20 seconds frees cores 100 times sooner. On a fixed cluster, that efficiency allows the same hardware to absorb far more agent desks without scaling up or incurring budget overruns. Firms should measure compute-seconds per query on their current platform, count queries per agent task, and compare hold times on a real-time engine to control the agent compute bill.
Azure Databricks provides each user $10 of free Genie usage each month, with Genie One and Genie Agents free for users through January 31, 2027. The Genie ontology saves context from the whole company, so answers are not recomputed from raw data each time. Smart routing sends each request to a cost-efficient model, and open-weight models further reduce costs, making Genie more efficient with increased use. Genie budgets let admins set spending thresholds above the free allowance, using alert-only or block thresholds for per-user, group, and shared limits. Genie integrates with Microsoft Teams and Microsoft 365 Copilot, routing questions to Genie to avoid double billing, and partners can use these capabilities to deploy AI broadly without cost obstacles.
Unity Gateway Insights is a new Databricks feature that automatically analyzes millions of coding agent traces to identify token waste. It uses Genie to examine traces alongside business data and ontology, surfacing recurring MCP errors, simple tasks running on expensive frontier models, and repeated workflows worth codifying as shared skills. At Databricks, trace analysis revealed that fixing seven small MCP server bugs recovered an estimated $1.2M in annual costs. Insights requires Unity Gateway as the control plane, the ug CLI for automatic OpenTelemetry tracing, and a governed Delta table in Unity Catalog. It ranks findings by token cost and links each to example sessions for further investigation.
Coding agent sessions on GKE stay open all day but work only part of it; a study of GitHub Copilot traces found agents wait for the user about 80% of the time. Traditional approaches like one Pod per session or scale-to-zero waste compute or lose process state. Agent Substrate and AX separate the stateful session from the compute sandbox, enabling idle sandboxes to be snapshotted to object storage and restored on any warm worker. With a 2-minute idle timeout and 2 prompts per hour, parking saves about 40% of the node bill compared to one Pod per session. The savings diminish as prompt frequency rises, and around 4.5 prompts per hour one Pod per session becomes the cheaper option.
AI agents and real-time workloads generate far higher query volumes than human analysts, causing traditional data warehouses to scale cost linearly with demand. Databricks introduces Lakehouse//RT, a real-time analytics engine designed to serve high concurrency directly on the lakehouse without proportional cost growth. The engine achieves efficiency through four mechanisms: higher concurrency per warehouse, faster query execution, autoscaling in small increments, and a single system that eliminates duplicate infrastructure. Customers report 6x to 10x lower infrastructure costs, with examples such as Aurasell sustaining over 250 QPS on a single small cluster and VisionHeight reducing costs by more than 90% after migrating from Apache Pinot. Lakehouse//RT is available in beta with a 30% discount through January 2027.
OrderServ, a food-ordering platform, faced linear cost growth and slow scaling as it grew from one to multiple QSR brands, each running on dedicated ECS clusters with 21 microservices and 315 sidecar containers. AWS Professional Services and Cognizant transformed it into a multi-tenant SaaS by sharing a single ECS cluster with a tenancy library that enforces tenant isolation at the application level using request-scoped context. They replaced AWS Fargate with EC2 warm pools running Bottlerocket, reducing scaling time from 5-7 minutes to 30-60 seconds and achieving 47-64% compute cost reduction. A crash observability pipeline using FireLens and S3 provided zero-loss logging with full stack traces at $10/month per service, and passkeys via Amazon Cognito cut authentication costs by 80% while improving login latency. The combined annual savings exceeded 60% of previous infrastructure costs, with tenant onboarding reduced from days to minutes.
Snorkel, an AI data lab that creates datasets and benchmarks, evaluates agents across coding, infrastructure, and ML engineering tasks by running millions of simulations per month. To create realistic environments for valid comparisons, it uses Modal’s GPU and CPU sandboxes that reproduce complex, production-like systems such as multi-service workloads and GPU-enabled deep learning tasks, reflecting that an ML agent requires GPU access while an infrastructure agent needs a full Linux kernel. Previously, the team had to estimate CPU and memory needs, which often caused agent failures or wasted spending. By adopting Modal’s memory bursting, where sandboxes elastically expand resources at runtime based on actual usage, Snorkel decreased failed runs and saved approximately 20% on its total sandbox bill. For inference on open-weight models, Snorkel uses Modal’s shared and dedicated endpoints to quickly stand up, benchmark, and tear down models, peaking at tens of thousands of sandboxes running concurrently.
Per-token API prices are falling, but engineering bills for autonomous coding agents keep climbing because the dominating metric is now cost per successful task, not price per million tokens. A lightweight routing layer can intercept routine decisions before they reach an expensive reasoning model, preventing unnecessary deep-reasoning spend. The article tests TypeSafe’s Jev classifier in front of Google Antigravity’s model calls, using a single atomic Noul question to route tasks. On a 50-question coding-agent benchmark, the Jev router achieved 100% accuracy on 34 unseen held-out tasks and 96% overall, while a frozen regex and prompt-length heuristic dropped to 70.6% on unseen tasks. The most cost-effective approach is to start with a fast model on a light thinking setting, then add a near-free classifier to send only hard tasks to a stronger model.
Databricks is extending cost control functionality to serverless compute for notebooks, jobs, and pipelines, matching the controls already available for serverless SQL and Model Serving. The new controls operate at the workload and user layer rather than the infrastructure layer, with three capabilities: attribute costs through tags on serverless compute objects, control access via entitlements on default interactive and automated compute objects, and limit spend with per-compute rate limits expressed as t-shirt sizes S, M, L, XL. Serverless Compute Access Controls are generally available, rate limits are in beta, and serverless compute tags are in beta. Monitoring via system tables and budget alerts is generally available, letting teams track consumption within hours. The full set of controls moves cost governance from machine-level caps to people- and workload-level policies, addressing runaway spend, wrong hands, and lack of accountability.
Junie Eco Mode splits coding tasks into two phases: planning with the user’s selected model and implementation with a cheaper model, cutting costs significantly. In two internal benchmarks, average model cost per task dropped 57.3% (benchmark B) and 48.1% (benchmark A), while average resolve rates changed by less than one percentage point. The architect only reads code and produces a structured plan in about 15 steps, never making changes. The builder then follows the plan exactly, editing files, running builds and tests, and fixing issues. Eco mode is enabled by default for many configurations in JetBrains Air EAP and Junie CLI.
In CostBench, ClickHouse Cloud delivered 412×–1,996× better end-to-end performance per dollar than Snowflake, Databricks, BigQuery Capacity, and Redshift Serverless on a 113.2-billion-row stock-quote workload. The benchmark streamed the same data into all five systems while running analytical queries throughout ingestion, tracking summary freshness, preparation cost, query cost, and query runtime. ClickHouse Cloud prepared all 113.2 billion rows for $28.69, kept daily summaries in sync with raw data during inserts, and logged about $0.05 in query cost with 1.03 minutes of accumulated runtime. The lead comes from sorting and pre-aggregating incoming data in memory and writing sorted, compressed columnar parts to disk, so raw history and summaries advance together. Production examples include Tesla ingesting one billion rows per second, Cloudflare sub-two-second queries over 1.61 quadrillion events, and Artemis cutting an investigative lookup from 12 seconds to 200 milliseconds.
Databricks’ AI coding agent usage initially caused exponential cost growth, threatening to reverse the productivity gains that motivated adoption. To control spending without hindering developers, the company built a control layer that routes requests to appropriate models and provides spend visibility, avoiding hard caps that frustrate top users. Key cost-reduction levers include continuously migrating to cheaper models as they become available, which alone cut costs by over 50%, and using a Smart Router that reduces average task cost by 30% while maintaining quality. The company benchmarks models on its own multi-million-line codebase using real pull requests, finding that an open source model tied a frontier model at a third less cost per task, and combined with spend visibility, harness optimization, and caching adjustments, unit costs dropped by up to 90%. This internal solution was productized as Unity Gateway, now used by thousands of customers to manage AI coding costs.
Enterprise AI cost management is shifting from maximizing raw token volume to maximizing return on investment, requiring teams to measure, attribute, and optimize spend across models, agents, and applications. Granular cost attribution, enabled through request-level tags that map spend to specific teams or projects, is essential because organizations cannot manage what they do not measure. To avoid context bloat, systems should have agents pull relevant context on demand via tools or MCP servers rather than pushing all information upfront, preventing unnecessary token waste. Dynamic model routing assesses task complexity in real time to direct the 90% of tasks suited for cheaper models away from frontier models. End-to-end tracing collects the full exhaust of agent activity including prompts and tool calls, enabling teams to identify abuse, waste, and leaks to inform cost management decisions.
JetBrains Air Governance, formerly JetBrains Central, is now generally available as the organization layer of JetBrains Air for managing agentic AI usage. It provides a single console to manage AI agents, models, and providers across teams, set spending limits, and track both costs and outcome metrics like the split between human-authored and AI-generated code. The tool works with Claude Agent, Codex, Gemini CLI, Junie, and other ACP-compatible agents across IDEs, CLI, web, and mobile, and supports multiple vendors without separate contracts. Admins can set AI credit limits per user, team, or service account, manage BYOK providers, approve agents, and configure MCP servers at the company level, combining these into policies for different groups. Air Governance is available to all JetBrains organizational customers with free and paid plans starting at USD 20 per developer per month, and it already manages usage for roughly 2,300 people at JetBrains.
The post describes how specializing the vocabulary of a small language model cut inference cost by 77% in a Portuguese essay grader built on Qwen3-4B. The original general-purpose tokenizer fragmented domain text and included unused tokens, wasting compute. The authors developed VocabX, which rebuilds the tokenizer by weighting token cost based on whether tokens appear in input or output, since generated tokens cost 7.4 times more due to memory bandwidth limits. VocabX works on sub-word and multi-word layers, reducing vocabulary from 151,669 to about 65,000, and outperformed three reference methods across five domains and three model families. In the grader, it reduced response tokens from 350 to 101, cut cost by 77%, and improved quality from 0.703 to 0.810, though compressing the grade into a macro token hurt quality.
Notion developed Auto, an upgraded model router, to deliver high-quality AI results while making customers’ AI credits go further. To evaluate models, Notion categorized knowledge-work tasks into clusters and created an evaluation dataset by sampling hundreds of real-world tasks from the 20 largest clusters. They built Gymmy, a simulated environment running Notion’s application code, databases, and search services in isolated sandboxes loaded with saved workspace data, allowing consistent comparison of multiple models including GPT-6 Astra, Opus 5.5, GPT-6.1 Sol, and Auto. Notion used pairwise comparisons with Elo scores to calibrate a single LLM judge, achieving over 80% agreement between pairwise and pointwise evaluations, validated by customer thumbs-up and thumbs-down feedback. On average, Auto delivers roughly 90% of frontier model performance for about 90% lower cost, enabling users’ AI credits to go up to 10x further for everyday tasks like polishing emails, tracking task progress, and drafting performance reviews.
By August 2026, Cloudflare’s AI code reviewer average cost had doubled to $2.46 per review, driven by a switch to Anthropic models and tripled token usage per session. Analysis showed 77% of spend went to prompt caching, yet first-request cache hits were only 14-26% because the shared prefix lacked an independent cache breakpoint. Adding a breakpoint on September 16 enabled cross-repository cache reuse, immediately cutting cost from $2.47 to $2.02. Subsequent changes—inline reference indices, tool removal, parallel file reads, and skipping reviewers on re-reviews—reduced cost by another $0.20 per review. The final result: $0.77 average cost (68% reduction), 1m32s median time (from 4m9s), and code quality at high effort maintained real-problem detection with reduced noise.
PostgreSQL’s ACID guarantees cause substantial write amplification: each write flushes WAL for durability, copies rows via MVCC for isolation, and updates every affected index, amplifying 100 bytes of row change into tens of kilobytes of I/O. Costs scale linearly with data size, and even sharded Postgres offers only linear scaling with added coordination overhead, so growing datasets drive rising bills. The post proposes offloading settled, rarely-changing data to ClickHouse, whose columnar compression shrinks datasets 10-30x and whose cloud offering costs about 5x less than comparable Postgres infrastructure while also reducing Postgres compute load through fewer indexes. ClickHouse builds indexes in background batches and runs aggregations at roughly 100x lower cost than Postgres. ClickHouse Cloud provides WalShadow for millisecond-latency CDC and pg_clickhouse FDW, enabling an application pattern that cuts the cost of serving settled data by an order of magnitude.
The post describes design tradeoffs and workarounds encountered while building the open-source Bulk Executor tool for Amazon DynamoDB on AWS Glue. Core requirements included real-time local-script feel, scaling to hundreds of parallel workers without user infrastructure management, and easy command extensibility. AWS Glue was chosen for serverless parallelism and a built-in DynamoDB connector, but the connector simplified data types, losing distinctions like string set versus list of strings. Challenges included estimating costs for provisioned tables, handling job termination with ^C, and streaming output via CloudWatch Live Tail which samples events and delivers out-of-order. Solutions included a two-phase cost estimate for deletes, programmatic interrupt handling, writing large output to S3 with a preview, mandating point-in-time recovery for mutating commands, and using AI for testing and linting; the team also migrated from AWS Glue 4 to 5 and 6 for faster startup and 30 percent lower DPU costs.
Level 5 covers operability for LLM systems: daily running, cost control, provider outage survival, and fast shutdown on misbehavior. A single gateway funnels all model traffic, measuring cost, routing requests, enabling failover, and hosting an instantaneous kill switch; a shared decision_id threads metrics, logs, traces, and the audit ledger. Observability supplements RED metrics with a decision layer capturing auto vs. human splits, guardrail blocks, judge disagreements, token spend per tenant and capability, and shadow-eval pass ratios via tiered structured logs. Cost controls attribute spending at the gateway per tenant and capability, with hard budget ceilings; optimization follows order: skip model, batch, cache, right-size, trim—each step profiled against quality. The platform spine includes stateless agent services, the gateway, an audit datastore, cache, secrets store, and object storage—scoped with least-privilege IAM and encryption, avoiding queues or vector stores until warranted.
The best engineering reads, once a week.