Skip to content

feat: add Clover support - #31306

Open
Maphist0 wants to merge 2 commits into
ggml-org:masterfrom
Maphist0:dev-clover
Open

Maphist0 wants to merge 2 commits into
ggml-org:masterfrom
Maphist0:dev-clover

Conversation

@Maphist0

Copy link
Copy Markdown
Contributor

Overview

Add support for DiffuSpace's Clover-35B-A3B-Preview, including GGUF conversion, loading and hybrid attention.

Following the DFlash #22105 and DFlash2 series (#27342, #27816), this adds another speculative decoding mode:

  • draft-self, for self-speculative generation through the existing speculative framework.

The same model proposes masked blocks and verifies them causally. Block construction is shared with DFlash; no separate draft model is required.

The speculative example includes opt-in entropy-threshold acceptance for unconstrained temperature-zero decoding.

Additional information

Validated with BF16 CPU and H200 CUDA inference.

Validation:

CPU compile:

cmake -S source -B build-clover-cpu \
    -DGGML_CUDA=OFF \
    -DGGML_BLAS=OFF \
    -DLLAMA_CURL=OFF \
    -DLLAMA_BUILD_TESTS=OFF \
    -DLLAMA_BUILD_SERVER=OFF \
    -DCMAKE_BUILD_TYPE=Release

cmake --build build-clover-cpu --target llama-speculative-simple

CUDA compile:

cmake -S source -B build-clover-cuda \
    -DGGML_CUDA=ON \
    -DCMAKE_CUDA_ARCHITECTURES=90a \
    -DLLAMA_CURL=OFF \
    -DLLAMA_BUILD_TESTS=OFF \
    -DLLAMA_BUILD_SERVER=OFF \
    -DCMAKE_BUILD_TYPE=Release

cmake --build build-clover-cuda --target llama-speculative-simple

Ckpt convert:

python source/convert_hf_to_gguf.py \
    <clover_ckpt_path> \
    --outtype bf16 \
    --outfile clover-bf16.gguf

The example llama-speculative-simple program:

build-clover-cuda/bin/llama-speculative-simple \
    -m clover-bf16.gguf \
    --spec-type draft-self \
    --spec-draft-n-max 15 \
    --spec-accept-ratio 0.9 \
    --spec-accept-delta 0.6 \
    -ctk bf16 -ctv bf16 \
    -f explanation.prompt \
    -n 64 -c 1024 -b 256 -ub 256 \
    --temp 0 --top-k 1 --seed 42 \
    -ngl 99 -t 8 -tb 8 --flash-attn on --color off

// another example

build-clover-cuda/bin/llama-speculative-simple \
    -m clover-bf16.gguf \
    -p "Here is a quick sort implementation in C++. Just code, no comments:\n\n#include" \
    --spec-type draft-self \
    --spec-draft-n-max 15 \
    --color on \
    --spec-accept-ratio 0.9 \
    --spec-accept-delta 0.6 \
    -ctk bf16 -ctv bf16 \
    -n 256 --temp 0 --top-k 1 --seed 42 -ngl 99 -lv 4

The current implementation generates around 32 tokens/s on an H200, with substantial room for improvement. Further performance optimizations are planned as separate PRs.

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES, I've used GPT-6.1 Sol for majority of code generation under my review. Code generated by AI was reviewed before adding into the codebase.

Port Clover conversion, metadata, loading and hybrid attention to upstream. Reuse the current QKV, MoE and recurrent-memory infrastructure.
Share anchor-and-mask block construction with DFlash and register draft-self in the same speculative framework.
Add opt-in raw-logit entropy acceptance to the shared sampler for unconstrained temperature-zero decoding.
@Maphist0
Maphist0 requested review from a team, CISC and ggerganov as code owners October 28, 2026 10:22
@github-actions github-actions Bot added documentation Improvements or additions to documentation model Model specific examples conversion labels Oct 28, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conversion documentation Improvements or additions to documentation examples model Model specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant