GLM-5.2: Built for Long-Horizon Tasks

GLM-5.2: Built for Long-Horizon Tasks

GLM-5.2 Overview

GLM-5.2 is a flagship model designed for long-horizon tasks, featuring a solid 1M-token context and released under an MIT open-source license.

Key Capabilities

GLM-5.2 provides a solid 1M-token context that sustains long-horizon work, advanced coding with flexible effort levels, architectural improvements that reduce compute cost, and fully open access.

Solid 1M Context

GLM-5.2 maintains quality across long, messy coding-agent trajectories, not just accepting more tokens, by substantially expanding 1M-context training for coding-agent scenarios.

Advanced Coding with Flexible Effort

GLM-5.2 offers multiple thinking effort levels to balance performance and latency, allowing users to allocate additional computation when higher performance is required.

Improved Architecture

GLM-5.2 introduces IndexShare, which reuses the same indexer across every four sparse attention layers, reducing per-token FLOPs by 2.9× at a 1M context length, and improves the MTP layer for speculative decoding, increasing acceptance length by up to 20%.

Pure Open

GLM-5.2 is released under an MIT license with no regional limits, providing technical access without borders.

Performance on Long-Horizon Coding Benchmarks

GLM-5.2 demonstrates strong long-horizon delivery capability, ranking as the highest-ranked open-source model across three benchmarks.

On FrontierSWE, GLM-5.2 trails Opus 4.8 by only 1%, edges out GPT-5.5 by 1%, and outperforms Opus 4.7 by 11%.

On PostTrainBench, GLM-5.2 outperforms both Opus 4.7 and GPT-5.5, ranking second only to Opus 4.8.

On SWE-Marathon, GLM-5.2 trails Opus 4.8 by 13% while remaining second only to the Opus series.

Across all three benchmarks, GLM-5.2 is the highest-ranked open-source model, showing that its 1M context translates into practical long-horizon capability.

Performance on Standard Coding Benchmarks

GLM-5.2 achieves strong results on standard coding benchmarks, improving markedly over its predecessor and narrowing the gap to closed‑source frontier models.

On Terminal‑Bench 2.1, GLM-5.2 scores 81.0 versus GLM-5.1’s 63.5, landing within a few points of Claude Opus 4.8’s 85.0 and staying ahead of Gemini 3.1 Pro.

On SWE‑bench Pro, GLM-5.2 scores 62.1 versus GLM-5.1’s 58.4.

Effort Level Control

GLM-5.2’s effort level control lets users explicitly balance model capability against execution speed and computational cost.

At comparable token budgets, GLM-5.2 delivers substantially stronger agentic coding performance than GLM-5.1, with capability roughly positioned between Claude Opus 4.7 and Claude Opus 4.8.

The Max effort level allows additional computation for challenging tasks, further extending coding capability.

This design gives users flexibility to select the most suitable reasoning mode for different scenarios.

Architecture for 1M Context

GLM-5.2’s architectural changes enable efficient processing of very long sequences.

IndexShare for DSA

In GLM-5.2, every four transformer layers share a lightweight indexer, placed at the first layer and reused for the next three layers, reducing the computation of indexer dot product and topk operations in three‑quarters of the layers.

GLM-5.2 is trained with IndexShare from mid‑training using 128K sequence length, outperforming GLM-5.1 on long‑context benchmarks with less computation.

MTP with IndexShare and KVShare

The MTP layer of GLM-5.2 is improved for speculative decoding by applying IndexShare to reduce cost and by using KV cache reuse to eliminate training‑inference discrepancy.

Ablation studies show that adding IndexShare + KV Share raises acceptance length from 4.56 to 5.10, adding rejection sampling raises it to 5.29, and adding end‑to‑end TV loss raises it to 5.47, a 20% increase over the baseline.

Efficiently Serving 1M Context Length

GLM-5.2 extends maximum context length from 200K to 1M tokens, shifting the inference bottleneck from computation to KV‑cache capacity, long‑context kernel overhead, and CPU‑side overhead.

To address this, the inference engine is optimized via finer‑grained memory management (building on LayerSplit), kernel optimizations that coordinate with cache transfer, and CPU‑side cache management and request scheduling to reduce pipeline bubbles.

As a result, GLM-5.2 achieves an increasingly larger throughput advantage as context length grows, demonstrating stronger scalability in long‑context inference scenarios.

slime for Agentic RL

The slime framework serves as an integrated infrastructure layer for GLM-5.2’s agentic RL post‑training, supporting multiple training and task organization modes.

In the post‑training process, slime was used to conduct parallel OPD training, efficiently merging more than ten expert models into the final model, with the entire OPD training taking approximately two days.

slime provides a highly open and flexible interface to inference systems, allowing the training side to connect to inference services in different forms and adapt to various parallelism strategies, routing policies, PD disaggregation setups, and deployment patterns.

Configuration experience, scheduling strategies, and optimization paths accumulated during RL rollout can be reused in production serving, creating a direct path from post‑training to deployment.

Together with flexible training‑inference resource organization and KV‑cache FP8, slime provides critical infrastructure support for GLM-5.2’s large‑scale agentic RL training, improving system efficiency, rollout throughput, and large‑scale inference concurrency.

RL for Long‑Horizon Task with Anti‑hacking

GLM-5.2’s RL for long‑horizon tasks moves from group‑wise optimization to a critic‑based PPO formulation that learns from individual rollouts, using a critic to estimate token‑level advantages.

This single‑rollout formulation naturally accommodates compaction, as it places no constraint on the number or length of traces produced by a prompt.

To counter reward hacking in coding agents, GLM-5.2 introduces an anti‑hack module with two stages: a rule‑based filter that flags potential hacks for high recall, followed by an LLM judge that checks intent to maintain high precision.

The system monitors tool calls at each step; if a hack is detected, the call is blocked and dummy information is returned, allowing the rollout to continue after the invalid behavior is handled.

This online guard prevents training instability and model collapse that can occur when rollouts are abruptly stopped.

Getting Started with GLM-5.2

Use GLM-5.2 with GLM Coding Plan

GLM-5.2 is available in popular coding agents such as ZCode, Claude Code, and OpenCode.

For GLM Coding Plan subscribers, the model is already rolled out; users can enable it by setting the model name to "GLM-5.2" (or "GLM-5.2[1m]" in Claude Code to activate 1M context).

Different thinking effort levels (High or Max) can be selected depending on the task.

GLM-5.2 consumes quota at 3× during peak hours and 2× during off‑peak hours; as a limited‑time promotion through the end of September, off‑peak usage is billed at 1×.

Peak hours are defined as 14:00–18:00 UTC+8 (Beijing Time) daily.

A desktop agent, ZCode, powered by GLM-5.2, offers a /goal command for long‑horizon tasks, SSH remote development, and mobile control.

Special offer: using GLM-5.2 through the Coding Plan inside ZCode yields 1.5× effective quota until June 30.

Users can start building at https://z.ai/subscribe.

Chat with GLM-5.2 on Z.ai

GLM-5.2 is now available for chat at https://chat.z.ai/.

Serve GLM-5.2 Locally

The model weights are publicly available on Hugging Face at https://huggingface.co/zai-org/GLM-5.2 and on ModelScope at https://modelscope.cn/models/ZhipuAI/GLM-5.2.

For local deployment, GLM-5.2 supports inference frameworks including transformers, vLLM, SGLang, xLLM, and ktransformers.

Sources