xpu-port
Execute a single-target CUDA-to-XPU port of a PyTorch Python repo with libcst-based scan, mechanical rewrite, optional generic availability checks, and CPU…
от intel★ 54 звезды на GitHub
Установить xpu-port в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Об этом скилле
xpu-port
Three deterministic scripts; the agent drives the loop.
scripts/
├── xpu_port_scan.py # libcst, classifies sites mechanical/semantic/escalate
├── xpu_port_rewrite.py # libcst, named transforms, --check previews diff
└── xpu_port_verify.py # CPU FP64 reference vs target dtype, one forward
pip install libcst
Targets
Single-target XPU only. After the port, the codebase runs on Intel XPU. CUDA call sites are rewritten, not dual-gated. If the user wants both CUDA and XPU at runtime (dual-target), stop and say so — that's a different problem (per-call-site guards, device-aware factories) and this skill produces broken half-ported code if used for it.
Backstop — wrong entry point
This skill executes; it does not assess or route. One redirect exists, pointing one way. If the request is really an assessment or a whole-repo migration ("migrate this repo", "what would it take to run on XPU" — scope not yet set), hand it to cuda-to-xpu-migration and stop; its report's Next steps lead back here for the Python surface.
The same backstop covers mis-scoped ports. This skill reads Python source only — its gates say nothing about Dockerfiles, launch scripts, or dependency pins. When no migration report is in hand and the step-1 scan comes back empty while its advisory flags NVIDIA/CUDA infrastructure surfaces, the port was mis-scoped: hand it to cuda-to-xpu-migration and stop. When a migration report is in hand, execute the Python surface it scoped and list its non-Python surfaces as documented-not-rewritten — an advisory on the final scan does not reopen this gate (see step 5).
Procedure
The port's minimum gate is final scan empty + verifier green. Both are necessary; neither alone is sufficient (for service repos with no single forward, the serving skill's smoke test stands in for the verifier — see step 6).
Important: the verifier confirms one forward pass is
numerically correct — it does not confirm the training loop
runs end-to-end (e.g. torch.compile, custom LR schedulers, or
data-loader workers may still fail on XPU). After the gates pass,
run at least 2 real training iterations on the target device
before declaring the port complete.
1. Scan
python3 path/to/xpu_port_scan.py . > findings.json
Findings tagged mechanical (safe to rewrite), semantic (agent
edits per references/semantic-patterns.md), escalate (custom
.cu, CUDAExtension, CUDA-only attrs — agent decides per
finding). Each finding also carries a route field: a skill name
(e.g. torch-xpu-profile) names the skill an orchestrating agent
should chain to for that site; null means there is no single
downstream skill — either xpu-port resolves the site in-loop (a
mechanical transform or a semantic hand-edit) or the site is
escalate (redesign, no mechanical port). Read bucket first:
null does not by itself mean "already handled".
Empty scan on an NVIDIA-stacked repo: if the scan found no real
CUDA sites (synthetic unreadable/unparseable bookkeeping findings
don't count) but the JSON contains an advisory block (also printed
to stderr; emitted on directory scans only — a single-file scan never
carries one), the repo has NVIDIA/CUDA surface xpu-port cannot rewrite —
container files, dependency pins, launch scripts, or distinctive
cloud NIM/API endpoints (e.g. integrate.api.nvidia.com) in
source. That is an API-first migration, not a torch.cuda port.
Stop and route to cuda-to-xpu-migration (assessment) then
xpu-deploy-plan (serving plan). That is the no-plan case: with
a migration report already in hand, don't bounce back — follow the
report's routes for the non-Python surfaces instead (see Backstop).
A bare 0 with no advisory is a
hint, not a proof of "nothing to migrate": the check is bounded
(distinctive markers, capped file read), so for anything beyond a
pure PyTorch repo, confirm with cuda-to-xpu-migration's full
inventory scan.
2. Mechanical pass
for t in device_string cuda_to_xpu dot_cuda imports dist_backend amp_autocast amp_gradscaler; do
python3 path/to/xpu_port_rewrite.py --transform "$t" --path .
done
--check previews the diff without writing. Read
references/cuda_to_xpu_whitelist.md before running the mechanical
pass to understand what cuda_to_xpu rewrites and why CUDA-only
attrs are flagged instead.
Availability defaults to torch.xpu.is_available(). To request
torch.accelerator.is_available() instead, read the availability
guidance in references/semantic-patterns.md, then add
--availability-api accelerator to the cuda_to_xpu invocation.
Existing generic checks stay unchanged. This option covers qualified
availability references only; the port and verifier still target XPU.
3. Re-scan (gate)
python3 path/to/xpu_port_scan.py . > findings.after_mechanical.json
Mechanical bucket must be 0. If not, a transform missed something — don't proceed until resolv
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
- references/cuda_to_xpu_whitelist.md
- references/semantic-patterns.md
- scripts/xpu_port_rewrite.py
- scripts/xpu_port_scan.py
- scripts/xpu_port_verify.py
FAQ
Что делает скилл xpu-port?
Execute a single-target CUDA-to-XPU port of a PyTorch Python repo with libcst-based scan, mechanical rewrite, optional generic availability checks, and CPU FP64 vs target-dtype correctness verify on one forward pass. Use when the request says "port" — "port my repo to XPU", "port my repo at ./my-model to XPU", "rewrite the CUDA calls to XPU", "apply the mechanical transforms", "run the scan and rewrite", "make the port changes now". Not for the "migrate" verb ("migrate my repo", "migrate this repo to XPU") or a bare whole-repo workflow request where scope is not yet set — those start with cuda-to-xpu-migration, whose plan routes here. Not for assessment-only, throughput (torch-xpu-bench), op-level slowness (torch-xpu-profile), custom CUDA C++ extensions, or dual-target CUDA+XPU codebases.
Как установить скилл xpu-port?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл xpu-port запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
theme-factory
AnthropicToolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
access
AnthropicManage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
configure
AnthropicSet up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
access
AnthropicManage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…