arXiv(opens in a new tab)cs.LGAug 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2608.30908

Fine-Tuning Low-Bit Models with Gradient in Quantized Code Space

Shiguang Wu, Zhouchen Lin, Quanming Yao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

Fine-tuning Low-bit models aims to adapt a quantized model while keeping the final deployed checkpoint in the same low-bit form. This setting is practically important as it reduces memory and inference cost for storage and deployment. Under this constraint, adaptation becomes an optimization problem over quantization codes and scales. Existing continuous low-bit training is efficient, but it can be distorted by straight through estimation error or by post-quantize gap; discrete search is deployment-faithful, but it is often too inefficient under a finite training budget. We propose code surrogate gradient as the first order signal in deployable code space to accelerate optimization, and performing guided search to preserve deployment faithfulness. Experiments across arithmetic reasoning, instruction following, and structured language understanding show that GradCodeS consistently improves fine-tuning low-bit models across different quantization datatypes. Code is provided at https://github.com/ovo67/GradCodes.

1 INTRODUCTION

Large language models (LLMs) are increasingly deployed in low-precision formats such as INT4, NF4, and MXFP4 to reduce storage, memory traffic, and inference cost (Xiao et al., 2023; Lin et al., 2024). These savings matter not only for a shared backbone, but also when many task- or user-specific checkpoints must be stored under a fixed memory budget. We study a strict fully low-bit setting in which the targeted weights of every adapted checkpoint remain in the target quantized representation, with only datatype-permitted scale metadata and no high-precision residual adapter at inference time (Jeon et al., 2025; Malinovskii et al., 2024). Under this constraint, fine-tuning is no longer optimization in a nearly continuous floating-point space; it is optimization over quantization codes and scales.

One practical strategy retains continuous optimization. Quantized-backbone adapter methods train high-precision LoRA-style parameters and either keep them at inference time or merge and requantize them afterward (Dettmers et al., 2023; Li et al., 2024; Loeschcke et al., 2024; Xu et al., 2024). This is effective when mixed-precision deployment or a separate conversion stage is acceptable. Under the stricter setting above, however, retaining the adapter violates the deployment constraint, while merging and requantizing can make the evaluated low-bit state differ from the state optimized during training. Quantization-aware and compressed-representation methods move optimization closer to the final checkpoint (Jeon et al., 2025; Malinovskii et al., 2024), but still leave a fundamental question: how should first-order information be expressed when the actual decision variable is a quantization-code index?

Direct discrete and zeroth-order approaches instead evaluate candidates in or near the quantized model family (Zhou et al., 2025; Shang et al., 2026; Xu et al., 2026), but random or population proposals can require many forward evaluations in high-dimensional code spaces. The central challenge is to combine deployment-faithful selection with first-order directional guidance.

To be deployment-faithful, we optimize over quantized code coordinates rather than weight. To be efficient, we try to find more useful information beyond zero-order. Based on this principle, we propose GradCodeS, a gradient-guided search method. We first identify that mapping ordinary

Figure

(a) Geometry mismatch between weight and code spaces.

(b) Accuracy under different deployment regimes.

Figure 1: Motivation for deployment-faithful code-space optimization. (a) Group scales and non-uniform codebook gaps distort local geometry, so a weight gradient does not identify the best discrete code move. (b) In the Llama-3.2-1B GSM8K example, continuous adaptation either retains an FP16 adapter or loses 13.4 points after QLoRA requantization; GradCodeS improves the fully 4-bit result while retaining a deployable checkpoint.

gradient in weight space to code space is generally not the steepest descent direction in code space, as illustrated in Figure 1(a), thus introducing a code-coordinate surrogate gradient by codebook continuation, serving as first-order information in code space with theoretical support. GradCodeS uses code-coordinate surrogate gradient descent to provide reference and then samples multiple nearby code candidates biased toward that reference and selects an update only according to its realized deployed loss. Thus every selected iterate is a valid low-bit checkpoint. This rule is parameterization-agnostic and datatype-agnostic: it can be instantiated on full weights, integrated with structured parameterizations such as LoRA, combined with joint scale optimization, and paired with different quantization datatypes.

Our contributions can be summarized as follows:

• We derive a code-coordinate surrogate gradient and establish its local steepest-descent interpretation under codebook continuation.

• We develop a guided candidate-sampling algorithm that combines first-order guidance with loss-based selection over deployable low-bit candidates.

• We evaluate GradCodeS across three task families, multiple quantization datatypes, and both full and structured code parameterizations, observing consistent gains in the fully low-bit setting.

References (38)

  • QLoRA: Efficient finetuning of quantized LLMs
  • GPTQ: Accurate post-training quantization for generative pre-trained transformers
  • Oops i took a gradient: Scalable sampling for discrete distributions
  • LoRA: Low-rank adaptation of large language models
  • L4Q: Parameter efficient quantization-aware fine-tuning on large language models
  • Reheated gradient-based discrete sampling for combinatorial optimization
  • LoftQ: LoRA-fine-tuning-aware quantization for large language models
  • AWQ: Activation-aware weight quantization for LLM compression and acceleration
  • Gradient-guided importance sampling for learning binary energy-based models
  • LoQT: Low-rank adapters for quantized pretraining
  • Guided evolutionary strategies: Augmenting random search with surrogate gradients
  • PV-Tuning: Beyond straight-through estimation for extreme LLM compression
  • Fine-tuning quantized neural networks with zeroth-order optimization
  • Discrete langevin samplers via wasserstein gradient flow
  • Revisiting sampling for combinatorial optimization
  • Efficient informed proposals for discrete distributions via Newton's series approximation
  • SmoothQuant: Accurate and efficient post-training quantization for large language models
  • Quantized evolution strategies: High-precision fine-tuning of quantized LLMs at low-precision cost (opens arXiv in a new tab)
  • QA-LoRA: Quantization-aware low-rank adaptation of large language models
  • MetaMath: Bootstrap your own mathematical questions for large language models
  • A Langevin-like sampler for discrete distributions
  • QuZO: Quantized zeroth-order fine-tuning for large language models
  • We evaluate on three datasets covering arithmetic reasoning, general instruction following, and mobile-style language understanding
  • We use the same target modules, quantization format, training data, and evaluation scripts whenever applicable
  • Every selected update is a deployable low-bit state, so the final model does not require a 16-bit adapter or high-precision residual branch at inference time
  • Table 6 summarizes these components for the evaluated datatypes
  • The deployed weight is
  • A feasible code move changes an entry by
  • Here datatype-agnostic refers to the common optimization rule, not to identical feasible spaces; every candidate is still evaluated through the appropriate recovery map in (6)
  • For an actual code-coordinate move $\Delta Z \in \mathbb{Z}^{d_{\mathrm{out}} \times d_{\mathrm{in}}}$, the deployed-weight change is exactly
  • Writing $\sigma = \mathrm{sign}(\nabla_{\widehat{W}}L)$, the corresponding nonnegative directional slope is
  • Applying the chain rule to this local continuation yields
  • Hence $-\nabla_Z L(Z, s)$ is the steepest descent direction of $\bar{L}_{Z,s}$ at $\Delta Z = 0$ under the Frobenius norm
  • If $\Delta Z_{ij} = 0$, both sides contribute zero
  • If $\Delta Z_{ij}=-1$, feasibility gives $Z_{ij}>1$, and gradient alignment gives $(\nabla_{\widehat{W}}L(Z,s))_{ij}\geq0$
  • Therefore, for every coordinate
  • At iteration t, define the code-space surrogate gradient and continuous reference step by
  • As a result, the same rule can also be used with other parameterizations