Engine support for concatenated weights with per-sub-parameter configuration
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 12/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- python
调研方向
This is design work, so start by reading the closed prototype in #366 for the approach, not to reuse it. The payload names ConcatenatedParameterMeta and concatenate_linear_layers, the init_parameter and metas_for_grad hooks, the param-group loop in stage_base.py, and the attention QKV/KV path. Done would require agreement on the design first, so raise the scope questions in the thread before writing code.
由索引模型根据 Issue 内容生成。
描述
Many weights are stored as a single tensor for compute/optimization efficiency but are logically several distinct parameters. Examples:
- fused QKV (and key/value in GQA)
- gated MLP layer-1 (gate + up)
- MoE expert stacks
- SSM
in_proj(z, x, B, C, dt splits)
Today the engine treats each as one opaque parameter. The goal is to make it aware of the internal structure so each logical sub-parameter can be configured independently: lr_scale, initialization, weight decay, PEFT enablement (LoRA on a subset of the split). Bias-split is possible but lower priority.
This is also architecturally adjacent to the converter weight-mapping work — splitting in_proj / QKV is the same concern that shows up in the hybrid-Mamba and Gemma converters.
Prototype approach (#366, closed — preserved here in case the branch is pruned)
The central abstraction is a ConcatenatedParameterMeta (subclass of TensorMeta → ParameterMeta) that holds its constituent sub-parameter metas plus the concat axis (dim_index), built via from_metas(metas, dim_index=0, dim_name=...). It validates that all constituent dims match except on the concat axis, and sets that axis to a ConcatenatedTensorDim. Everything that needs the parts treated independently routes through this one structure:
- Initialization —
init_parametersplits the buffer and delegates to each constituent meta's owninit_parameteron its slice, so each sub-param keeps its own init method. (requires_global_initializationforced on.) - Optimizer — a new
metas_for_gradproperty exposes the constituents to the param-group builder. When sub-params differ inlr_scale/weight_decayit sets a_split_optimizationflag (only valid ondim_index==0, since the optimizer needs contiguous chunks) and the param-group loop instage_base.pywalksmetas_for_grad, grouping each contiguous buffer slice by its own(weight_decay, lr_scale). - PEFT —
concatenate_linear_layers(...)fuses already-builtLinear/{Input,Output}ParallelLinearlayers into one over the concatenated meta, and resolves per-sub-layerapply_peftflags: uniform → single enable/disable; mixed → buildsout_channel_rangesfrom the concat dim'sget_split_ranges(global_=True). PEFT'sapply_linear/lora_linearwere generalized from a single(out_channel_begin, out_channel_end)toout_channel_ranges: tuple[(begin, end), ...], so LoRA can target multiple disjoint output-channel ranges.
ConcatenatedTensorDim gained split_tensor / merge_tensors / get_split_ranges helpers (local or global), and local_to_global/global_to_local were refactored onto them.
Notably, this supersedes two prior hacks: (1) the old lr_scale-as-tuple-of-floats on ParameterMeta (which split a param into equal contiguous chunks for the optimizer) is removed — lr_scale becomes a plain scalar and combine_lr_scales a simple product; (2) the attention layer's old "build a fused key_value linear then bolt PEFT onto the value half via out_channel_begin" path is replaced by building key/value separately and fusing with concatenate_linear_layers(..., default_apply_peft=(False, True)).
The concrete demonstration is attention QKV/KV; Megatron-init compatibility was handled with a small _get_init_method helper that picks the first constituent's init for a concatenated meta.
Open scope from the prototype
Simplify and harden concatenate_linear_layers (PEFT especially — several TODOs flag rough edges, e.g. LoRA on concatenated layers, naming of the original constituent params), extend coverage to the remaining fused linears (gated MLP, MoE, SSM in_proj), and round out tests. Treat the prototype as a reference for the approach, not for reuse — it predates the linear/PEFT layer rework on main and would need a full rebase.
Drafted by Claude Opus 4.8 from the #366 diff.
- 主要语言
- Python
- 星标
- 337
- 派生
- 52
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ServiceNow/Fast-LLM 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 25/100
ServiceNow/Fast-LLM#556 ·
-
难度 4/5 3-5 天 新手友好度 30/100
ServiceNow/Fast-LLM#538 ·
-
难度 5/5 一周以上 新手友好度 15/100
ServiceNow/Fast-LLM#510 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 12/100
ServiceNow/Fast-LLM#507 ·
-
难度 4/5 3-5 天 新手友好度 25/100
ServiceNow/Fast-LLM#500 ·
查看 ServiceNow/Fast-LLM 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 72/100
521xueweihan/HelloGitHub#4150 ·
-
难度 2/5 1-3 小时 新手友好度 74/100
aws-samples/sample-per-model-bedrock#595 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 85/100
维护者通常 1 天内回复
-
bug connectors
难度 1/5 1 小时以内 新手友好度 67/100
pyinfra-dev/pyinfra#2036 ·
维护者通常 9 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复