Skip to content

feat(market): show and fix the default quant - one family only, never the lowest tier - #246

Merged
Atom112 merged 2 commits into
devfrom
dev-fix-market-default-quant
Oct 30, 2026
Merged

Atom112 merged 2 commits into
devfrom
dev-fix-market-default-quant

Conversation

@Atom112

@Atom112 Atom112 commented Oct 30, 2026

Copy link
Copy Markdown
Owner

问题(用户反馈)

「本地模型需要点一下才知道具体量化版本,不点开直接下载,默认下载的是哪个版本?还是所有版本都下了?」

旧行为的事实:

  1. 一次只下一个量化家族(单文件,或该家族的全部分片)——不会把仓库里所有版本都下下来;这点界面上完全看不出来。
  2. 选法 = 「名字命中白名单(q4_k_m / q4_k_s / q5_k_m / iq4_xs / ud-q4_k_xl)且分片完整的家族里按名字取第一个」,一个都没命中时退化为「按名字第一个完整家族」。

顺带查出的真实缺陷

退化路径是错的:只出 Q2_K / Q3_K_M / Q4_0 / Q6_K / Q8_0 的仓库,字母序最靠前的是 Q2_K —— 质量最差的那一档,用户下载完才发现。另外命中多个白名单时,展开列表会同时挂好几个「推荐量化」徽标,和一键下载的实际选择不一致。

改动

① 规则(features/settings/utils/quantPick.ts,新增纯函数 + 10 项单测)

在分片完整的家族中选「最接近 Q4_K_M」的一档:

  • 档位数字距 4 最近(Q4 → Q5/Q3 → Q6/Q2 → Q8 …)
  • 同档内变体:K_M > K_XL/XXL > K_L > K_S > K > XS/NL > _0
  • 同距离取更高档(质量优先:Q5_K_M 优于 Q3_K_M)
  • 支持 UD-Q4_K_XL、ggml-model-q4_k_m、Model.Q4_K_M、bf16/fp16/int8 等命名

② 可见性(折叠行直接告诉你会下哪个)

  • 折叠行右侧显示该档名称与体积:Q4_K_M · 5.4 GB(悬停显示将下载的文件名列表)
  • 仓库文件列表在行进入视口时预取(IntersectionObserver,rootMargin 400px,并发 2 + 内存缓存),不展开就能看到,也不会一次打满几十个请求(点击下载本来就要打同样的接口)
  • 下载中/暂停态不显示该 chip(此时进度行已显示文件名)

③ 一致性与可发现性

  • 推荐量化 徽标只标在真正会被下载的那一档(此前可同时出现多个)
  • 展开列表按同一偏好序排序 → 列表第一行就是一键下载会取的那档
  • 行尾补展开箭头(复用已有 chevron-down 图标,展开旋转 180°),点行体即展开量化列表

文档:docs/zh|en/usage/providers-and-models.md 增补「量化版本」条目(双语同步)。

行为变化

同一模型的一键下载结果可能与旧版本不同:旧版在白名单缺失时会落到 Q2_K 这类最低档,现在固定为 Q4 档优先。

验证

  • npm run verify 全绿:i18n 1195 键、docs 37 文件、gates rgba=173/any=77 持平、prettier/eslint/tsc 干净、103 前端测试(+10)、vite build;cargo fmt + clippy -D warnings + 473 Rust 测试通过
  • 行布局量测:用真实编译后的 CSS 在 headless Edge 里渲染同一行结构,量到 chip 与下载按钮同一垂直中心(midY 73 vs 73)、行无横向溢出(scrollWidth − clientWidth = 0)
  • 未做(留给实装确认):真机上的预取请求节奏(每个可见行 2 个列表请求、并发 2)

Fixes 用户反馈(本地模型默认量化版本不透明)

…o the lowest tier

The market row downloads exactly ONE quant family (all its shards, never every
variant), but the collapsed row gave no hint which one, and the fallback rule
was wrong: with no whitelist match it took the alphabetically first complete
family - in a repo shipping Q2_K/Q3_K_M/Q4_0/Q6_K/Q8_0 that is Q2_K, the
worst-quality tier, silently.

Changes:
- features/settings/utils/quantPick.ts (new, pure + unit tested): preference
  order over quant families - nearest level to 4 first, then the in-level
  variant (K_M > K_XL > K_L > K_S > K > K_XS > _0), then the higher level on a
  tie; pickDefaultQuant() only considers complete families (shards present)
- LocalModelMarket: the collapsed row now shows the family the button will
  fetch and its size (e.g. "Q4_K_M . 5.4 GB", tooltip lists the files). The
  repo file list is prefetched when the row enters the viewport
  (IntersectionObserver, 400px margin, concurrency 2) so this needs no click
- the "recommended" badge now marks the family that is actually downloaded
  (before, every whitelist match got a badge, disagreeing with the button),
  the expanded list sorts by the same order, and the row gained an expand
  chevron (reuses the existing chevron-down icon)
- both docs: a "quant variants" bullet in zh/en usage/providers-and-models.md
- CHANGELOG: Unreleased entry

Behaviour change: the default family can differ from older builds - those
could land on Q2_K-class tiers, this always prefers the Q4 sweet spot.

Verification: npm run verify green (i18n 1195 keys, docs 37 files, gates
rgba=173/any=77 held, prettier/eslint/tsc, 103 FE tests (+10), vite build;
cargo fmt + clippy -D warnings + 473 Rust tests). Row layout measured in
headless Edge against the real compiled CSS: chip and download button share a
vertical center, no horizontal overflow.
…ial-redos)

The PR's CodeQL run failed on src/features/settings/utils/quantPick.ts with
"Inefficient regular expression": the continuation class [a-z0-9_] also
accepted the '-' / '_' separators, so the separator and the repetition could
each consume the same character - a name like q0_0_0_0_... has exponentially
many ways to split, and family ids come from a remote repo listing (untrusted).

Excluding '-' and '_' from the continuation class makes the repetition
unambiguous; a 4 kB pathological id now resolves in 0 ms and the documented
naming forms (Q4_K_M, IQ4_XS, UD-Q4_K_XL, ggml-model-q4_k_m, Model.Q4_K_M,
bf16/fp16/int8) still extract correctly (10 unit tests unchanged).

Verification: npm run check:frontend green (gates rgba=173/any=77 held,
prettier/eslint/tsc, 103 FE tests, vite build).
@Atom112
Atom112 merged commit 694973d into dev Oct 30, 2026
8 checks passed
@Atom112
Atom112 deleted the dev-fix-market-default-quant branch October 30, 2026 15:44
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.

2 participants