Loading...
Loading...
Compare original and translation side by side
1. Compute local output: y_local = x @ W_shard.T + bias_shard (if bias per shard)
2. All-gather to concatenate: y = concat([y_0, y_1, ..., y_n], dim=-1)
3. Return complete output of shape (batch, out_features)1. Get input shard: x_shard = x[..., start:end] for this rank
2. Compute partial output: y_partial = x_shard @ W_shard.T
3. All-reduce to sum: y = sum([y_0, y_1, ..., y_n])
4. Add bias (only once, not per-rank): y = y + bias
5. Return complete output of shape (batch, out_features)1. 计算本地输出:y_local = x @ W_shard.T + bias_shard(如果每个分片有偏置)
2. 执行all-gather拼接:y = concat([y_0, y_1, ..., y_n], dim=-1)
3. 返回形状为(batch, out_features)的完整输出1. 获取输入分片:x_shard = x[..., start:end](当前rank对应的分片)
2. 计算部分输出:y_partial = x_shard @ W_shard.T
3. 执行all-reduce求和:y = sum([y_0, y_1, ..., y_n])
4. 添加偏置(仅执行一次,而非每个rank都添加):y = y + bias
5. 返回形状为(batch, out_features)的完整输出