Expand description
GLM-5.3 KDA tensor-parallel shard plan — head-parallel, one all-reduce.
Scoped to LibertAIDAI/GLM-5.3-Flash-NVFP4@9e0d74e3. Shapes below are measured
from the checkpoint’s safetensors headers, not inferred.
§Why a pure plan
The GPU copy is three lines of crate::tp_shard reuse. The part that is easy
to get silently wrong is which rows belong to this rank — and a wrong head
range produces a running model with quietly mixed-up heads, not a crash. So the
row arithmetic lives here as pure data that can be proven without a GPU, exactly
like the EP residency proof.
§The pattern this follows
Qwen3.5 GDN HeadParallel (weight_loader/qwen35/load_layers/linear_attn_arms.rs,
helpers in tp_shard/gdn.rs): each rank owns a contiguous head range, out_proj
is row-parallel, and one all-reduce follows it. KDA differs from GDN in two
ways that matter here:
- KDA’s
q/k/v_projandq/k/v_conv1dare separate tensors on disk — GDN fuses them intoin_proj_qkv/conv1d. So KDA needs no segmented slice: each tensor is sliced independently and the 3-segment trap (crate::tp_shard::gdn::segment_copy_plan) simply does not arise. - KDA has no
Ztensor. The output gate is low-rankg_a/g_b.
§🪤 Traps this module encodes
a_logis per-HEAD[64];dt_biasis per-CHANNEL[8192]. The KDA module doc already calls this “the highest-risk line”. Under TP they shard at different granularity — heads vs heads×head_dim. Slicingdt_biasby head count silently keeps 1/128th of the right data.o_normis[head_dim], NOT[heads*head_dim]— it is per-channel-within- a-head and therefore replicated, never sharded. It is 256 B; a “shard everything that looks per-head” rule corrupts it.f_a/g_aare down-projections[rank, hidden]— replicated. Only the_bup-projections carry head structure. Sharding an_asplits the low-rank bottleneck and every head reads a truncated gate.o_projis row-parallel:[hidden, heads*head_dim]sliced on its INPUT dim. Each rank produces a partial[hidden]that is only correct after the all-reduce. Column-slicing it instead yields a plausible, wrong output.
Structs§
- KdaTensor
Plan - One tensor’s placement.
row_elemsis the width of a row in elements; forKdaShard::ChannelColsthe roles invert androw_elemsis the sharded axis. - KdaTp
Plan - The complete per-rank shard plan for one KDA block.
Enums§
- KdaShard
- How one KDA tensor maps onto TP ranks.