Back to list
Scaling High-Performance AI: How Cloudflare Optimizes Kimi and GLM Models for Workers AI
Industry NewsCloudflareAI InfrastructureOpen Source

Scaling High-Performance AI: How Cloudflare Optimizes Kimi and GLM Models for Workers AI

Cloudflare has unveiled advanced optimization techniques to run demanding large-scale models, specifically Moonshot's Kimi K-series and Z.ai's GLM, on its Workers AI platform. These Mixture-of-Experts (MoE) models are known for their long-context capabilities but present significant memory challenges. To address this, Cloudflare utilizes a combination of KV cache quantization, model weight compression, and cache protection. A key breakthrough involves transitioning the KV cache from 16-bit precision (BF16) to 8-bit floating point (FP8), which effectively doubles the context capacity for models like Kimi K2.6 from 686,000 to 1.37 million tokens. By leveraging the open-source SGLang framework, Cloudflare achieves higher efficiency and lower costs while maintaining model accuracy, ensuring high-performance inference is accessible closer to the end-user.

Hacker News

Key Takeaways

  • Memory Efficiency: Cloudflare uses FP8 quantization for the KV cache to halve its memory footprint, doubling the available context for long-context models.
  • Model Support: The optimizations specifically target high-demand Mixture-of-Experts (MoE) models, including Moonshot's Kimi K-series and Z.ai's GLM.
  • Framework Integration: All inference serving and benchmarking are conducted using SGLang, an open-source framework that Cloudflare actively contributes to.
  • Performance Gains: By separating prefill and decode phases and layering compression techniques, Cloudflare supports more concurrent requests on shared hardware without losing accuracy.

In-Depth Analysis

Overcoming the Memory Bottleneck in Long-Context Models

Serving large-scale models like Kimi and GLM presents a unique set of infrastructure challenges, primarily centered around memory constraints. These models utilize a Mixture-of-Experts (MoE) architecture and support extensive context lengths, which are highly beneficial for users but demanding for hardware. Cloudflare's analysis reveals that in long-context scenarios, it is often the KV (Key-Value) cache—rather than the model weights themselves—that exhausts GPU memory first. The KV cache is essential for maintaining the state of a conversation, allowing the model to reference previous tokens without re-processing the entire history for every new output.

To mitigate this, Cloudflare has implemented 8-bit floating point (FP8, e4m3) quantization for the KV cache. Previously stored in 16-bit precision (BF16), this shift effectively reduces the memory required for the cache by 50%. For a model such as Kimi K2.6, this optimization increases the context capacity from approximately 686,000 tokens to 1.37 million tokens on the same hardware. This allows for significantly longer interactions and more complex data processing within a single session.

Strategic Optimization Layers: Compression and Cache Protection

Beyond quantization, Cloudflare employs a multi-layered strategy to maximize GPU utility. This includes model weight compression and the separation of the prefill and decode phases of inference. Prefill involves processing the initial input prompt, while the decode phase generates subsequent tokens one by one. By isolating these phases, Workers AI can optimize the specific compute requirements of each, leading to faster overall performance.

Furthermore, because these optimizations allow more requests to be packed onto shared hardware, Cloudflare has introduced mechanisms to protect the shared cache. This ensures that the increased density of requests does not lead to performance degradation or resource contention. These technical refinements are designed to lower the cost of serving state-of-the-art models, making it economically viable to offer high-performance AI capabilities at scale.

Collaborative Innovation with SGLang

Cloudflare’s infrastructure relies heavily on SGLang, an open-source inference serving framework. Through rigorous benchmarking, Cloudflare identified SGLang as a market leader in performance. Rather than maintaining a private fork, Cloudflare works closely with the SGLang development team to upstream patches and new features. This collaborative approach ensures that the broader open-source community benefits from the stability and performance enhancements developed for Workers AI, while Cloudflare maintains a cutting-edge platform for its users.

Industry Impact

The ability to serve massive, long-context models like Kimi and GLM at the edge represents a significant shift in AI accessibility. By reducing the hardware barriers through software-level optimizations like FP8 quantization and weight compression, Cloudflare is setting a precedent for how infrastructure providers can handle the next generation of MoE models. This efficiency not only lowers the entry barrier for developers looking to integrate sophisticated AI into their applications but also promotes a more sustainable model for GPU resource management in data centers worldwide.

Frequently Asked Questions

Question: Why is the KV cache more problematic than model weights for memory?

In long-context models, the KV cache grows with every token processed in a conversation. For very long dialogues or document analyses, the cumulative size of these stored keys and values can exceed the static size of the model's weights, eventually filling the GPU's memory and limiting the maximum context length.

Question: How does FP8 quantization affect model accuracy?

According to Cloudflare's findings, transitioning the KV cache to 8-bit floating point (FP8) allows for a significant reduction in memory usage with no change in the accuracy of the model's output. This makes it a highly effective optimization for scaling inference.

Question: What is the role of SGLang in Cloudflare's AI stack?

SGLang is the open-source inference serving framework used by Cloudflare to run and benchmark its AI models. Cloudflare contributes patches and features back to the SGLang project, ensuring the framework remains optimized for high-performance, production-grade AI traffic.

Related News

Stripe Agrees to Acquire AI Startup OpenRouter Following $1.3 Billion Valuation Milestone
Industry News

Stripe Agrees to Acquire AI Startup OpenRouter Following $1.3 Billion Valuation Milestone

Financial infrastructure giant Stripe has entered into an agreement to acquire OpenRouter, a prominent US-based artificial intelligence startup. This strategic acquisition follows a period of significant financial growth for OpenRouter, which recently concluded a US$113 million Series B funding round. The funding round had propelled the startup to a reported valuation of approximately US$1.3 billion prior to the acquisition announcement. The deal marks a major consolidation in the AI sector, as Stripe integrates a high-value AI platform into its existing ecosystem. The transition from a newly minted unicorn to a subsidiary of Stripe highlights the rapid pace of investment and acquisition within the current artificial intelligence landscape, emphasizing the strategic value placed on established AI infrastructure and talent.

OpenAI Reportedly Disbands Preparedness Team Responsible for Assessing and Mitigating Serious AI Model Risks
Industry News

OpenAI Reportedly Disbands Preparedness Team Responsible for Assessing and Mitigating Serious AI Model Risks

OpenAI has reportedly dissolved its internal preparedness team, a specialized group formerly tasked with identifying and mitigating catastrophic risks associated with advanced AI models. According to reports from the Financial Times and The Verge, the team’s primary mandate was to evaluate whether AI models could pose serious threats, such as the potential for a model to "go rogue" or engage in unauthorized hacking activities against other organizations. The responsibility for these critical safety assessments is reportedly being redistributed within the company following the team's disbandment at the end of last month. This organizational shift marks a significant change in OpenAI's approach to internal risk management and preparedness as it continues to develop increasingly powerful artificial intelligence technologies.

Stripe Reportedly Set to Acquire AI Gateway Startup OpenRouter in Landmark $7 Billion Strategic Deal
Industry News

Stripe Reportedly Set to Acquire AI Gateway Startup OpenRouter in Landmark $7 Billion Strategic Deal

Financial technology leader Stripe is reportedly in the process of acquiring OpenRouter, a prominent startup specializing in AI gateway infrastructure. The deal, valued at over $7 billion, marks a significant consolidation between the fintech and artificial intelligence sectors. OpenRouter has gained attention for its role as a unified interface for AI model access, a position emphasized by its CEO’s description of the company as the "Stripe for AI." This acquisition highlights Stripe's aggressive expansion into the AI ecosystem, aiming to provide the underlying infrastructure for AI integration. The reported $7 billion price tag underscores the immense value placed on middleware that simplifies the deployment and management of diverse artificial intelligence models for developers and enterprises globally.