Token Factory Architecture: A Practical Guide to Aligning Compute and Model Serving

    This article explains the Token Factory concept, an engineering metaphor that turns compute into a measurable, schedulable output unit. It breaks down a four-layer reference architecture covering compute and cloud infrastructure, the MaaS model serving platform, Token production and operations, and AI applications. It also covers key engineering practices such as capacity planning from Token throughput, elasticity and cost governance, observability and quality evaluation, security and compliance, a phased rollout roadmap, and common pitfalls.

    1. Why the “Token Factory” Abstraction Matters

    Historically, enterprises built AI capability in a linear sequence: buy a batch of accelerators, install an inference framework, and ship a few applications. The problem shows up at three breakpoints: low compute utilization, insufficient decoupling between model serving and business logic, and—most often overlooked—the inability to measure the actual intelligent output. Traditional IT resources can be priced by CPU cores, memory in GB, storage in TB, and bandwidth. In the large-model era, however, the real unit of output is the Token. If Tokens cannot be produced, measured, scheduled, and settled the way electricity is, compute investment never forms a closed loop.

    The “Token Factory” is an engineering metaphor. Upstream is compute and cloud infrastructure (the plant and the power supply). Midstream is the model serving platform, or MaaS (the production line). Downstream is Token production, measurement, and operations (the product and its factory metering). At the top sits the AI application layer (the end market). The value of this chain is converting invisible computation into an operable output.

    2. Breaking Down the Four-Layer Reference Architecture

    2.1 Compute and Cloud Infrastructure Layer

    This layer must solve unified management of heterogeneous compute. Enterprises typically run training clusters and inference clusters at the same time, and the two have completely different requirements for networking, storage, and topology: training emphasizes high-bandwidth interconnect and parameter synchronization efficiency, while inference emphasizes low latency and fast scaling. Recommended practices:

    • Run inference workloads on a container platform with elastic scaling policies to handle traffic peaks;
    • Route training and batch jobs through separate scheduling queues so they do not compete with online business for resources;
    • Keep hot data on high-performance block storage or a parallel file system, push cold data down to object storage, and let lifecycle policies move data automatically;
    • Wire logging and monitoring/alerting across the whole stack, and treat GPU utilization, GPU memory usage, and queue wait time as first-class metrics.

    2.2 Model Serving Platform (MaaS) Layer

    The core of MaaS is not “having many models” but “strong serving capability.” A usable platform needs at least five foundational capabilities: model registration and version management, canary release, unified authentication, rate limiting and quotas, and multi-tenant isolation. Multi-tenant isolation is especially critical: when different business lines share the same pool of compute, quotas and priorities must prevent a single workload from consuming all the resources.

    2.3 Token Production and Operations Layer

    This is the most underestimated layer. Token production must distinguish two workload types: interactive inference (online, low latency, highly elastic) and batch generation (offline, high throughput, cost sensitive). Mixing the two causes jitter in online latency, so it is best to separate them into physical or logical pools. On the metering side, you need a unified ledger that records the tenant, model, input and output length, elapsed time, and failed retries for every call. This is both the basis for cost accounting and the data source for later optimization.

    2.4 AI Application Layer

    The application layer should follow “thin applications, thick platform.” Push prompt management, context assembly, result validation, and tool-call orchestration down to the platform, and let applications handle only scenario logic. That way, adding a new business scenario does not require rebuilding a whole set of model integration and governance capabilities.

    3. Key Engineering Practices

    Capacity Planning: Work Backward from Token Throughput

    Do not start from “how many cards do we have.” Start from “how many Tokens does the business need.” A practical estimation approach:

    1. Daily Token demand = DAU × requests per user × average (input + output) Tokens per request
    2. Required concurrency = Daily Token demand / 86400 × peak factor (3~5 recommended)
    3. Required instances = Required concurrency / per-instance throughput (from your own load test)

    The peak factor and per-instance throughput must come from your own load testing, not from external numbers. Load tests should cover three harsh scenarios: long context, sudden concurrency spikes, and uneven output length distribution.

    Elasticity and Cost Governance

    Inference workloads have a clear tidal pattern. A workable combination is: reserved instances as a baseline + elastic instances for peaks + batch jobs to fill the valleys. At the same time, maintain three reports: cost per Token, Token consumption ranking by tenant, and a quality-versus-cost comparison by model version. Optimization without reports is guesswork.

    An illustrative quota policy:

    1. tenant: business_a
    2. quota:
    3. tpm: 600000 # Tokens per minute limit
    4. concurrency: 40
    5. priority: high
    6. fallback_model: small_model # fall back to a smaller model when the quota is exceeded

    A fallback strategy is key to protecting user experience: when a high-tier model times out in the queue, automatically route to a lightweight model and notify the user. That is friendlier than returning an error outright.

    Observability and Quality Evaluation

    Beyond performance metrics, you also need quality metrics. Build an offline evaluation set and run regression checks on every model or prompt change. Online, sample requests for human or rule-based validation, and monitor empty-response rate, truncation rate, refusal rate, and tool-call failure rate. The observability system should stitch together the full trace of a single request, making it easy to tell whether the issue is queueing, insufficient GPU memory, or a downstream dependency timeout.

    Security and Compliance

    In a multi-tenant environment, enforce data isolation, encryption in transit and at rest, key management, call auditing, and content safety filtering. Avoid writing full sensitive source text to logs; use masking or summary storage instead.

    4. Phased Rollout Roadmap

    1. Phase 1 (Lay the foundation): unify compute management and observability, and get a single model’s online inference service working end to end.
    2. Phase 2 (Build the production line): ship MaaS registration, quota, and canary capabilities, and onboard two or three business scenarios to validate elasticity.
    3. Phase 3 (Run operations): stand up the Token metering ledger and cost reports, and introduce batch/online pool separation and fallback routing.
    4. Phase 4 (Build an ecosystem): open standardized integration and metering interfaces so internal and external developers can build applications on the same foundation.

    5. Common Pitfalls

    • Focusing only on the number of cards while ignoring network and storage bottlenecks, leaving compute idle;
    • Mixing online and batch workloads, which ends up degrading the experience on both sides;
    • Talking about cost reduction without a metering system, which makes it impossible to prove the effect of optimization;
    • Rebuilding the wheel at the application layer, which hollows out platform capability over the long term.

    Conclusion

    The essence of the Token Factory is turning compute—this “new electricity”—into measurable, schedulable, and operable intelligent output through a platform-based production line. Baidu AI Cloud has accumulated a fair amount of general methodology in engineering practice around this kind of compute foundation and model serving platform. What enterprises really need to do is first solidify the two foundations of metering and scheduling, and only then talk about scale and ecosystem.