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

Industry News

Parallel Cuts Labor Market Research Time and Cost in Half Using OpenAI GPT-6 Astra

According to a release by OpenAI, Parallel has successfully halved both the operational time and overall financial cost required to research and synthesize complex labor-market data by integrating GPT-6 Astra into its agentic workflows. By deploying GPT-6 Astra, Parallel's autonomous agents achieve double the processing efficiency compared to prior models while simultaneously cutting operational expenses by fifty percent. This deployment highlights tangible performance gains in practical agent-driven data analysis and labor research pipelines.

Industry News

OpenAI Outlines Core Priorities and Principles for Rigorous and Independent Third-Party AI Safety Assessments

OpenAI has officially outlined a set of priorities and foundational principles aimed at guiding effective third-party AI safety assessments. As artificial intelligence advances into increasingly capable territory, the organization emphasizes the necessity of independent, rigorous, and secure evaluations targeting frontier models and their corresponding technical safeguards. This initiative highlights the growing recognition across the artificial intelligence sector that internal safety testing alone is insufficient for establishing comprehensive risk mitigation. By formalizing expectations around external assessment methodologies, OpenAI aims to promote transparent verification practices and robust safety validation. The framework addresses the need for external evaluators to thoroughly examine frontier system capabilities and safeguard effectiveness without compromising security, setting a strategic direction for future independent AI auditing standards.

Apple Agrees to $250 Million Siri AI Settlement: Eligible iPhone Owners Can Now Submit Payout Claims
Industry News

Apple Agrees to $250 Million Siri AI Settlement: Eligible iPhone Owners Can Now Submit Payout Claims

Apple has agreed to a $250 million settlement following allegations that the company failed to deliver an advertised AI-upgraded Siri, opening the claims submission process for eligible smartphone purchasers. The resolution allows qualifying United States residents who purchased an iPhone 15 Pro, iPhone 15 Pro Max, or any iPhone 16 model beginning on June 10, 2024, to seek financial compensation through official claims channels. The legal outcome reflects heightened consumer expectations and stricter accountability surrounding marketed artificial intelligence features versus actual product rollouts. This massive financial payout marks an important development for affected consumers and sets a clear precedent for tech companies promoting advanced AI capabilities on flagship hardware.