Skip to content

feat(clover): add native Hygon block diffusion and frontier decoding - #604

Open
Ringssss wants to merge 13 commits into
InfiniTensor:mainfrom
Ringssss:feat/clover-hygon-diffusion
Open

Ringssss wants to merge 13 commits into
InfiniTensor:mainfrom
Ringssss:feat/clover-hygon-diffusion

Conversation

@Ringssss

@Ringssss Ringssss commented Oct 29, 2026 •

Copy link
Copy Markdown

Summary

  • Register the text-only clover_moe model using the existing Qwen3.5-MoE modules, strict checkpoint mapping, FP32 recurrent state and native InfiniOps providers.
  • Separate read-only block preview from causal replay/commit. Preview uses bidirectional GDN/convolution and Clover block coreset routing; unresolved masks are never committed.
  • Add an optional frontier stride decoder and expert-budget/live-row reuse, a serial OpenAI chat endpoint, a portable paired benchmark client, controlled workload, tests and build instructions.
  • Pin the matching InfiniCore dependency stack.

Motivation

Clover-35B-A3B-Preview was unsupported by the native Hygon stack. This runs full checkpoint inference in InfiniLM C++ on two Hygon BW 64GB DCUs. Torch is used for token-confidence selection; model forward does not use a Torch/Transformers or SGLang fallback.

Dependencies, in order:

  1. feat(hygon): expose driver modules and device attributes InfiniRT#52
  2. feat(hygon): add native Clover diffusion and sparse MoE operators InfiniOps#1015
  3. chore: pin Hygon Clover runtime and operator support InfiniCore#1579

The dLLM-serve adaptation is the frontier/stride mechanism, with a confidence floor and immediate progress for already-confident positions. The supplied dllm-h100 study informs top-4 preview routing and TV6 live-row reuse with refresh interval five. This PR does not claim the full admission/compaction scheduler or the H100 DP/EP communication pipeline. The endpoint currently serializes requests; that boundary is explicit in the guide.

Type of Change

  • feat — new model and decoding path
  • test — checkpoint mapping, frontier and full-model validation
  • docs — supported configuration and reproduction
  • build — dependency pin / optional decoder dependencies

Test Results of Involved Models on Supported Platforms

Hygon BW/gfx936, DTK 26.04, Torch 2.10.0, Triton 3.5.0, BF16 TP2, eager static cache, 2048 context capacity:

Validation Result
Native build Repository xmake release build and installation passed; a separate CMake validation build also passed
Full checkpoint All 28 safetensors files loaded, including learned preview shards; real Chinese/English/code generation
Checkpoint/runtime/host regression 24 tests and 61 subtests passed
Clover-specific tests 3 tests passed; final PR build also passed 24 additional HTTP requests with 24/24 structural/answer checks
Companion InfiniRT 13 tests passed
Companion InfiniOps focused tests 62 passed
Companion CPU/Hygon Ops smoke 121 passed, 43 inactive-provider skips, 9485 deselected
Serving All 96 requests per variant completed successfully in the common OpenAI chat campaign
Controlled answer/structure checks Joint 96/96; expert-only 93/96; baseline/frontier/local SGLang 90/96
Dispatch evidence Both TP devices contain native Clover kernels; live-row kernel only in joint mode

The native baseline matched local SGLang token IDs on the four initial prompts. Other inputs can differ across the kernels' floating-point paths. These fixture checks do not establish general accuracy equivalence. The lower confidence floors 0.3/0.5 were rejected after repetition/invalid Python appeared.

Rendered validation record

This is a rendered record of measured test output, not a terminal screenshot. The original request/response logs and traces are retained with the local integration artifacts.

Benchmark / Performance Impact

Same complete model/tokenizer, BF16, TP2, greedy sampling, neutral penalties, thinking disabled, 32 mixed prompts, three measured repetitions after warmup, concurrency one. Prompt/output caps and client endpoint are shared. Throughput uses visible completion tokens retokenized with the same tokenizer, divided by summed client request time; padded diffusion usage counters are excluded.

Variant Output tok/s Per DCU tok/s
Native baseline 28.57 14.29
Frontier only 38.47 19.24
Expert budget/live reuse only 28.70 14.35
Joint, floor 0.7 39.92 19.96
Local SGLang Clover iterative port 5.88 2.94

Joint/native is 1.397x and joint/local-SGLang is 6.791x. Joint repetitions measured 39.85–40.02 tok/s. This is serial short-prompt throughput, not peak concurrent capacity, and compares the local iterative SGLang port rather than Clover's official self-speculative implementation. The SGLang reference runs on a separate identical TP2 pair on the same host.

examples/bench_clover.py and test/diffusion/workload.json reproduce the HTTP workload. See docs/clover-hygon.md for launch/build details. Separate profiles verify dispatch and are excluded from timing.

Notes for Reviewers

Supported now: BF16, Hygon, eager/static cache, greedy non-streaming text, causal block commit. The model's 128K maximum context, general continuous batching, graphs, multimodal input, stochastic sampling and official AR-verify speculation are not validated by this change. Unsupported endpoint options are rejected explicitly.

Review block/slot boundaries, state immutability, full-route causal replay after approximate preview, and the shared attention preview flag. The checkpoint cast bridge also rejects same-address dtype conversion before writing, restoring an existing loading regression invariant discovered during integration.

This remains a draft pending dependency review and the broader model/service integration expected by the repository. The dedicated Clover generator/server is the validated path; the generic AR examples/test_infer.py / examples/bench.py / benchmark suite does not yet drive diffusion.

CI / ChatOps

Fork Ruff CI passed. The rerun at https://github.com/Ringssss/InfiniLM/actions/runs/40928429479 passed Host behavior, Check Format, dependency identity, and matrix generation. The NVIDIA build/package job is queued for an external runner. The earlier fork-only format failure was caused by a stale fork main; syncing the fork resolved it without unrelated source changes. Local checks using the CI formatter versions also pass all 24 changed code files.


Checklist

Title, Branch, and Commits

  • PR title follows Conventional Commits.
  • Branch uses feat/ with hyphen-separated words.
  • Commit follows Conventional Commits and is squashable.
  • No merge/fixup/wip commits; based on current main at preparation.
  • N/A: legacy issue format is not used.

Scope and Design

  • Changes implement the stated model/decoder/dependency scope.
  • No debug prints or unrelated code in model execution.
  • Public input flags and supported boundaries are documented.
  • No unrelated formatting churn.

General Code Hygiene

  • English comments/messages, trailing newlines and no whitespace errors.
  • Third-party provenance and licenses recorded.
  • git diff --check passed.

C++ Specific

  • Model code uses existing owning tensors, modules and runtime/stream resources.
  • No changes to llama_legacy.
  • Changed files pass scripts/format.py with the CI formatter version.

Python Specific

  • Ruff and syntax checks passed.
  • Docstrings and comments use English.
  • No changes to auto_config.py.

Testing

  • Real Hygon build, operator and full-model tests recorded above.
  • Other accelerator hardware validation: unavailable locally.
  • Generic examples/test_infer.py: AR entry point; dedicated Clover generator validated instead.
  • Generic examples/bench.py: AR entry point; paired Clover HTTP/offline measurements supplied instead.
  • Full C-Eval/MMLU sanity suite: not run; controlled fixture is not a substitute for that evaluation.
  • Generic inference server: dedicated serial Clover OpenAI endpoint validated instead.

Build, CI, and Tooling

  • Native Hygon release build passed.
  • Manual CI workflow dispatched; external hardware jobs remain pending.

Documentation

  • Build, deployment, methods, measurement and supported boundaries documented.
  • N/A: no default behavior change for existing models; optimizations are opt-in.

Security and Safety

  • No secrets, private URLs or personal hardware identifiers committed.
  • Third-party terms and sources retained.
  • Mask/state/workspace bounds and lifetime contracts covered by checks/tests.

@Ringssss
Ringssss marked this pull request as ready for review November 19, 2026 07:37
@Ringssss
Ringssss requested a review from a team November 19, 2026 07:37
Ringssss and others added 11 commits November 26, 2026 15:16
CloverGenerator and the clover chat server hard-coded the Hygon platform,
which blocked the (already multi-device) InfiniOps providers from running
the native block-diffusion path on any other accelerator.

- CloverGenerator gains a device parameter (default "cuda") with an
  explicit platform -> Torch device mapping; engine dtype now flows into
  the logits copy-out instead of a fixed bfloat16, and every hard-coded
  cuda:0 / hygon literal is derived from the selected device.
- clover_server --device (default auto) reuses the framework's device
  resolution; --tp default drops to 1 for single-GPU startup.
- Docs describe the validated A100 (CUDA 13.1, TP2) configuration next
  to the Hygon one.
- Ignore pip editable-install artifacts; bump the InfiniCore submodule
  pointer to the multi-device InfiniOps operators.

Verified on NVIDIA A100 TP2 with Clover-35B-A3B-Preview: baseline and
frontier policies generate correct text; device aliases (cuda/nvidia)
resolve identically and unknown platforms are rejected up front.
`CloverGenerator._forward` passed `[1, tokens]` positions. `Mrope` reads a
two-dimensional tensor as `[3, tokens]` axis rows, so with contract asserts
compiled out the kernel took the h and w rows from the memory after the
positions buffer. Clover uses a single position axis, so pass the packed
`[tokens]` form.
The top-level README's entries build InfiniOps as Release through `pip
install` and InfiniCCL as Release through `scripts/build.sh`, while the
InfiniRT command sets no build type. The Hygon block now matches them.
`examples/test_clover.py` generates text for a few prompts.

`test/diffusion` records the logits of the checkpoint's reference
implementation along its block diffusion trajectory, replays the same
trajectory with the engine and reports the KL divergence from a float32
reference. A probe compares the `Mrope` kernel with the checkpoint's rotary
for each positions layout.
Clover runs on both platforms, so the guide and its CMake preset drop the
`-hygon` name, the README entry is no longer "Clover on Hygon", and the
build, generation and serving examples start from NVIDIA with the Hygon
differences noted. A note that applies to both platforms moves out of the
Hygon build block, and the throughput numbers are labelled as recorded on
Hygon. The validation image keeps its name: it is the record of the Hygon
campaign.

The guide also gains two notes. On Hygon gfx936 the fused MoE runs the native
InfiniOps kernels, and INFINI_OPS_HYGON_MOE_TRITON=1 selects the Triton ones.
The `pip install -e` step copies the Infini libraries into
python/infinilm/_lib and the package loads those copies, so it has to be
repeated after rebuilding one of them.
InfiniOps PR #1015 replaces CloverRecurrentGdn with a packed overload of
RecurrentGatedDeltaRule that takes the state pool, the sequence offsets
and the initial and final slots. The causal replay of the GDN layer
calls it; the preview operators are unchanged.

BREAKING CHANGE: requires InfiniOps PR #1015 at 3a046113 or later.
The InfiniOps guide that held these notes is removed upstream. Keep in
the InfiniLM guide what matters here: which shapes take the native
kernels, how to select the Triton kernels, and the measured gain for
spread and concentrated routing.
InfiniOps dropped INFINI_OPS_DECLARATIONS in favor of ops.json
selection. The InfiniLM profiles ship in the InfiniOps checkout
(scripts/configs/infiniops_ops_{hygon,nvidia}_infinilm.json) beside its
own build profiles, documented in its docs/build-hygon-inference.md; the
guide's build commands pass them through -DINFINI_OPS_OPS. docs/clover-
ops.cmake and the two repository-local json files are gone.

BREAKING CHANGE: the documented InfiniOps build passes -DINFINI_OPS_OPS
pointing into the InfiniOps checkout instead of -C docs/clover-
ops.cmake.
Add the NVIDIA counterpart of the Hygon validation record: the same
client, workload, prompts and sampling controls on two A100 80GB with
TP=2, BF16 and concurrency one, 32 prompts x 3 repeats after a warmup.

  baseline  96/96  44.09 tok/s        joint  96/96  58.51 tok/s

The joint path is 1.327x the native baseline. Each variant answered the
workload's own check on all 96 requests; this checks the fixture, not
general quality. The SGLang comparison was not run (that port is not
available on the NVIDIA host).

Also reword the note that placed every throughput number on Hygon.
The clover extras duplicated the server and torch groups under a model
name and carried triton, which nothing in InfiniLM imports: it is a
runtime dependency of the InfiniOps in infini package, and the DTK Torch
wheel ships it. Installing '.[server,torch-compat]' covers serving and
local generation alike; the guide states what each group is for and
where Triton comes from.
@humannumber196
humannumber196 force-pushed the feat/clover-hygon-diffusion branch from 5698cc1 to a653798 Compare November 26, 2026 07:52
Review fixes for PR InfiniTensor#604.

Server: the generation lock is a threading lock held inside the worker
for the whole synchronous generate, so a cancelled request coroutine no
longer releases the slot while its thread still runs - a second request
waits for the first generation to actually return instead of resetting
the engine cache under it. The OpenAI endpoint maps
max_completion_tokens onto the generation cap and rejects stop sequences
and n > 1 with a 4xx instead of silently ignoring them.

Generator: the logits copy stages through a buffer of the source dtype,
so a BF16 model with an FP32 output head copies FP32 logits without
truncation (the engine_logits script likewise); the TP ranks sit on the
caller's indexed device for tp=1, while a bare platform name keeps the
first tp ranks.

Native entry: the preview input must be exactly [1, block_size] - [2,
16] and [1, 64] take unsupported paths through the layers - and the
MRoPE positions are checked for the packed [tokens] or axis-row [3,
tokens] layout before any device submit; a 2-D [1, T] row would
otherwise read out of bounds in release builds.

Scripts: the engine_logits first-block comparison generates with
ignore_eos and compares the complete block, so an early EOS no longer
truncates both sides into a vacuous pass; compare_logits returns zero
samples for a stage no case recorded instead of crashing on an empty
concatenation.
Round-2 review fixes for PR InfiniTensor#604.

The MRoPE position validation moved from the preview branch to the
shared Clover forward entry, so prompt prefill and causal replay are
checked as well: positions must be the packed [tokens] row or the [3,
tokens] axis-row form on every path, before any device submit.

The OpenAI endpoint computes one effective token cap and shares it
between the generation and the finish_reason, so an honored
max_completion_tokens request reports `length` at exactly that cap,
including a cap of zero.

A device object names one specific accelerator like an indexed string
does: both map their normalized index onto the TP config for tp=1, while
a bare platform name keeps the first tp ranks.

The generation slot is one FIFO that every request joins, the running
one included. A request cancelled while waiting vanishes at its own
await point before any worker starts; a request cancelled after dispatch
keeps its shielded worker to the end so the slot is released exactly
once. A queued request cancelled just before its worker would start is
seen by the worker and yields without generating.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants