kl-divergence llm-quantization post-training-quantization agent-based model-accuracy glm-5-3-flash closed-loop-design ptq-methods
Abstract
Post-training quantization is the standard way to serve large language models at low cost. However, the best quantization recipe differs across models and precisions. As a result, experts must redesign it for every new model, which is time-consuming and often sub-optimal. Fortunately, an LLM agent can take over this design by refining the recipe over rounds of building and evaluating candidates, so that more rounds lead to better recipes. However, evaluating one quantized reasoning model takes tens of GPU-hours, and combining methods from different codebases means porting each to the new architecture by hand. We present QDA, a system in which an agent designs the recipe for each model and precision. To make evaluation fast, QDA scores each candidate in minutes by its output KL divergence from the original model on reasoning traces that the agent never sees, and checks promising ones with long generations to catch failures such as repetition loops. To make building fast, QDA provides a library of public PTQ methods that are compatible with one another and with new model architectures. Across four reasoning models, QDA improves accuracy over the strongest public recipe by 0.9, 1.4 and 2.2 percentage points on average at W4A16, W4A8 and W3A16, using 64 GPU-hours per search. On the 320B-parameter MoE model GLM-5.3-Flash at NVFP4 W4A4, it recovers 98.3% of the FP8 model's accuracy, against 96.9% for the best vendor checkpoint. Every QDA checkpoint also runs on existing serving kernels with no inference overhead. We will release the library, the evaluator and the harness.
한국어 요약
한 줄 요약
QDA는 LLM의 정량화 레시피를 에이전트가 설계하는 시스템으로, 기존 레시피 대비 정확도를 0.9~2.2% 개선한다.
핵심 기여도
- QDA는 LLM 에이전트가 정량화 레시피를 설계하는 첫 시스템으로, 기존 공개 레시피 대비 0.9~2.2%의 정확도 향상.
- KL 발산 기반의 빠른 평가 메트릭을 도입, 350~990× 저비용으로 후보 평가.
- 21개의 공개 PTQ 메서드를 호환 가능한 라이브러리로 통합, 새로운 아키텍처에도 적용 가능.
- GLM-5.3-Flash 모델에서 98.3%의 FP8 정확도 회복, 기존 베스트 체크포인트 대비 1.4% 개선.
핵심 아이디어
기존 PTQ 레시피는 모델과 정밀도에 따라 달라지며, 전문가가 수작업으로 설계하는 과정은 비효율적이다. QDA는 LLM 에이전트가 레시피를 반복적으로 설계하고 평가하는 방식을 도입한다. 핵심 아이디어는 두 가지다: 첫째, KL 발산을 기반으로 레시피 후보를 빠르게 평가하여, 기존 방식 대비 350~990배 저비용으로 탐색 가능하다. 둘째, 21개의 공개 PTQ 메서드를 호환 가능한 라이브러리로 통합하여, 새로운 아키텍처에도 쉽게 적용할 수 있도록 했다. 이는 기존 연구 코드가 분산되어 있어 수작업 포팅이 필요했던 문제를 해결한다.
기술적 접근법
- **KL 발산 기반 평가**: 후보 레시피의 출력 분포와 원본 모델의 분포 간 KL 발산을 계산하여, 빠르게 평가.
- **Reference Traces**: 원본 모델이 생성한 추론 트레이스를 사용, 에이전트는 이 데이터를 보지 않고 평가.
- **PTQ 라이브러리**: 21개의 공개 PTQ 메서드를 호환 가능한 인터페이스로 통합. 각 메서드는 입력 체크포인트를 받아 출력 체크포인트를 반환.
- **하이퍼파라미터**: 탐색당 64 GPU-시간 소요. GLM-5.3-Flash 모델에서는 6.5시간 검색으로 98.3%의 FP8 정확도 회복.
주요 결과
- **4개 추론 모델 평균 정확도 개선**: W4A16, W4A8, W3A16에서 각각 0.9%, 1.4%, 2.2% 개선.
- **GLM-5.3-Flash 모델**: NVFP4 W4A4에서 98.3%의 FP8 정확도 회복 (기존 베스트 체크포인트 대비 1.4% 개선).
- **에이전트 대비 탐색 알고리즘**: QDA는 탐색 알고리즘인 Greedy Search, ASHA 대비 0.2~1.2% 더 높은 정확도.
- **라이브러리 없이 탐색 시**: 정확도 0.2~0.5% 감소, 코드량 3배 증가, 실패율 2배 증가.
의의 및 한계
QDA는 정량화 레시피 설계를 자동화하여, 모델당 수작업 레시피 작성의 비용을 줄이고, 다양한 아키텍처와 정밀도에 대한 최적화를 가능하게 한다. 특히, KL 발산 기반의 저비용 평가와 호환 가능한 PTQ 라이브러리는 기존 연구의 한계를 극복한다. 그러나 QDA는 여전히 GPU-시간을 64시간 이상 소요하며, 모든 PTQ 메서드를 라이브러리에 통합하지는 않았다. 또한, 에이전트가 생성한 코드의 안정성과 확장성에 대한 검증이 추가적으로 필요하다.
실용적 활용
QDA는 대규모 언어 모델의 저비용 서비스를 가능하게 하며, 특히 새로운 모델이 빠르게 출시되는 환경에서 레시피 설계 자동화에 유용하다. 연구자나 엔지니어는 QDA를 사용해 다양한 정밀도와 아키텍처에 맞춘 최적의 정량화 레시피를 효율적으로 탐색할 수 있다.