Token导航 LogoToken导航TokenDH.com
开发只读github未标认证来源可访问clear审计通过

torch-tensor-parallelism火炬张量并行性

Agent Skill

torch-tensor-parallelism 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

897

周安装

37

GitHub Stars

93

下载量

293
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:torch-tensor-parallelism(火炬张量并行性)
来源仓库:https://github.com/letta-ai/skills
仓库路径:skills/torch-tensor-parallelism
安装命令:
npx skills add https://github.com/letta-ai/skills --skill torch-tensor-parallelism
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/letta-ai/skills --skill torch-tensor-parallelism

简介

torch-tensor-parallelism 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合整理项目协作相关内容。

  • 适用于围绕仓库状态、代码变更或协作事项进行信息归纳的场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 安装前需确认权限范围、维护状态及是否触发联网或文件操作。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Tensor Parallelism Implementation Guide

This skill provides guidance for implementing tensor parallelism patterns in PyTorch, specifically for ColumnParallelLinear and RowParallelLinear layers that distribute computation across multiple devices.

Core Concepts

Tensor Parallelism Overview

Tensor parallelism splits individual layers across multiple devices to parallelize computation within a single forward/backward pass. The two primary patterns are:

  1. ColumnParallelLinear: Shards weights along the output dimension (columns). Each device computes a portion of the output features, then results are concatenated via all-gather.
  2. RowParallelLinear: Shards weights along the input dimension (rows). Each device computes partial outputs using its shard of the input, then results are summed via all-reduce.

Critical Implementation Requirement

When implementing tensor parallelism (especially in simulation or testing contexts), the forward pass must actually perform the collective operations, not just compute local shards:

  • ColumnParallelLinear: Must concatenate outputs from all ranks (all-gather semantics)
  • RowParallelLinear: Must sum outputs from all ranks (all-reduce semantics)

A common mistake is returning only the local shard and expecting an external framework to handle collective operations. Unless explicitly specified otherwise, the implementation should produce the final, complete output.

Implementation Approach

Step 1: Understand the Parallelism Pattern

Before implementing, clearly identify:

  1. Which dimension is being sharded (input features vs output features)
  2. What collective operation combines the results (all-gather vs all-reduce)
  3. Whether the implementation should simulate distributed execution or prepare for actual distributed execution
  4. How bias should be handled in the parallel context

Step 2: Weight Sharding

For weight matrix W of shape (out_features, in_features):

ColumnParallelLinear:

  • Shard W along dim=0 (output features)
  • Each rank gets W_shard of shape (out_features // world_size, in_features)
  • Output shape per rank: (batch, out_features // world_size)

RowParallelLinear:

  • Shard W along dim=1 (input features)
  • Each rank gets W_shard of shape (out_features, in_features // world_size)
  • Input to each rank should be corresponding shard of input
  • Output shape per rank: (batch, out_features) - partial sum

Step 3: Forward Pass Implementation

ColumnParallelLinear Forward:

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)

RowParallelLinear Forward:

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)

Step 4: Bias Handling

ColumnParallelLinear:

  • Bias can be sharded along with output features
  • Each rank adds its bias shard to its output shard
  • After all-gather, the full bias has been applied

RowParallelLinear:

  • Bias must NOT be sharded or added per-rank (would cause N-fold bias)
  • Add bias only once after the all-reduce operation
  • Typically only rank 0 adds bias, OR add bias after the sum

Verification Strategies

Mathematical Verification

When local testing is unavailable, verify implementation correctness through mathematical analysis:

  1. Simple example: Use a 2x4 weight matrix with world_size=2
  2. Trace computation: Manually compute what each rank produces
  3. Verify combination: Confirm all-gather/all-reduce produces correct final output
  4. Compare to baseline: Verify parallel output matches non-parallel computation

Shape Verification Checklist

  • Input shape matches expected (batch, in_features)
  • Weight shard shape matches expected partitioning
  • Local output shape is correct for the parallelism type
  • Final output shape matches (batch, out_features) - NOT the sharded dimension

Test Cases to Consider

  1. world_size=1: Trivial case, should match non-parallel implementation exactly
  2. world_size=2,4,8: Common parallel configurations
  3. Non-divisible dimensions: What happens when out_features % world_size!= 0?
  4. Different batch sizes: Verify batch dimension is handled correctly
  5. With and without bias: Test both configurations

Common Pitfalls

Pitfall 1: Returning Local Shards Only

Symptom: Output tensor size is (out_features / world_size) instead of (out_features)

Cause: Implementation computes local shard but doesn't perform all-gather

Fix: Implement the collective operation to combine results from all ranks

Pitfall 2: Incorrect Bias Handling in RowParallelLinear

Symptom: Output values are N times larger than expected (where N is world_size)

Cause: Each rank adds the full bias, then values are summed

Fix: Add bias only once after all-reduce, not per-rank

Pitfall 3: Misinterpreting "Simulation" Requirements

Symptom: Implementation works for world_size=1 but fails for larger world sizes

Cause: Assuming external framework handles collective operations

Fix: Read requirements carefully - "as if using all_gather" means implement the operation

Pitfall 4: Truncated File Writes

Symptom: Implementation has syntax errors or missing code

Cause: File write operation was truncated

Fix: Always read back the complete file after writing to verify integrity

Pitfall 5: Wrong Dimension for Sharding

Symptom: Shape mismatch errors during matrix multiplication

Cause: Sharding along wrong dimension (rows vs columns confusion)

Fix: ColumnParallel shards output features (dim=0 of weight), RowParallel shards input features (dim=1 of weight)

Pre-Implementation Checklist

Before writing code, confirm understanding of:

  • Which collective operation is needed (all-gather vs all-reduce)
  • What the final output shape should be
  • Whether simulation should actually perform collective ops or defer them
  • How bias should be handled for this parallelism type
  • What happens for edge cases (world_size=1, non-divisible dimensions)

Post-Implementation Checklist

After writing code:

  • Read back the complete implementation file to verify no truncation
  • Verify output shapes match expected dimensions for all world sizes
  • Trace through a simple example manually to verify correctness
  • Test trivial case (world_size=1) matches non-parallel baseline
  • Test at least one non-trivial case (world_size=2 or 4)

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

26.68%
按下载量换算78

Gemini CLI

23.05%
按下载量换算68

Codex

18.65%
按下载量换算55

Antigravity

13.04%
按下载量换算38

OpenCode

8.04%
按下载量换算24

windsurf

3.18%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills