Converter: per-tensor-type mixed precision (int8 for shared/o_proj/kv_b_proj, int4 rest)#243
Converter: per-tensor-type mixed precision (int8 for shared/o_proj/kv_b_proj, int4 rest)#243woolcoxm wants to merge 1 commit into
Conversation
Split the resident weight classification into 5 sub-types so each can get different precision: sh = shared expert (highest sensitivity, fires every token) o = o_proj (reconstructs output, biggest attn tensor) kvb = kv_b_proj (reconstructs KV cache on every decode) attn = q_a/q_b/kv_a (other attention projections) dmlp = dense MLP (first 3 layers) New args: --shared-bits, --o-bits, --kvb-bits, --attn-bits, --dmlp-bits Each defaults to ebits (backward compat). When set, the converter applies that precision to just that tensor type. Research-backed plan: put the 3 compounding tensors (shared expert, o_proj, kv_b_proj) at int8 and everything else at grouped int4. Extra RAM cost: only +5.3 GB (those tensors are small vs the 372 GB expert pool on disk).
cde0544 to
1f57feb
Compare
|
Closing β this is already on The whole thing ( I checked rather than assumed: I trial-merged this PR onto current For what it's worth, I reviewed it as if it were new before I found that out, and it's good work: single caller for The reason this PR is a ghost is the same thing you were laughing about on #298: that mega-commit bundled grouped quantization + mixed precision + expert budget + the download tool together, so its pieces landed without their own PRs closing. Three of your issues (#237, #238, #239) were in the same boat β all delivered, all still open. Closing those too. The one that bundle also carried was |
|
ok will keep that in mind, was it one of my experimentation branches by chance?? i work on them for hours at a time and when i find things that work i submit them, they usually contains changes that i didnt mean to submit. usually i will create a new branch for the experiments, but if its the one im thinking it was, that one had a ton of experimentation done on it and i tried to submit one change at a time but couldnt figure out how to do it properly. it had 2-3 hours worth of work im sure, sorry about that :D |
Summary
Splits the converter's resident weight classification into 5 sub-types, each independently controllable to a different bit width. The recommended plan puts the 3 most error-sensitive tensors (shared expert, o_proj, kv_b_proj) at int8 and everything else at grouped int4 β for only +5.3 GB RAM.
Closes #237.
Problem
Not all tensors suffer equally from int4 quantization. Three categories of weights compound their error on every token:
The other ~95% of weight mass (routed experts, dense MLP, other attn projections) is either routed (error isolated to one expert) or lower-sensitivity.
Changes
c/tools/convert_fp8_to_int4.py(+52 lines, -8 lines):The
classify()function is split from 3 types (resident/expert/io) into 5 sub-types:shokvbattndmlpNew CLI args:
Recommended usage
Cost
Backward compatibility
--*-bitsflags, behavior is identical to the previous converter--group-size 128(orthogonal: grouped scales reduce error, mixed precision protects sensitive tensors)Stacked on
This PR includes the grouped-quant base (#242) because
quant_int4_groupedis used by the mixed-precision path when--group-size > 0andbits <= 4.Test plan