dsh-plugin-c2c: KV-Cache Fusion-Driven Collaboration of Dual Local Models in DSH

Preface

When doing multi-model collaboration in DeepSeek Harness (DSH), a common approach is for one model to write its result as text, which is then read by the next model. This channel is limited by the token-level expressiveness of text: information in the intermediate state that “cannot be written out” never reaches the receiver.

The Cache-to-Cache (C2C) idea projects and fuses the sharer’s KV-cache into the receiver’s cache, letting the receiver start from a more complete working state before generation instead of going through a text handoff first. The community plugin dsh-plugin-c2c (maintainer Alyosha28, category: workflow) wraps the upstream thu-nics/C2C runtime into a set of c2c_* agent tools for DSH sessions to call locally.

What Is This

dsh-plugin-c2c is a DSH plugin, version 0.1.0 (MIT license). It does not reimplement the C2C algorithm; instead it packages the upstream rosetta runtime: it runs one receiver (responsible for answering) and one or more sharers locally at the same time, and before the receiver generates any token, projects the sharer’s KV-cache into the receiver’s cache space and fuses it. No text is transmitted between the two models.

Architecturally, the DSH agent accesses c2c_daemon.py through the c2c_* tools via loopback HTTP, and the daemon then invokes the PyTorch-side receiver, sharer, and C2C projectors. The Node plugin does not import Python or torch; it launches the daemon on demand and forwards requests, so Python environment problems do not drag down DSH startup.

Core Features

The plugin exposes six agent tools:

Tool Purpose
c2c_status Check daemon and loading status
c2c_models List available fuser model pairs
c2c_load Load and build the fused model
c2c_chat Answer under fused conditions
c2c_compare Compare “fused” vs “receiver-only” under the same prompt
c2c_unload Release device VRAM/memory

The upstream ships seven fuser pairs, ranging from 0.6B+0.5B to 8B+7B; the README states the smallest pair can run on a laptop.

Practical uses emphasized in the README include: after fusion, two small models can answer questions that neither can answer well alone; the sharer and projectors run only once during the prompt phase, so decoding cost is comparable to receiver-only; weights, projection, and generation all run locally, the daemon binds only to loopback, and there are no outbound requests except the first-time weight pull from Hugging Face; the daemon lifecycle can outlive the plugin realm, and profile hot reload does not necessarily unload already-loaded pairs; upstream targets Linux+CUDA primarily, and this plugin has been ported and verified on Apple Silicon (MPS).

The paper reports accuracy improvements over single-model and pure text handoff; the plugin README explicitly states that the paper’s accuracy experiments have not been reproduced here. What has been verified is that the pipeline runs end-to-end and the performance numbers documented below (see “Environment and Limitations”).

Installation and Activation

Installation has two steps: first prepare the C2C runtime (clone upstream, create a venv, pin transformers), then register the plugin with the DSH profile. The setup step does not download weights; roughly 3.2 GB of model files are downloaded on the first c2c_load, cached at <root>/models/hf.

  1. Prepare the runtime (modify --root as needed):
python python/dsh_c2c_setup.py --root ~/factor_digging/c2c --verify
  1. Install the plugin (use the profile and repository identifier from the materials):
dsh plugin --profile web add Alyosha28/dsh-plugin-c2c
  1. Restart the DSH session. Profiles using patchReload: startup load the plugin at startup.

No configuration changes are needed by default: repoRoot and pythonPath can be auto-detected. To override, set them in the profile’s cordis.patch.yml, for example:

- id: c2c
  config:
    repoRoot: /path/to/c2c           # default: auto-detect
    pythonPath: /path/to/python      # default: <repoRoot>/.venv/bin/python
    port: 8765                       # loopback daemon port
    idleUnloadSeconds: 900           # 0 disables idle release
    loadTimeoutSeconds: 600

Environment and dependencies (from the README):

  • Node >= 20 (package.json engines).
  • Python 3.10–3.13.
  • macOS (MPS), Linux (CUDA), or CPU; the 8B+7B pair recommends ~32 GB+ of device memory.
  • The setup script pins transformers to 4.52.4 (an upper bound, not a lower bound); higher versions may break the KV-cache fusion path.
  • Requires accelerate (the upstream loader uses device_map=).

The plugin runs with the current dsh process’s permissions; review the GitHub source and the MIT license before installing to confirm it meets your security and compliance requirements.

Typical Usage

In a DSH agent session, operate in the README’s example order:

c2c_load    pair: qwen3_0.6b+qwen2.5_0.5b     # build the fused model
c2c_chat    prompt: "..."                      # answer through the fusion
c2c_compare prompt: "..."                      # fused vs receiver-alone, side by side
c2c_unload                                     # release device memory

c2c_compare runs the same prompt twice: once with the sharer fused, and once with receiver-only, making it easy to observe whether fusion makes a difference.

Without relying on DSH, you can also start the daemon manually and probe it with curl (replace the paths with your repo-root):

python python/c2c_daemon.py --repo-root /path/to/c2c --port 8765
curl -s localhost:8765/models
curl -s -X POST localhost:8765/generate \
     -H 'content-type: application/json' \
     -d '{"prompt":"Say hello.","mode":"c2c","max_new_tokens":48}'

Applicable Scenarios and Notes

Who it’s for: Developers already using DSH who want to run dual-small-model KV-fusion experiments locally or compare “text handoff vs cache fusion”; scenarios requiring Apple Silicon or a purely local setup with no outbound inference API.

Notes:

  • Do not enable sampled decoding on MPS; the README notes that torch.multinomial may return zero-probability indices on MPS, while the default greedy decoding is unaffected.
  • Cold loading takes several seconds; the underlying model is not suitable for concurrent generation, so the daemon serializes requests with a lock.
  • @deepseek-ai/* are peerDependencies, resolved at runtime from $DSH_HOME/profiles/node_modules; if you use dsh plugin add <path> for symlink-based development, run pnpm install inside the checkout to align peer dependencies.

Reference data recorded by the README on an arm64 Mac (48 GB unified memory, the smallest Qwen3-0.6B + Qwen2.5-0.5B-Instruct pair): loading ~6.9–7.7 s; receiver-only decoding ~39 tok/s, fused ~64 tok/s; weights ~3.2 GB. Different hardware and pairs will yield different numbers.

Summary

dsh-plugin-c2c turns the C2C paper’s ideas into a locally callable DSH workflow: six c2c_* tools, an independent Python daemon, configurable idle unloading, and a loopback service. If you care about “whether models can pass internal states without going through text,” you can start from setup and the minimal model pair to try c2c_compare.

The community plugin catalog is an independent site with no official affiliation with DeepSeek / High-Flyer; the DSH ecosystem follows the principle that “everything is a plugin,” and adopting any of them requires your own evaluation of the environment and licenses.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye