Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Engine support for concatenated weights with per-sub-parameter configuration

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

还没有人认领这个 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 内容生成。

描述

enhancement

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_parameter splits the buffer and delegates to each constituent meta's own init_parameter on its slice, so each sub-param keeps its own init method. (requires_global_initialization forced on.)
  • Optimizer — a new metas_for_grad property exposes the constituents to the param-group builder. When sub-params differ in lr_scale/weight_decay it sets a _split_optimization flag (only valid on dim_index==0, since the optimizer needs contiguous chunks) and the param-group loop in stage_base.py walks metas_for_grad, grouping each contiguous buffer slice by its own (weight_decay, lr_scale).
  • PEFT — concatenate_linear_layers(...) fuses already-built Linear/{Input,Output}ParallelLinear layers into one over the concatenated meta, and resolves per-sub-layer apply_peft flags: uniform → single enable/disable; mixed → builds out_channel_ranges from the concat dim's get_split_ranges(global_=True). PEFT's apply_linear/lora_linear were generalized from a single (out_channel_begin, out_channel_end) to out_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

环境准备

从这里开始

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

ServiceNow/Fast-LLM 的其他 Issue

查看 ServiceNow/Fast-LLM 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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