Repository navigation
Conversation
Ringssss
marked this pull request as ready for review
November 19, 2026 07:37
humannumber196
force-pushed
the
feat/clover-hygon-diffusion
branch
from
November 26, 2026 07:52
5698cc1 to
a653798
Compare
humannumber196
added a commit
to Ringssss/InfiniLM
that referenced
this pull request
Nov 26, 2026
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.
humannumber196
added a commit
to Ringssss/InfiniLM
that referenced
this pull request
Nov 26, 2026
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.
humannumber196
added a commit
to Ringssss/InfiniLM
that referenced
this pull request
Nov 27, 2026
Round-3 review fixes for PR InfiniTensor#604. A request whose client disconnects while queued no longer takes the generation slot: Uvicorn keeps the task of this non-streaming route alive, so a disconnect watcher polls the ASGI disconnect state and marks the waiter gone. The waiter owns an event and a separate done flag, so a queued request that is cancelled - even when an outer coroutine swallows the cancellation and keeps its task alive - is removed from the queue at the wait's finally, and a successor only advances when the head's done flag records that its slot was actually released by a finished generation. The queue head waits on an empty-queue guard and the dispatch re-checks liveness inside the lock, keeping the running generation exclusive and the successor strictly serial.
humannumber196
force-pushed
the
feat/clover-hygon-diffusion
branch
from
November 27, 2026 02:11
b487ea0 to
ad75d7e
Compare
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.
The chat endpoint hands its single engine slot to one request at a time and drops requests whose client is gone: the wait for the slot is a cancellable asyncio.Lock acquisition, a task-group watcher consumes the ASGI http.disconnect message while the request is queued, and the worker that runs the synchronous generation releases the slot from a done- callback, so a cancelled or disconnected waiter never starts a generation and a running one keeps the slot until it returns. A queued request re-checked for disconnects on admission, the effective token cap is computed once and shared by the generation and finish_reason (max_completion_tokens honored, including a zero cap), stop sequences and n > 1 answer 4xx, and an indexed device - string or object - maps its rank onto the TP config. The Clover forward entry validates the MRoPE positions on prefill, preview and replay alike: the packed [tokens] row or the [3, tokens] axis-row form, before any device submit, and the preview input is exactly [1, block_size]. The logits copies in the generator and the engine-logits script stage through a buffer of the source dtype, so FP32 logits of a BF16 model survive untruncated. The engine-logits first-block comparison generates with ignore_eos and requires the complete block, so an early EOS cannot truncate both sides into a vacuous pass; compare_logits returns zero samples for a stage no case recorded instead of failing on an empty concatenation. New tests cover disconnect-while-queued, buffered disconnects, cancellation of the running and the queued request, and run in CI with the anyio host dependency.
reset_cache zeroes the KV, convolution and recurrent caches in place when batch size and capacity are unchanged, and reallocates only when they differ; Clover now asks the hybrid cache allocator for FP32 recurrent state directly instead of allocating the model dtype and replacing it. The allocator takes that dtype as an optional argument, so the Qwen3-Next and Qwen3.5 callers keep their behavior. The generator validates max_context against the checkpoint's position table before loading weights, replays a block only when another block follows it, skips the cache reset when no token is requested, and returns the prompt token count it actually prefilled. The chat endpoint reports that count as prompt_tokens, maps chat-template failures to 400, and bounds the frontier confidence floor by the policy's own threshold for HTTP and the CLI alike. The Clover server tests move under test/service and load the module from source the way the other service tests do, so the host CI job can run them without the InfiniLM package or Torch; the CI dependency line drops the no longer needed anyio. A generation test covers the block hand-off, the skipped replay of the last block and the EOS exit. The accuracy tools grow stricter: two-dimensional logits are checked per case for their full shape, a missing required stage is an error rather than a silently dropped table row, the forced-trajectory reference keeps the first-step data the replay needs, the replay checks the cache and position range up front, the MRoPE probe runs only the supported layouts and fails on a numeric mismatch, and the benchmark client records empty candidates and timeouts as failures.
humannumber196
force-pushed
the
feat/clover-hygon-diffusion
branch
from
November 27, 2026 08:42
b5a9094 to
70a056e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
clover_moemodel using the existing Qwen3.5-MoE modules, strict checkpoint mapping, FP32 recurrent state and native InfiniOps providers.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:
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 pathtest— checkpoint mapping, frontier and full-model validationdocs— supported configuration and reproductionbuild— dependency pin / optional decoder dependenciesTest 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:
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.
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.
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.pyandtest/diffusion/workload.jsonreproduce the HTTP workload. Seedocs/clover-hygon.mdfor 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
feat/with hyphen-separated words.mainat preparation.Scope and Design
General Code Hygiene
git diff --checkpassed.C++ Specific
llama_legacy.scripts/format.pywith the CI formatter version.Python Specific
auto_config.py.Testing
examples/test_infer.py: AR entry point; dedicated Clover generator validated instead.examples/bench.py: AR entry point; paired Clover HTTP/offline measurements supplied instead.Build, CI, and Tooling
Documentation
Security and Safety