[Transformers] Declare DSV4 IndexCache config fields explicitly - #4997
Open
chenbong wants to merge 1 commit into
Open
[Transformers] Declare DSV4 IndexCache config fields explicitly#4997chenbong wants to merge 1 commit into
chenbong wants to merge 1 commit into
Conversation
`index_topk_pattern` and `indexcache_multi_layer_distill` configure DSV4 IndexCache: an F/S pattern over the ratio=4 CSA layers picks which layers run their own learned Indexer (`F`) and which reuse the nearest preceding producer's top-k (`S`), and the distill flag adds a served-layer distillation target. They already reach the model today, but only through `PretrainedConfig`'s generic `**kwargs` passthrough, which means: * `DeepseekV4Config()` has no such attribute at all, so every consumer must go through `getattr(config, "index_topk_pattern", None)` instead of reading the field; * neither field is documented, so the accepted values (F/S only, must start with `F`, one character per C4 layer) are not discoverable from the config; * nothing pins the defaults, so "IndexCache off" is an absence rather than a declared `None` / `False`. Declare both as real fields with documented defaults. Behaviour is unchanged for configs that set them explicitly. Verified against this change: a bare `DeepseekV4Config()` now exposes `index_topk_pattern=None` and `indexcache_multi_layer_distill=False`; explicit values still arrive unchanged; and both survive a `to_dict()` / `from_dict()` round trip and appear in `to_dict()` output. black, isort, flake8 and copyright_checker pass on the touched file.
Paddle-Bot
suggested changes
Sep 9, 2026
Paddle-Bot
left a comment
Contributor
There was a problem hiding this comment.
Paddle-Bot Review Board (review完成)
| 序号 | 位置 | 优先级 | 规则来源 | 状态 |
|---|---|---|---|---|
| 1 | 构造函数参数顺序 | 仓库规则:基础评审规则 | 🚧 |
Powered by Nyanpasu with gpt-5.6-sol 默认推理级别, please check the suggestions carefully.
| csa_compress_rotary_base=160000.0, | ||
| csa_dense_mode=False, | ||
| # === IndexCache (CSA F/S top-k reuse) === | ||
| index_topk_pattern=None, |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Category
Transformers / Model Config
PR Types
New features
Description
index_topk_patternandindexcache_multi_layer_distillconfigure DSV4IndexCache. The F/S pattern spans the ratio=4 CSA layers, one character per C4
layer:
Fruns that layer's own learned Indexer,Sreuses the nearestpreceding
Flayer's top-k. The distill flag additionally builds aserved-layer distillation target against the producer's top-k probabilities.
Both already reach the model today, but only via
PretrainedConfig's generic**kwargspassthrough. That has three costs:DeepseekV4Config()carries no such attribute, so every consumer has to usegetattr(config, "index_topk_pattern", None)rather than reading a field.F/S, must startwith
F, length equal to the C4 layer count) are not discoverable from theconfig class.
a declared
None/False.This PR declares both as real fields with documented defaults, next to the
existing CSA group.
Compatibility
No behaviour change. Configs that set either field explicitly resolve to exactly
the same values as before; the only difference is that a config which omits them
now reports the documented defaults instead of raising
AttributeErroronattribute access.
Validation
DeepseekV4Config()exposesindex_topk_pattern=Noneandindexcache_multi_layer_distill=False, and both appear in__dict__.index_topk_pattern="FSSF",indexcache_multi_layer_distill=True) arrive unchanged.to_dict()/from_dict()round trip and are present into_dict()output.black,isort,flake8andcopyright_checkerpass on the touched file.