Add APEX-MoE ridge transfer priors for Qwen3.6-35B-A3B, Qwen3.8-Flash-Next-FP8, DeepSeek-V4.1-Flash
Browse files- README.md +60 -0
- deepseek-v4.1-flash/gain.npy +3 -0
- deepseek-v4.1-flash/meta.json +39 -0
- deepseek-v4.1-flash/prior.npy +3 -0
- deepseek-v4.1-flash/transfer.npz +3 -0
- qwen3.6-35b-a3b/gain.npy +3 -0
- qwen3.6-35b-a3b/meta.json +46 -0
- qwen3.6-35b-a3b/prior.npy +3 -0
- qwen3.6-35b-a3b/transfer.npz +3 -0
- qwen3.8-flash-next-fp8/gain.npy +3 -0
- qwen3.8-flash-next-fp8/meta.json +45 -0
- qwen3.8-flash-next-fp8/prior.npy +3 -0
- qwen3.8-flash-next-fp8/transfer.npz +3 -0
README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
tags:
|
| 3 |
+
- mixture-of-experts
|
| 4 |
+
- expert-pruning
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# APEX-MoE calibration priors
|
| 8 |
+
|
| 9 |
+
Calibration files for APEX-MoE, prompt-based expert pruning for mixture-of-experts language models:
|
| 10 |
+
at the end of prefill, each request keeps a fixed share of the routed experts in every MoE layer,
|
| 11 |
+
and decode routes among those only. These files hold the per-expert statistics the selection score
|
| 12 |
+
needs, fitted once per model on a calibration set.
|
| 13 |
+
|
| 14 |
+
| folder | model | MoE layers x experts |
|
| 15 |
+
|---|---|---|
|
| 16 |
+
| `qwen3.6-35b-a3b` | [Qwen/Qwen3.6-35B-A3B](https://huggingface.co/Qwen/Qwen3.6-35B-A3B) | 40 x 256 |
|
| 17 |
+
| `qwen3.8-flash-next-fp8` | [Qwen/Qwen3.8-Flash-Next-FP8](https://huggingface.co/Qwen/Qwen3.8-Flash-Next-FP8) | 48 x 512 |
|
| 18 |
+
| `deepseek-v4.1-flash` | [deepseek-ai/DeepSeek-V4.1-Flash](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash) | 40 x 384 |
|
| 19 |
+
|
| 20 |
+
Each folder holds, for MoE layer `l` and routed expert `e`:
|
| 21 |
+
|
| 22 |
+
- `gain.npy` `[L, E]`: the expert's gain, its router-weighted mean output norm on the calibration
|
| 23 |
+
set, `sum g * ||f(x)|| / sum g`;
|
| 24 |
+
- `prior.npy` `[L, E]`: the expert's share of the summed REAP saliency `g * ||f(x)||` on the
|
| 25 |
+
calibration set (a static prior);
|
| 26 |
+
- `transfer.npz`: the transfer prior, a per-layer ridge regression of a request's decode profile
|
| 27 |
+
on its prompt's routing: `matrix` `[L, E, E]`, `offset` `[L, E]`, `lam` (ridge strength), `power`
|
| 28 |
+
(2: fitted on the square root of the decode share);
|
| 29 |
+
- `meta.json`: model revision, calibration runs, fit settings.
|
| 30 |
+
|
| 31 |
+
## Selection score
|
| 32 |
+
|
| 33 |
+
Per request and layer, with `m` the prompt's summed router weight per expert, `c` its route count
|
| 34 |
+
per expert, `n` its token count and `share(v) = v / sum(v)`:
|
| 35 |
+
|
| 36 |
+
```
|
| 37 |
+
prior = share(max(0, share(c) @ matrix[l] + offset[l]) ** power)
|
| 38 |
+
score = n * share(gain[l] ** 2 * m) + 256 * prior
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
The `round(keep * E)` highest-scoring experts are kept (ties: lowest expert id); decode masks the
|
| 42 |
+
other router logits before the top-k. Settings used with these files: gain power 2, prior strength
|
| 43 |
+
256, keep 25% and 50%.
|
| 44 |
+
|
| 45 |
+
## Calibration
|
| 46 |
+
|
| 47 |
+
1024 prompts (`calmix1024`, seed 0): 256 each from Open-Platypus, OpenThoughts-114k,
|
| 48 |
+
evol-codealpaca-v1 and FineWeb-Edu passages, decontaminated against the evaluated benchmarks. Each
|
| 49 |
+
model answered every prompt itself with thinking on; a teacher-forced replay of prompt and answer
|
| 50 |
+
recorded the routed experts' router weights and output norms. The Qwen3.6 files were fitted on the
|
| 51 |
+
BF16 checkpoint.
|
| 52 |
+
|
| 53 |
+
## Use
|
| 54 |
+
|
| 55 |
+
With [apex-engine](https://github.com/IST-DASLab/apex-engine) (FreeToken with APEX):
|
| 56 |
+
|
| 57 |
+
```bash
|
| 58 |
+
ft serve --model Qwen/Qwen3.6-35B-A3B --moe-strategy offload \
|
| 59 |
+
--apex-dir <this repo>/qwen3.6-35b-a3b --apex-keep 0.25
|
| 60 |
+
```
|
deepseek-v4.1-flash/gain.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:abbaec975f5d562160e1f039a418256182620a7c96241bd05e18854f793d333c
|
| 3 |
+
size 123008
|
deepseek-v4.1-flash/meta.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "deepseek-ai/DeepSeek-V4.1-Flash",
|
| 3 |
+
"model_revision": "5254448103b6254fc646dacbca1cbbf20e9216c1",
|
| 4 |
+
"prior_run_id": "prior-reapsum-ridge1-sqrt-4238cddecce7-20261017T222441Z",
|
| 5 |
+
"created": "2026-10-17T22:28:05+00:00",
|
| 6 |
+
"num_moe_layers": 40,
|
| 7 |
+
"num_experts": 384,
|
| 8 |
+
"fit": {
|
| 9 |
+
"score": "reap_sum",
|
| 10 |
+
"ridge_lambda": 1.0,
|
| 11 |
+
"ridge_target": "sqrt",
|
| 12 |
+
"transfer_power": 2.0
|
| 13 |
+
},
|
| 14 |
+
"calibration": {
|
| 15 |
+
"set": "calmix1024, seed 0",
|
| 16 |
+
"source_runs": [
|
| 17 |
+
"deepseek-v4.1-flash-calmix1024-h0-weights-norms-2e350144f1d4-20261017T200939Z",
|
| 18 |
+
"deepseek-v4.1-flash-calmix1024-h1-weights-norms-08ac594dbfaf-20261017T205057Z"
|
| 19 |
+
],
|
| 20 |
+
"dataset_digest": "f7902fc77890bc7987ec4e0e1557ebe35b13bba1a916af9fe5d572611fcc70cd",
|
| 21 |
+
"calibration_requests": 1024
|
| 22 |
+
},
|
| 23 |
+
"used_with": {
|
| 24 |
+
"score": "reap_gain",
|
| 25 |
+
"kappa": 256,
|
| 26 |
+
"gain_power": 2.0,
|
| 27 |
+
"transfer": true,
|
| 28 |
+
"keep": [
|
| 29 |
+
0.25,
|
| 30 |
+
0.5
|
| 31 |
+
]
|
| 32 |
+
},
|
| 33 |
+
"code": {
|
| 34 |
+
"apex-moe": "0.0.1",
|
| 35 |
+
"vllm": "0.30.0",
|
| 36 |
+
"torch": "2.13.0",
|
| 37 |
+
"git_commit": "9d44b8e6fbf20480c134c42bf889dc3cfda436de"
|
| 38 |
+
}
|
| 39 |
+
}
|
deepseek-v4.1-flash/prior.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5fe9c57085732af5441421c5ddab6772212d43f97ea6197aa488f140ecbab417
|
| 3 |
+
size 123008
|
deepseek-v4.1-flash/transfer.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f485517e2154c9241ebd8aeb8d4bca85a1e16f030af2036530a67abab864537b
|
| 3 |
+
size 47309806
|
qwen3.6-35b-a3b/gain.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0c5ceb11d99a1b2d4364eade0f3c5c9c432d7b2fb34d5857d19eee0ddcf00a5
|
| 3 |
+
size 82048
|
qwen3.6-35b-a3b/meta.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "Qwen/Qwen3.6-35B-A3B",
|
| 3 |
+
"model_revision": "995ad96eacd98c81ed38be0c5b274b04031597b0",
|
| 4 |
+
"prior_run_id": "prior-reapsum-ridge1-sqrt-277e36c6145b-20261017T135828Z",
|
| 5 |
+
"created": "2026-10-17T14:05:31+00:00",
|
| 6 |
+
"num_moe_layers": 40,
|
| 7 |
+
"num_experts": 256,
|
| 8 |
+
"fit": {
|
| 9 |
+
"score": "reap_sum",
|
| 10 |
+
"ridge_lambda": 1.0,
|
| 11 |
+
"ridge_target": "sqrt",
|
| 12 |
+
"transfer_power": 2.0
|
| 13 |
+
},
|
| 14 |
+
"calibration": {
|
| 15 |
+
"set": "calmix1024, seed 0",
|
| 16 |
+
"source_runs": [
|
| 17 |
+
"qwen3.6-35b-a3b-calmix1024-s0-weights-norms-a5bb5210fc0b-20261016T094934Z",
|
| 18 |
+
"qwen3.6-35b-a3b-calmix1024-s1-weights-norms-4fcbec7dd610-20261016T094934Z",
|
| 19 |
+
"qwen3.6-35b-a3b-calmix1024-s2-weights-norms-e803d5f9a8cd-20261016T094934Z",
|
| 20 |
+
"qwen3.6-35b-a3b-calmix1024-s3-weights-norms-3b38a3bbcad3-20261016T094934Z",
|
| 21 |
+
"qwen3.6-35b-a3b-calmix1024-s4-weights-norms-1760d9fe63fa-20261016T094934Z",
|
| 22 |
+
"qwen3.6-35b-a3b-calmix1024-s5-weights-norms-b7515d70f647-20261016T094934Z",
|
| 23 |
+
"qwen3.6-35b-a3b-calmix1024-s6-weights-norms-1af3085a8358-20261016T094934Z",
|
| 24 |
+
"qwen3.6-35b-a3b-calmix1024-s7-weights-norms-448f2d095736-20261016T094934Z"
|
| 25 |
+
],
|
| 26 |
+
"dataset_digest": "84fb3cc28ac4359b04ac177275d5a40e78e10e0ce1d05a623b3792c45dc6d9fa",
|
| 27 |
+
"calibration_requests": 1024
|
| 28 |
+
},
|
| 29 |
+
"used_with": {
|
| 30 |
+
"score": "reap_gain",
|
| 31 |
+
"kappa": 256,
|
| 32 |
+
"gain_power": 2.0,
|
| 33 |
+
"transfer": true,
|
| 34 |
+
"keep": [
|
| 35 |
+
0.25,
|
| 36 |
+
0.5
|
| 37 |
+
]
|
| 38 |
+
},
|
| 39 |
+
"code": {
|
| 40 |
+
"apex-moe": "0.0.1",
|
| 41 |
+
"vllm": "0.30.0",
|
| 42 |
+
"torch": "2.13.0",
|
| 43 |
+
"git_commit": "9d44b8e6fbf20480c134c42bf889dc3cfda436de"
|
| 44 |
+
},
|
| 45 |
+
"remark": "Fitted on the BF16 checkpoint; also used with RedHatAI/Qwen3.6-35B-A3B-NVFP4."
|
| 46 |
+
}
|
qwen3.6-35b-a3b/prior.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46253157e8946705420c4eed8ef179df560e40447fd2a5c62964767f94ccfb97
|
| 3 |
+
size 82048
|
qwen3.6-35b-a3b/transfer.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0161cd96b709f7769773b2c0f0ffdc70ef87e49076f430ecf94985e9832e328b
|
| 3 |
+
size 21054446
|
qwen3.8-flash-next-fp8/gain.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5b2caaa604517d56dbd2cca00ae097062afdca68e6d7e633606211b50adf23c5
|
| 3 |
+
size 196736
|
qwen3.8-flash-next-fp8/meta.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"model": "Qwen/Qwen3.8-Flash-Next-FP8",
|
| 3 |
+
"model_revision": "236dfdf285828023ca3bcd3f37366c58a3469b13",
|
| 4 |
+
"prior_run_id": "prior-reapsum-ridge1-sqrt-5a993b7b40fc-20261017T174201Z",
|
| 5 |
+
"created": "2026-10-17T17:51:23+00:00",
|
| 6 |
+
"num_moe_layers": 48,
|
| 7 |
+
"num_experts": 512,
|
| 8 |
+
"fit": {
|
| 9 |
+
"score": "reap_sum",
|
| 10 |
+
"ridge_lambda": 1.0,
|
| 11 |
+
"ridge_target": "sqrt",
|
| 12 |
+
"transfer_power": 2.0
|
| 13 |
+
},
|
| 14 |
+
"calibration": {
|
| 15 |
+
"set": "calmix1024, seed 0",
|
| 16 |
+
"source_runs": [
|
| 17 |
+
"qwen3.8-flash-next-fp8-calmix1024-s0-weights-norms-9d9af2d5fe11-20261017T165103Z",
|
| 18 |
+
"qwen3.8-flash-next-fp8-calmix1024-s1-weights-norms-9a866ba0c1a1-20261017T165104Z",
|
| 19 |
+
"qwen3.8-flash-next-fp8-calmix1024-s2-weights-norms-df30d646c38d-20261017T165104Z",
|
| 20 |
+
"qwen3.8-flash-next-fp8-calmix1024-s3-weights-norms-319a7c6d9fea-20261017T170734Z",
|
| 21 |
+
"qwen3.8-flash-next-fp8-calmix1024-s4-weights-norms-93b321d06e6a-20261017T170834Z",
|
| 22 |
+
"qwen3.8-flash-next-fp8-calmix1024-s5-weights-norms-0a92d999cf38-20261017T170934Z",
|
| 23 |
+
"qwen3.8-flash-next-fp8-calmix1024-s6-weights-norms-3d91f4734fa2-20261017T172504Z",
|
| 24 |
+
"qwen3.8-flash-next-fp8-calmix1024-s7-weights-norms-bf766fb018a6-20261017T172534Z"
|
| 25 |
+
],
|
| 26 |
+
"dataset_digest": "84fb3cc28ac4359b04ac177275d5a40e78e10e0ce1d05a623b3792c45dc6d9fa",
|
| 27 |
+
"calibration_requests": 1024
|
| 28 |
+
},
|
| 29 |
+
"used_with": {
|
| 30 |
+
"score": "reap_gain",
|
| 31 |
+
"kappa": 256,
|
| 32 |
+
"gain_power": 2.0,
|
| 33 |
+
"transfer": true,
|
| 34 |
+
"keep": [
|
| 35 |
+
0.25,
|
| 36 |
+
0.5
|
| 37 |
+
]
|
| 38 |
+
},
|
| 39 |
+
"code": {
|
| 40 |
+
"apex-moe": "0.0.1",
|
| 41 |
+
"vllm": "0.30.0",
|
| 42 |
+
"torch": "2.13.0",
|
| 43 |
+
"git_commit": "9d44b8e6fbf20480c134c42bf889dc3cfda436de"
|
| 44 |
+
}
|
| 45 |
+
}
|
qwen3.8-flash-next-fp8/prior.npy
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a9153c7b355b733cd2ee9440fac22fa15f9d99a0bd948d0a62fcd37e8aad6ef9
|
| 3 |
+
size 196736
|
qwen3.8-flash-next-fp8/transfer.npz
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:20899f2801a4d84eddbe0768cccaae2267bae6f2cd9b62feac1f56d3db59bb71
|
| 3 |
+
size 100860910
|