Trillion-Parameter Agent Models: Architectural Advantages and Inference Costs
This article analyzes the architectural design and inference cost estimation of an open-source trillion-parameter Mixture of Experts (MoE) model optimized for Agent applications. It details key architectural choices, including increased expert sparsity, reduced attention heads, and a streamlined dense layer structure. Furthermore, it examines how active parameters influence inference costs across different deployment scales and outlines data synthesis strategies for enhancing Agent tool-calling capabilities.
1. Background: New Requirements for Agent Scenarios
As Large Language Models (LLMs) transition from conversational Q&A to Agent applications, evaluation priorities have shifted. Traditional Q&A only requires the model to generate correct text, whereas Agents require the model to understand task objectives, decompose steps, select tools, parse tool returns, and adjust plans based on intermediate states. Therefore, Agent capabilities are typically reflected in three types of metrics: tool calling accuracy, multi-step decision planning stability, and foundational reasoning capabilities in frontier knowledge, mathematics, and coding tasks.
Models that perform strongly in Agent scenarios generally share two characteristics. First, they undergo specialized training in tool calling formats, parameter filling, and error recovery. Second, their training data covers a sufficient variety of task types and interaction trajectories. Addressing these two points requires synchronous consideration of model architecture design and training data engineering.
This article uses an open-source trillion-parameter Mixture of Experts (MoE) model as an example to analyze the motivations behind its architectural choices and estimate inference costs under different deployment methods. The numerical values mentioned are based on public descriptions, without making inferences beyond the original text.
2. Core Design of the Trillion-Parameter MoE Architecture
2.1 Increasing Sparsity: Scaling Experts to 384
MoE models split the feed-forward network into multiple experts, where each token passes through only a few experts selected by a router. The total parameter count is determined by all experts, while a single forward pass utilizes only the activated parameters. This structure allows the model to expand its knowledge capacity under controllable computational loads.
Compared to a similar MoE baseline with approximately 671 billion parameters, this model increases the number of experts from 256 to 384. With more experts, each expert can focus more closely on specific patterns, while the router must select from a larger pool of candidates. The code below illustrates a common top-k routing logic, where top_k is an example parameter and not the official configuration:
import torchdef route(hidden, gate_weight, top_k=8):# hidden: [num_tokens, d_model]# gate_weight: [num_experts, d_model]logits = hidden @ gate_weight.T # Score of each token for each expertscores = torch.softmax(logits, dim=-1)topk_scores, topk_idx = scores.topk(top_k, dim=-1)# Renormalize the selected expert weights so they sum to 1topk_scores = topk_scores / topk_scores.sum(dim=-1, keepdim=True)return topk_idx, topk_scores
Increasing the number of experts introduces two engineering challenges. The first is load balancing: if most tokens are routed to a few experts, some devices will be idle while others are overloaded. The second is communication overhead: in multi-GPU deployments, tokens must be distributed and aggregated across devices. Therefore, the increase in expert count must be designed in tandem with parallelization strategies and load balancing loss.
2.2 Halving Attention Heads: Reducing Long-Sequence Costs
The computational load of attention layers is proportional to the number of heads. This model reduces the number of attention heads from 128 to 64 while retaining the Multi-head Latent Attention (MLA) structure. Halving the heads reduces the attention computation by roughly half. In long-context scenarios where attention computation accounts for a high proportion, this modification significantly lowers per-inference cost.
Reducing the number of heads comes with trade-offs. The representational capacity and parallelism of each head decrease, requiring the model to compensate in other ways. Therefore, the choice of head count is typically evaluated alongside training stability and downstream benchmarks, rather than looking solely at computational volume.
2.3 Hierarchical Structure: Only the First Layer Remains Dense
Similar MoE models typically use dense feed-forward networks for the first few layers and sparse experts for the rest. This model reduces the dense layers from the first three to just the first layer, applying the MoE structure to all remaining layers. Dense layer parameters are fully utilized in every pass, meaning more dense layers result in larger activated parameters. Compressing the number of dense layers allows more layers to benefit from the computational savings of sparsity.
The premise of this modification is that foundational feature extraction can be handled by a single dense layer, while upper-layer experts manage complex semantic composition. This assumption must be verified through training curves and evaluation results.
2.4 Training Data Scale and Optimizer
The training data volume increased slightly from approximately 14.8T tokens to 15.5T tokens. For a trillion-parameter model, this growth in data scale is primarily to ensure sufficient training rather than to drastically expand knowledge coverage. Data quality, deduplication strategies, and task distribution generally have a greater impact than minor fluctuations in total volume.
Regarding the optimizer, the model employs an optimizer based on matrix orthogonalization and incorporates constraints on attention logits. Excessively large attention logits can lead to training instability; constraint mechanisms keep these values within a reasonable range. The core objective of such methods is to enable large-scale training to remain stable at higher learning rates, reducing loss spikes and mid-training rollbacks.
3. Inference Cost Analysis
3.1 Active Parameters Determine Per-Token Computation
For Transformer-based models, the floating-point operations for a single forward pass can be roughly estimated as:
Per-token computation ≈ 2 × Active parameter count
This model has approximately 32B active parameters, while the baseline has about 37B. Based on this approximation, the linear layer computation per token is reduced by about 14%. When combined with the benefits of halved attention heads, the overall reduction in computational cost is even greater. It is important to note that this estimate only includes forward computation and does not account for communication, memory read/write, and scheduling overhead.
3.2 Differences Between Large-Scale Clusters and Small-Scale Deployments
Large-scale inference typically employs multi-node, multi-GPU expert parallelism, combined with request batching and communication optimization. At scales of 128 GPUs or more, communication overhead can be amortized, and expert computational loads become more balanced. Following the baseline’s optimization methods, the unit inference cost of this model is expected to be comparable to the baseline. Increased sparsity means a lower proportion of parameters is actually engaged per token, which helps improve throughput during batched requests.
Small-scale deployments tell a different story. In single-node or few-GPU configurations, the weights of all experts must reside in memory, while parallelism among experts is limited. If low latency (low Time Per Output Token, or TPOT) is the goal, reading expert weights and cross-GPU communication become bottlenecks, potentially resulting in a higher unit cost than the baseline. Therefore, deployment scale is a critical variable determining the cost structure.
3.3 A Simple Cost Estimation Framework
The function below provides a rough framework for cost comparison. The inputs are example values used to illustrate the calculation method:
def cost_per_million_tokens(active_params_b, gpu_count,gpu_hour_price, tokens_per_sec_per_gpu):# Approximate cost per million tokens, unit is consistent with inputstokens_per_hour = tokens_per_sec_per_gpu * 3600 * gpu_countcost_per_token = (gpu_count * gpu_hour_price) / tokens_per_hourreturn cost_per_token * 1_000_000# Example: only used to compare relative results under different throughput assumptionsprint(cost_per_million_tokens(32, 16, 2.0, 500))
The throughput in this framework must be obtained through actual stress testing and cannot be directly derived from theoretical values. In practical evaluations, throughput and first token latency should be tested separately under different concurrency levels, input/output lengths, and latency constraints.
4. Data Synthesis Methods for Agent Tool Calling
4.1 Building a Tool Library Using Public APIs
The model’s Agent capabilities rely on a large volume of tool calling samples. The training methodology references academic benchmarks for tool calling by collecting large-scale public API interfaces to form a tool set available for Agent invocation. Each tool includes a name, functional description, parameter definitions, and return format, constituting the tool environment during training.
Three points are critical when constructing the tool library. First, interface descriptions must be clear and unambiguous. Second, parameter types and constraints must align with real interfaces. Third, there should be functional overlap among tools to train the model to make choices among similar tools.
4.2 Four Goals of Data Synthesis
The data synthesis system is designed around four goals:
- Diversity: Task types, tool categories, and interaction formats should be as broad as possible to prevent the model from excelling only in a few scenarios.
- Scalable: The synthesis pipeline must be able to generate samples in batches and continue running as the tool library expands.
- Realistic: User instructions, tool returns, and error messages should closely resemble real environments to minimize the distribution gap between training and deployment.
- Interactive: The model must receive feedback and correct its calls in multi-turn interactions, rather than just outputting a one-time result.
Trade-offs exist among these four goals. For instance, over-pursuing realism increases annotation costs, while over-pursuing scale may introduce low-quality samples. In practice, automated filtering and manual sampling are typically combined to ensure trajectory quality.
4.3 Trajectory Quality, Quantity, and Variety
Agent training data is typically measured in “trajectories,” which encompass all steps from the user instruction to the final result in a complete task. Trajectory quality is reflected in whether the steps are logical, whether tool parameters are correct, and whether errors are handled properly. The quantity of trajectories determines the coverage of training, while the variety determines whether the model can generalize to unseen tasks.
Continuously improving these three dimensions is the core of Agent model iteration. A viable approach is to feed the model’s own failure cases back into the data synthesis pipeline, forming a closed loop.
5. Engineering Practice Recommendations
If a team plans to evaluate or deploy a similar large-scale MoE model, the following steps can be referenced:
- Clarify the latency and throughput requirements of the business, distinguishing between offline batch processing and online interactive workloads.
- Select parallelization strategies based on deployment scale. Small-scale scenarios can prioritize quantization and expert offloading schemes, while large-scale scenarios should focus on expert parallelism and communication optimization.
- Establish a separate evaluation set for tool calling capabilities, including metrics such as parameter accuracy, calling sequence correctness, and error recovery rate.
- Conduct small-traffic canary testing on real business data to observe stability under long-context and multi-turn interactions.
- Establish cost monitoring, tracking cost per million tokens, memory usage, and request latency separately to avoid relying on a single metric.
6. Conclusion
Trillion-parameter sparse models balance total capacity and per-computation cost by increasing expert sparsity, reducing attention heads, and streamlining dense layers. Inference cost depends on deployment scale: large-scale clusters offer better unit costs, while small-scale, low-latency scenarios require separate evaluation. The enhancement of Agent capabilities relies on broadly covering, realistic, and interactive tool-calling data. For engineering teams, model selection should simultaneously consider architectural features, deployment conditions, and business metrics, rather than focusing solely on the total parameter count.
