Repository navigation
feat(models): add Xing4.0 (xing4_0) support - #3276
Merged
Merged
Conversation
Member
Author
Implementation Review SummaryIntent
Findings Addressed
Verified without change
Verification
|
Member
Author
Security and performance reviewFixed (HIGH): Checked with no change needed:
Open, not fixed (below the auto-fix threshold):
|
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
Add the bilingual technical report for PR #3276 covering the hyper-connection port, the opt-in YaRN table, the per-plane width solving, the tokenizer BOS default and the trace results.
Add the Xing4.0 causal LM: the DeepSeek-V3 MLA attention, noaux_tc MoE and sanitize reused by composition inside a width-hc_mult manifold hyper-connection residual stream, ported from mlx-vlm's xing4_0 module. - New src/models/xing4_0.rs with the Xing-specific connection (f32 RMS norm, activation-dtype mix, no pre eps, clipped exp Sinkhorn with row-then-column rounds, comb @ x expand, mean head), config validation, native batched decode and last-row logits. - DeepSeekV3Attention gains an opt-in RoPE frequency table so Xing applies its YaRN block; every other family keeps the plain-frequency path. - QuantizedMultiLinear and the DeepSeek-V3 routed-expert SwitchGLU solve each affine plane's width from its shapes when a per-path override differs from the declared width (the OptiQ 4-bit export stores the MLA projections and some expert planes at 8 bits); uniform checkpoints keep the declared width. - The Xing4_0Tokenizer class defaults add_bos_token to true, as its constructor does. - Wired into detection, the config-backed loader, LoadedModel, the registry, the MLA latent-pair family list and docs/supported-models.md; scripts/xing4_0_oracle_trace.py scores the logit trace against mlx-vlm with three negative arms.
Xing4.0 resolves its RoPE through RopeScalingKind::resolve, which consumes an installed --rope-freq-base override and counts it as applied. When the scheme resolves to no table (--rope-scaling none, or a YaRN block that degrades to default), the DeepSeek-V3 attention kept rotating at the config's rope_theta, so the server accepted the override while the rotation ignored it, the silent-override failure rope_overrides exists to prevent. The table-less layers now take rope_theta through rope_overrides::resolve_base, as the other rope_utils families do. With no override installed the base is unchanged, so the released YaRN checkpoints and every other DeepSeek-V3 family are unaffected. Also add Xing4.0 to the Used by notes of rope_utils, rope_overrides::resolve_base, strip_language_model_wrapper and mla_latent_decode_rows, which it now reaches. The override is a process-wide OnceLock, so it is not exercised by a unit test; models::xing4_0 and models::deepseek_v3 tests, clippy, fmt and the used-by check pass. Refs #2356
The per-plane width solve added for the OptiQ Xing4.0 export lets a plane's shapes pick its bit width. Shapes that solve to 1 bit passed the load checks and reached MLX's gather_qmm, which has no 1-bit kernel and aborts the process at the first routed forward pass. The shared SwitchLinear loader already refuses this layout (issue #1370); SwitchGLU now refuses it too, naming the plane. A new test drives a hostile down_proj plane at a 1-bit and a non-integer width and asserts both are load errors. models::xing4_0 and models::deepseek_v3 unit tests, clippy and fmt pass. Refs #2356
The xing4_0 family had a docs/supported-models.md entry but no CHANGELOG.md line, which the other recent model additions carry under Unreleased. The entry names the two checkpoints, the hyper-connection residual stream over the reused DeepSeek-V3 decoder, the mlx-vlm parity numbers, and the out-of-scope items. Validation: cargo fmt --check, clippy on lib and tests, the repo CI check scripts, and the models::xing4_0, models::deepseek_v3, tokenizer::tests, coverage_tests and models::detection selectors all pass. Refs #2356
Add the bilingual technical report for PR #3276 covering the hyper-connection port, the opt-in YaRN table, the per-plane width solving, the tokenizer BOS default and the trace results.
inureyes
force-pushed
the
feature/2356-xing4-0-support
branch
from
November 22, 2026 22:19
b2d0a27 to
897c772
Compare
inureyes
marked this pull request as ready for review
November 22, 2026 22:24
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
Main gained `xing4_0` (#3276) in `MLA_LATENT_CACHE_FAMILIES` while this branch added `hy_v4`. Both edits set the pinned length to 17, so the textual merge kept 17 for a list of 18 and `only_the_fallback_less_families_are_latent_families` failed. Found by rerunning `-p mlxcel-core --lib mla::` after bringing the branch up to date with main. Refs #2354
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
The branch was rebuilt on current main (f315dc2) to clear the CHANGELOG.md and docs/supported-models.md conflicts with #3270, #3275 and #3276. This merge records the previously pushed commit 2642118 as a parent so the update is a fast-forward of the remote branch; the tree is the rebuilt branch's, which already carries every change of that commit. Refs #2354
inureyes
added a commit
that referenced
this pull request
Nov 22, 2026
The Kolibri-1 (#3275), Limite (#3249) and Xing4.0 (#3276) oracle trace scripts carry a shebang but landed with mode 100644. The executable-mode check in the Python tooling tests fails on main, and every open PR inherits the failure through its merge ref. This sets the executable bit on the three files. Mode change only, no content changes. Verified locally that no other tracked `scripts/*.py` with a shebang is left at 100644.
This was referenced Nov 23, 2026
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
Adds Xing4.0 (
xing4_0,Xing4_0ForCausalLM), a 29B-total / 4B-active MoE on the DeepSeek-V3 lineage whose residual stream is a width-hc_multmanifold hyper connection. The port follows mlx-vlm'smlx_vlm/models/xing4_0and reuses the DeepSeek-V3 MLA attention,noaux_tcMoE and weight sanitize by composition.Closes #2356
What changed
src/models/xing4_0.rs(new): config with validation (hc_mult, Sinkhorn iterations,hc_eps, clamp range,hc * hiddenoverflow), the Xing hyper connection (f32 RMS norm over the flattened state, activation-dtype mix,sigmoidpre without eps,2 * sigmoidpost, clippedexp(x - rowmax)Sinkhorn with row-then-column rounds, collapse,post * out + comb @ xexpand, mean head), decoder layer and model with native batched decode and last-row logits. Wrong-shapedhc_fn/hc_base/hc_scaleare refused at load; thelanguage_model.wrapper is stripped and the MTP trailer dropped by the reused DeepSeek-V3 sanitize.src/models/deepseek_v3.rs:DeepSeekV3Attentiongains an opt-in RoPE frequency table (with_rope_table), applied throughfast_rope_with_freqs. Xing installs its YaRN table; every other family keeps the previous plainfast_ropecall. The routed-expertSwitchGLUnow stores one width per plane.--rope-freq-baseis carried onto the attention when Xing installs no RoPE table (rope_overrides::resolve_base), and a routed-expert plane whose shapes solve to 1 bit or to a non-integer width is a load error instead of agather_qmmabort.src/lib/mlxcel-core/src/layers.rs:QuantizedMultiLinear::from_weightssolves an affine plane's width from its shapes when it differs from the declared width, with a load-time warning, matching whatUnifiedLinearalready does.src/tokenizer/mod.rs:Xing4_0Tokenizerdefaultsadd_bos_tokento true when the config omits it, as the upstream class constructor does.LoadedModel, registry (MoE list, alias), memory estimate, tensor-parallel family name, batched-decode coverage list, MLA latent-pair cache families (fp16 only),docs/supported-models.md,CHANGELOG.md.TECHNICAL_REPORTS/3276-xing4-0-support-20261123.{en,ko}.md.scripts/xing4_0_oracle_trace.py(new): mlx-vlm reference trace with three negative arms (--comb-transpose,--v4-sinkhorn,--no-yarn).Validation
Teacher-forced logit trace over
docs/architecture.md, plan64 40 8 1536, BOS-anchored, scored withscripts/compare_logit_traces.py --decided 2:comb.Texpand64 20 8 512).mlxcel generategreedy: 8-bit coherent at about 19 tok/s (29.2 GB resident), OptiQ 4-bit coherent at about 22 tok/s (19.2 GB); both answer17 * 23with 391.mlxcel-serveron the 8-bit checkpoint: non-streaming and streaming chat completions return coherent text (The capital of France is Paris.).models::xing4_0(16),models::deepseek_v3,models::deepseek_v32,models::glm4_moe_lite,models::longcat,coverage_tests, registry, detection, tokenizer, mlxcel-coremla::,one_bit,layers::. The GLM4 MoE Lite and LongCat latent-path counter tests fail only when run in parallel with each other (shared global MLA stats counters) and pass with--test-threads=1.Findings outside this PR
DeepSeekV3Attentionignored YaRN for every family before this change: it always appliedfast_ropeatrope_theta. Only Xing opts into the frequency table here, so real DeepSeek-V3 and Kimi K2 checkpoints with a YaRN block still run plain RoPE. Worth a follow-up with its own long-context trace.UnifiedLinearpath already does.Out of scope
MTP drafting, a fused Sinkhorn kernel, tensor-parallel sharding of the hyper connection, and a quantized latent cache for this family.