onescience-parallel

A skill for changing PyTorch models to run across multiple devices with pipeline and tensor parallelism. Pipeline parallelism splits model stages between devices, while tensor parallelism splits individual calculations.

In plain words
What is it for?
It helps split a model into pipeline stages, replace linear layers with parallel versions, connect training data and forward-step interfaces, and create distributed attention, MLP, and fusion modules.
Why use it?
It provides a defined path for turning a single-device model into a distributed training model while preserving existing interfaces and avoiding common import problems.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/onescience-ai/oneskills/onescience-parallel
Any agent
npx skills add onescience-ai/OneSkills --skill onescience-parallel
Clone the repo
git clone --depth 1 https://github.com/onescience-ai/OneSkills

Made for: Claude Code, Codex.

Per session 210 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 10,439 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00210 $0.10439
Opus 5 $0.00105 $0.05220
Sonnet 5 $0.00042 $0.02088
Haiku 4.5 $0.00021 $0.01044

Measured 2d ago against content hash 403631e0dec4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

onescience-parallel scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/onescience-parallel/SKILL.md · 1,013 lines

How it starts

The opening of the file, as written. The whole thing — 1,013 lines — stays where its author put it; the contents beside it link to each section on GitHub.

输入获取方式

本技能支持两种输入方式:

  1. 上下文 handoff(默认):从调用方传入的 step_handoff 获取任务信息。
  2. 文件 handoff(autonomous_mode):从 .onescience/handoff/step_{step_id}.yaml 读取任务信息。执行后,将结果写入 .onescience/handoff/step_{step_id}_result.yaml

启动时优先检查 .onescience/handoff/ 目录是否存在对应的交接文件;若存在则使用文件模式,否则使用上下文模式。

文件交接格式参见 skills/onescience-orchestrator/references/file_handoff_contract.md

Pipeline Parallel 改造 Skill

重要原则(必读)

  1. 复用 OneScience 模块:所有基础模块必须使用 onescience 已有实现,禁止重复实现
  2. 先读后写:开始前必须阅读 context.mdarchitecture.md
  3. 参考已有实现:必须参考 examples/earth/pangu_weather_distributed/ 的 pangu 实现
  4. 保持参数一致性:进行并行改造时,各 Stage 类的 __init__ 参数签名和内部初始化逻辑应尽可能与原模型保持完全一致(如 configmask 等参数的处 理),避免随意更改参数名或逻辑。
  5. 严禁循环导入:在创建 Distributed 模块(如 {StyleName}DistributedFuser)时, 禁止在模块内部导入 OneFuserOneTransformer 等顶层包装类 ,因为这些包装类通常已经导入了你的 Distributed 模块,会导致 ImportError。应直接导入具体的子模块类(如 from .{stylename}distributedlocalsiefuser im port {StyleName}DistributedLocalSIEFuser)。

改造三步流程

步骤 1:模型拆分  (PP)  →  步骤 2: TP 并行模块   →  步骤 3:训练接口对接

步骤 1:模型拆分(Pipeline Parallel)

1.1 切分策略

按前向执行顺序找计算串行边界,切点满足:

  • 数据依赖最少(只有一个 tensor 出口)
  • 跨 stage 传输的中间 tensor 尽量小
  • 各 stage 计算量尽量均衡

典型 4-stage 切分(U-Net/Encoder-Decoder 结构):

Stage 内容 说明
0 Embedding + Encoder 前半 首阶段,产生 skip connection
1 Downsample + 中间层 下采样后的计算密集区
2 解码层 + Upsample 解码器前半段
3 Decoder 后半 + Recovery 消费 skip,产出最终结果

1.2 每个 Stage 的必要属性

class MyModel_stageN(Module):
    def __init__(self, original_arg1, original_arg2, ..., megatron_config=None):
        """
        参数签名应尽可能与原模型保持一致。
        如果原模型第一个参数是  config (yaml配置 ),则保持不变;
        额外传入的  Megatron 核心配置建议命名为  megatron_config 避免冲突。
        """
        super().__init__(meta=MetaData())

        # ① 必须有这三个属性,均设为 None
        self.pre_process = None
        self.share_embeddings_and_output_weights = None
        self.input_tensor = None          # Stage 0 也要有

        # ② 必须初始化  config(Megatron get_model_config() 需要)
        # 使用传入的  megatron_config,若无则从  args 获取
        if megatron_config is None:
            args = get_args()
            megatron_config = core_transformer_config_from_args(args)
        self.config = megatron_config

        # ③ 保持原模型的初始化逻辑
        self.arg1 = original_arg1
        # ... 原模型的参数处理  ...

    def set_input_tensor(self, input_tensor):
        """Megatron pipeline 调度钩子,所有  Stage 都必须实现 """
        self.input_tensor = input_tensor

Read the full file on GitHub · 1,013 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 1,013 lines · 210 tokens per session scan A 403631e0dec4

Subscribe to this mod's changes

onescience-parallel is a skill published in the GitHub repository onescience-ai/OneSkills (18 stars, last pushed 19d ago), licensed MIT. It adds 210 tokens to every session and 10,439 once invoked, about $0.0011 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

codex-autoresearch

Run autonomous, measurable experiments in a Git repository: change one hypothesis, verify a numeric metric, keep improvements, and revert failures. Use when the user wants Codex to keep iterating toward a numeric target in the foreground or as a detached background run. Do not use for ordinary one-shot coding…

leo-lilinxiao/codex-autoresearch · 80 tokens

evo-memory

Manages persistent research memory across ideation and experimentation cycles. Maintains two stores: Ideation Memory MI (feasible/unsuccessful directions) and Experimentation Memory ME (reusable strategies for data processing, model training, architecture, debugging). Three evolution mechanisms: IDE (after…

EvoScientist/EvoSkills · 186 tokens

map-wayfind

Decision-frontier wayfinding: build and work a durable map of open design decisions BEFORE planning, for large or foggy efforts where /map-plan would force premature decomposition. Use when a task is too big or too vague to decompose — many unknowns, tangled decisions, or "I'm not even sure what to build yet" — and…

azalio/map-framework · 182 tokens

clipboard

Copy text to clipboard with optional rich formatting. Triggers on "copy to clipboard", "copy that", "pbcopy", "copy formatted", "copy rich text".

CodeAlive-AI/ai-driven-development · 36 tokens

neo4j-modeling-skill

Design, review, and refactor Neo4j graph data models. Use when choosing node labels vs relationship types vs properties, migrating relational/document schemas to graph, detecting anti-patterns (generic labels, supernodes, missing constraints), designing intermediate nodes for n-ary relationships, enforcing schema with…

neo4j-contrib/neo4j-skills · 152 tokens

alphafold-database

Access AlphaFold 200M+ AI-predicted protein structures. Retrieve structures by UniProt ID, download PDB/mmCIF files, analyze confidence metrics (pLDDT, PAE), for drug discovery and structural biology.

agent-skills-hub/agent-skills-hub · 54 tokens