Skip to content

Add Shensi and Shensi-VL models - #48404

Open
zongzhilou wants to merge 2 commits into
huggingface:mainfrom
zongzhilou:shensi
Open

Add Shensi and Shensi-VL models#48404
zongzhilou wants to merge 2 commits into
huggingface:mainfrom
zongzhilou:shensi

Conversation

@zongzhilou

@zongzhilou zongzhilou commented Aug 29, 2026

Copy link
Copy Markdown

CPU CI GPU run-slow

What does this PR do?

Adds two new models sharing a "DeepRecur" design: Shensi (text,
ShensiConfig / ShensiForCausalLM, checkpoint louzongzhi/Shensi-Nano) built on
the DeepSeek-V4 backbone, and Shensi-VL (multimodal, ShensiVlConfig /
ShensiVlForConditionalGeneration, checkpoint louzongzhi/Shensi-VL-Nano) pairing
the Shensi language tower with a Kimi K3 vision tower (MoonshotAI/Kimi-K3).

Shensi (text)

Three changes vs. the vanilla V4 stack:

  1. GDAR-XHC — residual streams reworked following xHC
    (arXiv:2607.14530): the residual runs as
    hc_mult=16 parallel streams with per-stream pre/route/post gating, only the
    active streams are updated per step (no Sinkhorn constraint). The Gated Delta
    Attention Residual replaces the remaining mHC machinery: each stream does
    cross-layer attention internally — a delta rule keeps a per-block slot memory
    with decay/erase/write gates, normalized-key retrieval, and softmax routing over
    the slots of previous blocks — instead of stacking an extra attention module on
    top of the hyper-connection.

  2. Block Router & Block UniPool — router sharing across a block of layers
    (arXiv:2603.18297, Path-MoE) combined with a
    block-level unified expert pool (arXiv:2605.06665,
    UniPool): the block's write layer owns the top-k router and the expert pool, the
    read layers of the same block share them — one router and one pool per block
    instead of per layer (parameters tied in the state dict). Shared experts are
    removed following arXiv:2605.11689
    (Slicing and Dicing: shared experts barely move the needle).

  3. Block aux_loss & erc_loss — kept at block level from an information-theoretic
    angle: the standard load-balancing aux_loss minimizes the mutual information
    between inputs and routed experts (not strictly required once the path constraint
    removes the bias, but kept as a regularizer), while erc_loss
    (arXiv:2512.23447) maximizes the mutual
    information between outputs and routed experts. Together they give routing
    stability and expert specialization, stacking on the specialization already
    enforced by the path constraint for deep cooperation.

Shensi-VL (multimodal)

Shensi language tower + Kimi K3 vision tower, interleaved into DeepRecur blocks
that rely on GDAR:

  • cross blocks exchange evidence/guidance between the towers — language queries
    retrieve vision evidence, language guidance is written back to vision;
  • the loop block runs a continuous latent reasoning loop (Coconut-style): the
    language stream is refined with damped write-backs, and the loop stops on a
    data-driven criterion — hidden-stream delta, reasoning-state delta and orbit
    recurrence are combined, no hard iteration cap.

Notes

  • Docs: docs/source/en/model_doc/shensi.md, shensi_vl.md; tests:
    tests/models/shensi, tests/models/shensi_vl.
  • The VL composite owns the tower layers; blocks only reference slices of them, so
    state dicts stay alias-free and save/load round-trips exactly.

Who can review?

@zongzhilou zongzhilou closed this Aug 29, 2026
@zongzhilou zongzhilou reopened this Aug 29, 2026
@zongzhilou zongzhilou closed this Aug 29, 2026
@zongzhilou zongzhilou reopened this Aug 29, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CI recap

Dashboard: View test results in Grafana
Latest run: 33226796429
Result: failure | Grafana metrics are not available yet.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/ — this covers files the PR deletes or renames, not only the ones it edits
  • A new high-severity security issue was detected in the changed Python files (Bandit check)
  • The PR touches a path this repository protects from untrusted PRs, such as the file that decides who reviews it — a maintainer must make that change in a separate PR

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

@github-actions

Copy link
Copy Markdown
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, shensi, shensi_vl

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution 🤗!

CI Security Gate — automatic approval blocked

This PR was not automatically approved for CI because the security gate failed.

Possible reasons:

  • The PR touches 50 or more files — only PRs with fewer than 50 changed files are automatically approved
  • A changed file is outside the allowed directories (src/, tests/, docs/, utils/), has a disallowed extension (only .py, .txt, .md permitted outside tests/ and docs/), or is not .md/.yml inside docs/ — this covers files the PR deletes or renames, not only the ones it edits
  • A new high-severity security issue was detected in the changed Python files (Bandit check)
  • The PR touches a path this repository protects from untrusted PRs, such as the file that decides who reviews it — a maintainer must make that change in a separate PR

See the workflow run for the exact violations.

A maintainer can review and manually approve CI if a finding is a false positive.

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.

1 participant