sanmonga22 commited on
Commit
b94a271
Β·
verified Β·
1 Parent(s): 8d12640

Sanitize public model card metadata

Browse files
Files changed (1) hide show
  1. README.md +12 -90
README.md CHANGED
@@ -1,96 +1,18 @@
1
  ---
2
- license: mit
3
- tags: [qhexrt, moe, llm, hexagon, npu, qnn, snapdragon]
4
- base_model: microsoft/Phi-tiny-MoE-instruct
5
- pipeline_tag: text-generation
 
 
 
 
6
  ---
7
 
8
- # Phi-tiny-MoE β€” Hexagon v79 + v81 NPU bundle (QHexRT)
9
 
10
- **microsoft/Phi-tiny-MoE-instruct** (PhiMoEForCausalLM, 3.8 B total / **1.1 B active**, 16 experts top-2)
11
- compiled to run on the **Qualcomm Hexagon v79 NPU** (Snapdragon 8 Elite / SM8750, e.g. Galaxy S25) through
12
- [**QHexRT**](https://github.com/) β€” a thin C++ QNN runtime. **First MoE in the QHexRT family.**
13
 
14
- > A native, manifest-driven QHexRT bundle: **text in β†’ text out** via the standard `qhx_generate` tool,
15
- > exactly like the other models. Every number below is a **real on-device measurement** on a Samsung S25.
16
 
17
- ## How it runs
18
- A `phimoe_generate` host-op drives an **AR=1 KV-cache decode**: per layer a **GQA-native** attention+router NPU
19
- graph (K/V kept at 4 heads β€” no `repeat_interleave`/VTCM spill) β†’ host `sparsemixer` top-2 β†’ ONE **fused
20
- 2-expert FFN graph** (`ffn2`: both selected experts dequantized from host-RAM int8 **in parallel** + `m1,m2` β†’
21
- `m1Β·SwiGLU_a + m2Β·SwiGLU_b` in a single execute). It reads only the **2 active experts** per token. Quant:
22
- **int8 experts + fp16 attention / router / lm-head** (int16 activations break attention; W4 too coarse). Fits the
23
- device in **4 QNN contexts** (the HTP caps concurrent contexts β‰ˆ 8). The Phi-3 tokenizer + chat template
24
- (`<|user|> … <|end|><|assistant|>`) are applied on-device, so you pass plain **text**. **MAXCTX = 2048**
25
- (16 Q-heads β†’ wide attention HTP-correct past the v79 512 wall β€” verified 12/12 vs fp32 on a 529-token
26
- needle-recall prompt).
27
-
28
- | Metric | Value |
29
- |---|---|
30
- | **Decode** | **~5–7 tok/s** (top-2; best ~7 cold, thermal-dependent) |
31
- | **Prefill / TTFT** | **~2.8 s for a 529-token prompt** (batched MoE prefill); short prompts (<24 tok) β‰ˆ1.5 s |
32
- | **Accuracy** | **100 % greedy parity** vs the fp32 reference β€” 5 prompts **+ a 529-token long-context test** |
33
- | **Context** | **2048** tokens |
34
- | **Peak RSS** | ~6 GB |
35
-
36
- > **GQA-native attention + a fused FFN** lifted decode ~2.5–3.3Γ— over the first 2048 build (2.1 tok/s). A
37
- > **batched MoE prefill** (`pf_lo`/`pf_hi` + `ffn_pf`: one forward/layer over the whole prompt + an expert-grouped
38
- > FFN, seeding the decode KV cache) then cut the 529-token first-token latency from **~95 s β†’ ~2.8 s (~34Γ—)**.
39
- > Short prompts skip it; prompts > 576 fall back to decode-over-prompt.
40
-
41
- ## Contents (`v79/`)
42
- | file | what | size |
43
- |---|---|---|
44
- | `phimoe.json` | the QHexRT manifest (`phimoe_generate` host-op) | small |
45
- | `a_lo.bin` / `a_hi.bin` | GQA-native attn+router graphs, layers 0–15 / 16–31 (KV cache, MAXCTX 2048) | 650 MB each |
46
- | `ffn2.bin` | fused 2-expert FFN graph (both top-2 experts + m1,m2 β†’ 1 execute) | 108 KB |
47
- | `pf_lo.bin` / `pf_hi.bin` | batched-prefill attn+router graphs, layers 0–15 / 16–31 (causal, PN=576) | 659 MB each |
48
- | `ffn_pf.bin` | batched single-expert FFN for prefill (run once per used expert/layer) | 86 KB |
49
- | `lmhead_ar1.bin` | final LayerNorm + lm-head β†’ logits | 251 MB |
50
- | `experts_i8.bin` | all 512 experts (32Γ—16), per-output-channel int8 | 2.69 GB |
51
- | `experts_scale.f32` | int8 dequant scales | 9.8 MB |
52
- | `embed_f16.bin` | token embedding table (host lookup), fp16 | 251 MB |
53
- | `tokenizer.json`, `tokenizer_config.json`, `special_tokens_map.json` | Phi-3 tokenizer | small |
54
-
55
- ## Run
56
- ```bash
57
- # 1) download
58
- hf download runanywhere/phi_tiny_moe_HNPU --local-dir phi_tiny_moe_HNPU
59
- # 2) build qhx_generate from QHexRT for aarch64-android, push it + the QNN runtime libs
60
- # (libQnnHtp.so, libQnnSystem.so, the v79 HTP skel) to /data/local/tmp/phimoe
61
- # 3) push this bundle
62
- adb push phi_tiny_moe_HNPU/v79 /data/local/tmp/phimoe # (PowerShell on Windows β€” native paths)
63
- # 4) run β€” plain text in, text out
64
- adb shell "cd /data/local/tmp/phimoe && export ADSP_LIBRARY_PATH='/data/local/tmp/phimoe;/vendor/dsp/cdsp'; \
65
- LD_LIBRARY_PATH=. ./qhx_generate phimoe.json libQnnHtp.so libQnnSystem.so . 24 'What is the capital of France?'"
66
- # -> "The capital of France is Paris. It is not only the largest city in France ..."
67
- ```
68
- (The manifest also accepts a raw comma-separated token-id list in place of the text prompt, for exact-id repro.)
69
-
70
- ## Caveats
71
- - **v79 only** (SM8750). Another arch = re-export (the build plane / `npu-forge`).
72
- - **MAXCTX 2048** (prompt + generation ≀ 2048). The decode-over-prompt prefill is ~0.46 s/prompt-token, so very
73
- long prompts take minutes to the first token; decode is ~2.1 tok/s regardless of length. A faster small-window
74
- variant (e.g. 512 + sliding KV ring) is a re-export (`MAXCTX=512 build_alo_ahi_2048_v2.sh`).
75
- - Greedy/argmax decode (temperature 0). Weight-only int8 occasionally flips a thin-margin token; output stays
76
- coherent (the prior-port finding β€” int8 is the accuracy/memory sweet spot, W4 too coarse).
77
-
78
- Built with the `npu-forge` toolkit (weights β†’ oracle-gated NPU graphs). Base model + tokenizer Β© Microsoft (MIT).
79
-
80
- ## v81 (SM8850 / soc_model 87) β€” DECODE-ONLY
81
-
82
- Device-validated on SM8850: *"What is the capital of France?"* -> **"The capital of France is Paris. It is not
83
- only the country's largest city but also a global center for art"** β€” coherent, greedy first token 450 (= the
84
- PyTorch gold), **~5.7 tok/s** decode (matches v79), TTFT 1.7 s for a 10-token prompt (decode-over-prompt).
85
-
86
- **Why decode-only:** the full 7-context bundle (64 graphs incl. batched prefill) **crashes the v81 cDSP** β€” the
87
- unsigned protection-domain heap is exhausted during `Graph::setup_vtcm` in `libQnnHtpV81Skel.so` (fastrpc
88
- `0x8000040d` AEE_ENOMEMORY -> remoteproc-cdsp fatal, recovery disabled -> full device reboot). NOT host RAM
89
- (12.7 GB free). The `v81/` bundle therefore ships the **4 decode contexts only** (a_lo/a_hi/ffn2/lmhead_ar1);
90
- `phimoe_generate` auto-falls-back to decode-over-prompt (the batched-prefill graphs are optional). Trade-off:
91
- slower TTFT on long prompts; identical decode quality/speed. (v79 keeps the full batched-prefill bundle.)
92
-
93
- ### Files (`v81/`)
94
- `phimoe.json` (decode-only manifest) Β· `a_lo.bin` `a_hi.bin` (decode attn+router a0..a31) Β· `ffn2.bin` (fused
95
- 2-expert FFN) Β· `lmhead_ar1.bin` (final-norm + lm-head, input `h`) Β· `experts_i8.bin` (int8 experts, host) Β·
96
- `experts_scale.f32` Β· `embed_f16.bin` Β· `tokenizer.json` (+ config/special-tokens).
 
1
  ---
2
+ license: "mit"
3
+ tags:
4
+ - "hnpu"
5
+ - "hexagon"
6
+ - "npu"
7
+ - "llm"
8
+ base_model: "microsoft/Phi-tiny-MoE-instruct"
9
+ pipeline_tag: "text-generation"
10
  ---
11
 
12
+ # phi tiny moe HNPU
13
 
14
+ Prebuilt HNPU artifacts for [microsoft/Phi-tiny-MoE-instruct](https://huggingface.co/microsoft/Phi-tiny-MoE-instruct), a public text-generation model.
 
 
15
 
16
+ For model behavior, license, intended use, and limitations, see the [upstream model card](https://huggingface.co/microsoft/Phi-tiny-MoE-instruct).
 
17
 
18
+ Artifacts are architecture-pinned. Available artifact directories: `v79/`, `v81/`.