[Engine] Switching quant tiers starts the learned expert profile over: the save path is per pack tag, while the loader only checks geometry

未关闭
#7,301 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 4 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
cpp, python

调研方向

Start with learned_profile_args() and profile_shape() in the Python serving and config path, then compare their fallback behavior with read_expert_profile() in src/core/expert_cache.cpp. Check how the configured save path and per-replica suffix are formed. Done means a same-geometry profile can be selected when the tagged save file is missing, with a log naming the adopted file; the issue also suggests documenting profile portability.

由索引模型根据 Issue 内容生成。

描述

Problem: On one machine running three quantisation tiers of Qwen3.8-Flash-Next, each tier's learned expert profile is stored under a different pack-tagged filename, so changing tier starts the adaptive tier from the shipped baseline instead of from a profile that a previous tier already trained. The engine loader itself does not require a tier match: it accepts any profile whose header reports the same layer and expert counts.

Environment: engine 0.1.62, Windows 11, RTX 3090 24 GB (sm_86), CUDA 13.0. Model: Qwen3.8-Flash-Next (48 layers x 512 experts). Tiers used on this box: UD-IQ4_XS v3.1 (--native, 4 shards), UD-Q4_K_XL, and Swift-1.5 IQ3_S_G8. Relevant settings: --expert-cache auto --adapt-every 1 --adapt-swaps 160 --adapt-decay 0.97 --kv int8 --kv-resident 20480 --max-context 393216, config keys expert_profile_save and expert_profile_save_every: 5.

Reproduce:

  1. Train a profile on tier A (a few hours of normal use; expert profile saved to ... (periodic) appears in the log, and the start log shows pre-filled 6495 of 6495 slots from the profile).
  2. Point the config at tier B, a different quantisation of the same model, and start serve.
  3. Watch data/ gain a second expert-profile-learned-<new-tag>.bin, and the start log name that new file rather than the trained one.

Expected: a tier change either reuses an existing profile of the same geometry as its starting prior, or says in one line that it is starting fresh.

Actual: a new tagged file is created and the first start begins from the config's --expert-profile (the shipped baseline), because learned_profile_args() substitutes the saved profile only when that exact path already exists and matches:

learned = profile_shape(save if os.path.isabs(save) else os.path.join(here, save))
base = profile_shape(args[i] if os.path.isabs(args[i]) else os.path.join(here, args[i]))
if learned is not None and learned == base:
    args[i] = save

(profile_shape() returns None for a missing file, so on a new tag the substitution never happens.)

Evidence — the four profile files on this box have identical headers, so nothing in the format is tier-specific:

file magic ver layers experts slots ranked
expert-profile.bin (shipped) STRP 1 48 512 24576 24576
...-learned-...-unsloth-iq4xs-v31.bin STRP 1 48 512 24576 24576
...-learned-...-unsloth-q4kxl.bin STRP 1 48 512 24576 24576
...-learned-...-iq3s-g8.bin (separate install) STRP 1 48 512 24576 24576

read_expert_profile() (src/core/expert_cache.cpp) rejects only on a bad magic, on version != 1, and on nl != n_layers || ne != n_expert ("it is a profile for a different artifact"). It never compares the pack, the quantisation, or a weight hash, and slots is not a constraint either: the file stores all 24,576 (layer, expert) pairs and the engine takes the top N for whatever the current resident budget is.

The tagged absolute path itself is written by the install/Control layer, not by serve; in this checkout the config simply carries
"expert_profile_save": "<data>/expert-profile-learned-021-unsloth-iq4xs-v31.bin", and serve/replicas.py only suffixes it per replica.

Workaround available today: point expert_profile_save at the trained file of another tier with the same geometry. The header check passes and the start log then shows the trained profile being pre-filled (this is the step we have not run end to end yet — see status below).

Two small suggestions:

  1. When no profile exists for the configured save path, look in the same directory for another STRP version 1 profile with the same (layers, experts) and use it as the prior, with one log line naming the adopted file. This is the same check profile_shape() already performs, applied as a fallback.
  2. Document that a learned profile is portable across quantisation tiers of the same geometry, and that the pack tag in the filename is a naming convention rather than a compatibility requirement.

Related: #6200 and #6201 propose a two-timescale STRM sidecar because a saved profile over-specialises on the most recent workload. This report is not that problem and needs no new format: the profile that would have been reused already exists, on disk, for the same geometry. One connection worth a maintainer's answer: #6200 attributes the over-specialisation partly to the default adaptive decay of 0.7 per adaptation. We run --adapt-decay 0.97 (half-life roughly 23 adaptations instead of about 2), and day-to-day hit rates on this box stay at 91-96% across mixed work. We have not run the 0.7 arm, so this is a hypothesis, not a result — if 0.97 already removes most of the drift #6200 describes, the sidecar may be solving a smaller problem than it looks.

Reproduction status: unconfirmed static analysis with direct file and config inspection. The header table, the config keys, the start-log lines and the two code paths above were all read directly on this machine. We have not yet started a second tier from the first tier's profile on this box, so the reuse itself is inferred from read_expert_profile()'s acceptance rule, not observed. Verifying it is one cold start and one log line.

主要语言
C++
星标
11.6k
派生
1k
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Niko1221/Strata 的其他 Issue

查看 Niko1221/Strata 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。