Logo di Torch Xpu Bench

Torch Xpu Bench

Organizzazione
intel
torch-xpu-bench

Benchmark a Hugging Face model on an Intel GPU through pure PyTorch + Transformers, **single-process, no HTTP server**. Measures generate() throughput in tokens/sec, time-to-first-token, decode-step latency, and peak XPU memory. Also covers diffusion and encoder-only models via `references/non-llm-snippets.md`. Use after **model-can-it-fit** to validate predicted memory against `torch.xpu.max_memory_allocated()`.

Panoramica

Autoreintel
Repositoryskills
Nome della skilltorch-xpu-bench
Stelle
31
Fork
14
File inclusi
2
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • 2 file inclusi

    Script, modelli di documento e riferimenti che il modello può leggere mentre lavora. I file sono di sola lettura e non vengono mai eseguiti.

  • Open source

    Pubblicata da intel su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Torch Xpu Bench in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/intel/skills/tree/main/skills/torch-xpu-bench
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Nuova skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella nella cartella delle skill di quell'agente.

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-bench .claude/skills/torch-xpu-bench
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Torch Xpu Bench in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Torch Xpu Bench non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Torch Xpu Bench non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

torch-xpu-bench

Pure-PyTorch benchmarks of HF models on XPU. Measures bare model.generate() with no scheduler, no continuous batching, no API overhead. For serving-shape numbers (TTFT/TPOT/ITL under concurrency) use vllm-xpu-bench.

Important: This skill provides a ready-to-use benchmark script at {base_dir}/scripts/bench.py. Do not write your own benchmark script; use the provided one.

Use cases:

  • TTFT and decode rate of a single sequence at a given dtype.
  • A/B dtypes (bf16 vs fp16), compile on/off, model size.
  • Decide whether --enforce-eager is worth adding in vLLM for a problem model (graphs are on by default from v0.31.0).
  • Validate model-can-it-fit predictions against max_memory_allocated.

For diffusion and encoder-only models, see references/non-llm-snippets.md.

CUDA → XPU translation

CUDAXPU
torch.cuda.synchronize()torch.xpu.synchronize()
torch.cuda.Event(enable_timing=True)torch.xpu.Event(enable_timing=True)
torch.cuda.max_memory_allocated()torch.xpu.max_memory_allocated()
torch.cuda.reset_peak_memory_stats()torch.xpu.reset_peak_memory_stats()
torch.cuda.empty_cache()torch.xpu.empty_cache()

Two gotchas:

  • Synchronise before timing. XPU kernels launch async; without torch.xpu.synchronize() you measure launch latency.
  • Warm up. First call compiles XPU Triton kernels; first compiled-graph call triggers capture. Discard the first 1–3 runs.

Hosts with non-Intel GPUs

If nvidia-smi or rocm-smi reports hardware, bench code that doesn't pin a device may silently land on CUDA/ROCm. Defences:

sh
export CUDA_VISIBLE_DEVICES=     # hide all NVIDIA
export HIP_VISIBLE_DEVICES=      # hide all AMD ROCm
export ZE_AFFINITY_MASK=0        # pick a specific Intel device

scripts/bench.py asserts model parameters land on xpu after from_pretrained; replicate in your own benches. Cross-check with xpu-smi dump -d 0 -m 5 — if XPU memory doesn't climb, the bench is on the wrong device.

These all load onto xpu:0 when only an Intel XPU is visible: device_map="xpu" / "xpu:0" / 0 / "auto" / {"": "xpu"} / {"": 0}. hf_device_map is empty for whole-model placement; populates only on multi-GPU splits.

Quickstart

Always use the provided benchmark script at {base_dir}/scripts/bench.py:

sh
python3 {base_dir}/scripts/bench.py \
    --model Qwen/Qwen2.5-1.5B-Instruct \
    --dtype bfloat16 \
    --prompt-tokens 512 --gen-tokens 128 \
    --warmup 2 --runs 5

--revision pins the Hugging Face repo revision (branch, tag, or commit sha; default main). Pass a commit sha when a benchmark number has to stay reproducible — otherwise the run silently follows whatever main points at.

Output:

Run  TTFT (ms)  Decode (ms/tok)  Total (s)  Throughput (tok/s)
1      ...           ...           ...           ...
...

Median: TTFT ... ms, decode ... ms/tok, throughput ... tok/s
Peak XPU memory: ... GiB

Use this relative: capture a baseline median, change one knob, re-run. Throughput won't match anyone else's; the delta between two runs on your hardware is the signal.

Per-run metrics

  • TTFT — wall time from generate() entry to first token, dominated by prefill.
  • Decode (ms/tok) — per-token time for tokens 2..N, averaged.
  • Total (s) — full call wall time.
  • Throughput — gen_tokens / Total_s.
  • Peak XPU memory — torch.xpu.max_memory_allocated().

Median across runs is robust to jitter; mean isn't. Median delta within ~3% is noise; >5% is signal; >10% is a clear win/regression.

A/B comparisons

sh
python3 {base_dir}/scripts/bench.py --model "$M" --dtype bfloat16 --runs 5 > bench-bf16.txt
python3 {base_dir}/scripts/bench.py --model "$M" --dtype float16  --runs 5 > bench-fp16.txt
diff -u <(grep Median bench-bf16.txt) <(grep Median bench-fp16.txt)

Same shape for --compile on/off, model A vs B.

When torch.compile actually helps

vLLM v0.31.0+ captures XPU graphs by default, so the compiled path is already what you serve. Use this to confirm the pattern on Battlemage before you consider adding --enforce-eager back for a model that misbehaves under capture:

sh
python3 {base_dir}/scripts/bench.py --model "$M" --runs 5             # eager
python3 {base_dir}/scripts/bench.py --model "$M" --compile --runs 5   # compiled

If compiled wins on decode (ms/tok) and content is correct, leave graphs on in vllm-xpu-run — emit no --enforce-eager. Only if eager measures faster, or compiled output is wrong, is the flag justified for that model.

Compile gain scales with model size — sub-1B models see little win because launch overhead and kernel work are similar in magnitude. First compiled run includes graph capture cost; default warmup is post-capture. If a 0.5B sees no win, retest at 7B+ before concluding "compile doesn't help."

Feedback loop with model-can-it-fit

Run against the model you tested with model-can-it-fit. Compare the bench's "Peak XPU memory" against the calculator's "Total" line:

  • Decoder-only LLM, gap >20% -> calculator bug; file an issue.
  • VLM / diffusion -> gap is expected (the calculator covers decoder-only). Use the measurement to refine your headroom budget.
  • Lower than predicted -> KV cache may not have grown to the configured max_seq_len; rerun with longer --gen-tokens.

Bench-procedure checklist (any workload)

  1. Pin device (device_map="xpu"); verify next(model.parameters()).device.
  2. reset_peak_memory_stats(0) + empty_cache() once.
  3. Warm: 1–3 unmeasured iterations.
  4. Synchronise around the timer:
    python
    torch.xpu.synchronize(); t = time.perf_counter()
    <work>
    torch.xpu.synchronize(); times.append(time.perf_counter() - t)
  5. N=5 timed iterations (raise to 10–20 if >10% spread).
  6. Report median, not mean. Add p99 for latency-tail concerns.
  7. Cross-check with xpu-smi dump -d 0 -m 5,18 -i 1 from host.

Common errors

  • Cannot find any XPU devices → check xpu-container-run / xpu-discover before running.
  • XPU out of memory → reduce --prompt-tokens / --gen-tokens, use float16, or quantize. Run model-can-it-fit first.
  • TTFT >> decode → expected on long prompts.
  • Suspiciously fast decode + non-language output → garbage generation. Validate sample output before trusting throughput.
  • --compile first run much slower → graph capture cost; raise --warmup.

Env vars

VariablePurpose
ZE_AFFINITY_MASKPin to one XPU.
TRITON_CACHE_DIRPersist XPU Triton kernels across runs.
PYTORCH_ENABLE_XPU_FALLBACK=0Make CPU fallbacks loud during a bench.
HF_TOKENGated checkpoints.

What this skill does NOT cover

  • vLLM serving benches → vllm-xpu-bench.
  • SGLang serving benches → sglang-xpu-bench.
  • Profiling → torch-xpu-profile.
  • Training throughput — out of scope.

References

File inclusi

Il modello legge questi file quando servono, mentre la skill è caricata. Sono accessibili in sola lettura e non vengono mai eseguiti.

Domande frequenti

Cosa fa la skill IA Torch Xpu Bench?

Benchmark a Hugging Face model on an Intel GPU through pure PyTorch + Transformers, **single-process, no HTTP server**. Measures generate() throughput in tokens/sec, time-to-first-token, decode-step latency, and peak XPU memory. Also covers diffusion and encoder-only models via `references/non-llm-snippets.md`. Use after **model-can-it-fit** to validate predicted memory against `torch.xpu.max_memory_allocated()`.

Perché usare Torch Xpu Bench su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Torch Xpu Bench è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Torch Xpu Bench in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/intel/skills/tree/main/skills/torch-xpu-bench. TypingMind legge il file SKILL.md, include i file associati e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Torch Xpu Bench?

Qualsiasi modello che colleghi in TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Torch Xpu Bench?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Torch Xpu Bench: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Torch Xpu Bench è gratuita?

Sì. È pubblicata su GitHub da intel con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, modelli o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Vedi tutti

Crea subito la tua area di lavoro IA

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇