Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

convert-hf-to-te

БесплатноБез исполняемых скриптовНе проверен

Adapt a Hugging Face PyTorch model for training with compatible Transformer Engine modules. Replace a decoder layer, sublayer or individual operation and map…

NVIDIAот NVIDIA★ 4 269 звёзд на GitHub

Об этом скилле

Convert a Hugging Face model to Transformer Engine

Use the project's requested entry point or add a model-family module such as te_llama.py. Replace compatible building blocks of the Hugging Face (HF) model with Transformer Engine (TE) modules and load the original checkpoint into them. The building block is the whole transformer layer, as for Llama and Gemma, or else the attention (MHA, linear attention) and MLP or MoE blocks inside it. A partial conversion can also replace a single operation inside an HF block. For a review or plan, stop after the requested feasibility, boundary or weight-mapping decision in Steps 1–3. For a local implementation, Step 4 ends at the first BF16 forward comparison. Use Step 5 for requested training checks, integration or performance measurements at the scope the user specified. In this skill te means transformer_engine.pytorch.

In a plan or implementation handoff, lead with the chosen replacement boundary and weight map.

Not for JAX or inference serving (vLLM, TensorRT-LLM). For Megatron-LM or another PyTorch framework, the TE implementation can serve as a reference for which TE modules to use and how the weights map.

1. Check the architecture and feasibility

Identify the training path, representative inputs and target precision from the request and project. Read the model's config.json, checkpoint keys and decoder forward at the requested revision or installed version. For each distinct layer type, record its modules, which tensors they consume or share, and their checkpoint keys. Use this inventory to identify candidate TE modules. Consult examples for the relevant boundary and verify API choices against the target TE release. For source-only work, use those sources to resolve API and layout questions before setting up a runtime.

HF component Candidate TE module
The whole transformer block te.TransformerLayer
Self-attention with QKV and output projections te.MultiheadAttention. Set input_layernorm=True only when it replaces HF's input norm, so the norm runs once.
Scaled dot-product attention on projected Q/K/V te.DotProductAttention
Input norm followed by one linear projection, which can pack compatible projections of the same normalized input te.LayerNormLinear
A norm and a dense MLP te.LayerNormMLP
Grouped linear projections across MoE experts te.ops.GroupedLinear. The surrounding MoE block supplies activation and routing.
Dispatch and combine across expert-parallel ranks te.ops.MoeDispatch and te.ops.MoeCombine in the experimental operation fuser. Check compatibility with the router outputs and backend.
A single projection or norm te.Linear, te.RMSNorm, te.LayerNorm

The table is not exhaustive. Newer architectures may need other TE modules, such as the experimental Gated DeltaNet core (te.GatedDeltaNetAttention). Check that the installed TE exports the candidate and its backend supports the target inputs and workload. Keep unsupported components in HF.

2. Choose the granularity

Start with the largest region that preserves HF's computation and the interface its caller uses. The level describes which part of the HF model you replace.

Level 1: the whole transformer block. Try one te.TransformerLayer for the HF decoder block. Match the attention and MLP widths, query and KV head counts, normalization and residual order, activation, mask, and rotary positions for the requested inputs. A causal HF decoder with only self-attention uses TE's self-attention topology with a causal mask. In TE 2.18, layer_type="decoder" adds cross-attention. When the block matches, substitute it at the HF decoder entry point and preserve the caller's arguments, layout and return value. Map the norm, attention and MLP weights and compare the whole block's BF16 output to HF in Step 4. Llama wrapper · Gemma constructor · TE layer topology

Level 2: attention and MLP separately. If the whole layer does not fit, consider each sublayer independently. Experts and linear attention are two examples from a non-exhaustive list.

  • Attention: use te.MultiheadAttention when it implements the target attention block.
  • MLP: te.LayerNormMLP for a dense MLP. For mixture-of-experts (MoE), compose a model-specific block around the compatible operations. For example, te_mixtral.py defines its own `TEMixtralS
Полный SKILL.md на GitHub

Установить convert-hf-to-te в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Bash
Read
Write
Edit
Glob
Grep

Вложенные файлы

BENCHMARK.mdevals/EVAL.mdevals/evals.jsonskill-card.mdskill.oms.sig

FAQ

Что делает скилл convert-hf-to-te?

Adapt a Hugging Face PyTorch model for training with compatible Transformer Engine modules. Replace a decoder layer, sublayer or individual operation and map its checkpoint weights. Choose fusions that preserve the requested workload's behavior.

Как установить скилл convert-hf-to-te?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл convert-hf-to-te запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить convert-hf-to-te с