Torch Xpu Profileのロゴ

Torch Xpu Profile

組織
intel
torch-xpu-profile

Profile a Hugging Face model on Intel GPU at the **PyTorch level** with `torch.profiler` and Kineto. Captures CPU + XPU timeline, exports Chrome trace, identifies hottest kernels and async-overlap gaps. Use when the user asks why a model is slow, which op is the bottleneck, or where the GPU is idle. Not for profiling inside a running vLLM server (use vllm-xpu-profile) or for SYCL-kernel-level signal beneath the PyTorch op layer (use xpu-profile-unitrace).

概要

公開者intel
リポジトリskills
スキル名torch-xpu-profile
スター
31
フォーク
14
同梱ファイル
指示のみ
ライセンスApache-2.0
リンク
  • Markdown形式の指示

    モデルが必要に応じて読み込むSKILL.mdファイルです。関連するリクエストがあったときだけトークンを消費します。

  • どのLLMでも利用可能

    AIスキルはプロバイダー固有のコードではなく、通常のMarkdownなので、GPT、Claude、Gemini、Grok、ローカルモデルで利用できます。

  • 指示だけで完結

    モデルに必要なものはすべて指示に含まれているため、別途同期するファイルはありません。

  • オープンソース

    intelがGitHubで公開しています。インストールする前にソースを確認してください。

インストール

AIスキルTorch Xpu ProfileをTypingMindにインストールすれば、どのLLMでも利用できます。SKILL.mdを読み取れる別のAIエージェントに追加することもできます。

1

TypingMindにインストール

TypingMindはGitHubフォルダから直接スキルをインストールします。SKILL.mdを読み取り、リソースファイルをまとめてローカルに保存します。

  1. アプリを開き、「プラグイン」→「スキル」に移動します。
  2. 「GitHubからインストール」を選択します。
  3. 以下のスキルフォルダのURLを貼り付けて確定します。
    https://github.com/intel/skills/tree/main/skills/torch-xpu-profile
  4. スキルを利用したいチャットごとに、そのスキルを有効にしてください。
「プラグイン」→「スキル」→「スキルを追加」→「GitHubのURLから」を選択し、フォルダのURLを貼り付けて「続行」を押します。
2

別のAIエージェントにインストール

Agent Skills形式を読み取れるAIエージェントなら、このスキルを利用できます。フォルダをそのAIエージェントのスキルディレクトリにコピーしてください。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/intel/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/torch-xpu-profile .claude/skills/torch-xpu-profile
コピー後、新しいスキルを読み込むためにClaude Codeを再起動してください。

TypingMindで使用

TypingMindのチャットでTorch Xpu Profileを有効にするだけで、あとはモデルが対応します。名前と説明がシステムプロンプトに含まれ、関連するリクエストがあると、モデルが指示の全文を自動で読み込みます。手動で呼び出す必要はなく、実際に使用されるまでトークンを消費しません。

関連するリクエストがあると、モデルが自動的にTorch Xpu Profileを読み込みます。

どのAIモデルでも利用可能

AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、Torch Xpu Profileは作成時に想定されたモデルに縛られません。TypingMindに一度インストールすれば、ご自身のAPIキーを使って、GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama、またはご自身で実行するローカルモデルで利用できます。

  • 必要なときだけ読み込み

    システムプロンプトには名前と説明だけが含まれます。関連するリクエストが初めてあったときに指示を取得するため、未使用のスキルにはコストがかかりません。

  • チャットの途中でモデルを切り替え

    スキルはコードではなく指示なので、モデルを切り替えてもそのまま使えます。次のモデルも同じSKILL.mdを読み込みます。

スキルの指示

モデルが読み込むSKILL.mdの内容です。スキルはモデルが従う指示なので、インストールする前に確認してください。

torch-xpu-profile

torch.profiler with ProfilerActivity.XPU captures CPU + XPU op timeline on Kineto. Use for "which aten::* op is slow?", "is the GPU idle?", "is decode kernel-bound?". For server-side profiling use vllm-xpu-profile; for SYCL kernel level use xpu-profile-unitrace.

CUDA -> XPU translation

CUDAXPU
ProfilerActivity.CPU, ProfilerActivity.CUDAProfilerActivity.CPU, ProfilerActivity.XPU
prof.export_chrome_trace("trace.json")identical
record_shapes=True, with_stack=Trueidentical
prof.key_averages().table(sort_by="cuda_time_total")sort_by="xpu_time_total"

Quickstart

python
import torch
from torch.profiler import profile, ProfilerActivity, schedule
from transformers import AutoModelForCausalLM, AutoTokenizer

mid = "Qwen/Qwen2.5-1.5B-Instruct"
tok = AutoTokenizer.from_pretrained(mid)
model = AutoModelForCausalLM.from_pretrained(
    mid, dtype=torch.bfloat16, device_map="xpu"
).eval()
inp = tok("Tell me a joke.", return_tensors="pt").to("xpu")

# Warmup so first-run kernel compile doesn't pollute the trace
with torch.no_grad():
    model.generate(**inp, max_new_tokens=8, do_sample=False,
                   pad_token_id=tok.eos_token_id)

with profile(
    activities=[ProfilerActivity.CPU, ProfilerActivity.XPU],
    record_shapes=True,
    profile_memory=True,
    with_stack=False,
) as prof:
    with torch.no_grad():
        model.generate(**inp, max_new_tokens=64, do_sample=False,
                       pad_token_id=tok.eos_token_id)

print(prof.key_averages().table(sort_by="xpu_time_total", row_limit=20))
prof.export_chrome_trace("trace.json")

Output: trace.json (drag into https://ui.perfetto.dev) plus a top-20 ops table sorted by XPU time.

Reading the trace

  1. Top of key_averages table — first 5 rows are usually 70–90% of XPU time. Top = matmul/attention -> GPU-bound (good). Top = aten::copy_ / H2D-D2H transfers -> bandwidth-bound or paying for unnecessary moves.
  2. Gaps in XPU timeline — wide white bands = GPU waiting for host. Causes: tokenizer on CPU, Python overhead, per-step sync. Decode TPOT spikes correlate with these gaps.
  3. Per-step decode structure — same kernel sequence per token; divergence often means KV reallocation or SWA edge effects.
  4. Memory peaks (with profile_memory=True) — peak before first generated token is prefill; subsequent peaks are KV growth. Compare against model-can-it-fit prediction.

Longer-window profiling with schedule

For multi-step capture without giant files:

python
sched = schedule(skip_first=2, wait=1, warmup=1, active=3, repeat=1)
with profile(activities=[ProfilerActivity.CPU, ProfilerActivity.XPU],
             schedule=sched,
             on_trace_ready=lambda p: p.export_chrome_trace(
                 f"trace_step_{p.step_num}.json")) as prof:
    for step in range(10):
        with torch.no_grad():
            model.generate(**inp, max_new_tokens=16, do_sample=False,
                           pad_token_id=tok.eos_token_id)
        prof.step()

One trace per repeat -> easier to diff than one giant file.

Common errors

  • ProfilerActivity.XPU not supported -> torch build doesn't include XPU profiler. Confirm torch.__version__ ends in +xpu and is recent enough.
  • Empty trace / only CPU ops -> kernel launches not synced before profiler exit. Add torch.xpu.synchronize() at end of with profile(...).
  • Trace > 500 MiB -> use schedule form above for short active windows.
  • "Cannot find any XPU devices" mid-profile -> an op fell back to CPU. Set PYTORCH_ENABLE_XPU_FALLBACK=0 so unsupported ops error loudly.

What to do with the bottleneck

  • Standard transformer op (attention, MLP, layer norm) at unsurprising time -> hardware limit for this dtype. Try a quantized path (see vllm-xpu-run Quantization).
  • Memory copy / H2D-D2H -> input pipeline is the bottleneck. Move tokenizer to a background thread, use pinned memory.
  • Unfamiliar dominating kernel -> SYCL-level investigation; use xpu-profile-unitrace.

Env vars

VariablePurpose
ZE_AFFINITY_MASKPin to one XPU.
PYTORCH_ENABLE_XPU_FALLBACK=0Error on CPU fallbacks instead of hiding them.
KINETO_LOG_LEVEL=INFODiagnose incomplete traces.

What this skill does NOT cover

  • Profiling inside a running vLLM server -> vllm-xpu-profile.
  • SYCL kernel level / hardware metrics -> xpu-profile-unitrace.
  • Fixing a slow kernel — out of scope.

References

よくある質問

AIスキル「Torch Xpu Profile」では何ができますか?

Profile a Hugging Face model on Intel GPU at the **PyTorch level** with `torch.profiler` and Kineto. Captures CPU + XPU timeline, exports Chrome trace, identifies hottest kernels and async-overlap gaps. Use when the user asks why a model is slow, which op is the bottleneck, or where the GPU is idle. Not for profiling inside a running vLLM server (use vllm-xpu-profile) or for SYCL-kernel-level signal beneath the PyTorch op layer (use xpu-profile-unitrace).

TypingMindでTorch Xpu Profileを使うメリットは何ですか?

一度インストールすれば、どのモデルでも使えるからです。Torch Xpu Profileはプロバイダー固有のコードではなく、通常のMarkdownで記述されているため、同じスキルをGPT-5、Claude、Gemini、Grok、ローカルモデルで利用できます。チャットの途中でモデルを切り替えても、そのまま使い続けられます。TypingMindは自分のAPIキーで動作するため、シート単位のサブスクリプションではなく、プロバイダーに直接料金を支払います。スキルとチャットは自分のストレージに保持されます。

TypingMindにTorch Xpu Profileをインストールするにはどうすればよいですか?

TypingMindで「プラグイン」→「スキル」→「GitHubからインストール」を開き、https://github.com/intel/skills/tree/main/skills/torch-xpu-profileを貼り付けてください。TypingMindがSKILL.mdを読み込み、チャットごとに有効にできるスキルとしてインストールします。

Torch Xpu Profileを使えるAIモデルはどれですか?

TypingMindに接続したどのモデルでも利用できます。AIスキルはプロバイダー固有のコードではなく、通常のMarkdownで書かれた指示です。そのため、GPT、Claude、Gemini、Grok、ローカルモデルのいずれも、リクエストが合致したときにこのスキルを読み込めます。

Torch Xpu Profileは何個のAIモデルで使えますか?

数に制限はありません。スキルに対応したモデルであれば、GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llamaなど、どのモデルでもTorch Xpu Profileを利用できます。すべてTypingMind上で、自分のAPIキーを使って利用できます。

AIスキル「Torch Xpu Profile」は無料ですか?

はい。intelがGitHubでApache-2.0ライセンスの下で公開しています。支払いが必要なのは、利用したトークンに対する、ご自身が契約するAIプロバイダーへの料金だけです。

AIスキルとは何ですか?

AIスキルは、特定のタスクの実行方法をAIモデルに教える、再利用可能な指示のセットです。オープンなAgent Skills形式に従い、名前と説明を含むSKILL.mdファイルに加え、モデルが必要とするスクリプト、テンプレート、参照ファイルで構成されます。モデルはリクエストがスキルに合致したときだけ指示を読み込むため、インストール済みのスキルも、使うまでは費用がかかりません。

AIスキルは、プラグインやMCPサーバーとどう違いますか?

プラグインやMCPサーバーは、モデルが呼び出せる新しいツールを提供します。ツールとは、どこかで実行され、結果を返すコードです。一方、AIスキルは、タスクへの取り組み方、従うべき手順、望ましい出力の例といった知識や進め方をモデルに伝えます。スキルは通常のMarkdownで記述されているため、サーバー、APIキー、実行環境は不要で、どのモデルでも利用できます。

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇