Metadata-Version: 2.4
Name: intel-extension-for-llm
Version: 0.1.0
Summary: Intel's extension for running and tuning LLMs on Intel XPU/CPU — optimize, quantize, and serve with OpenAI-compatible endpoint.
Author: 
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown

# intel-extension-for-llm

`intel-extension-for-llm` is Intel's extension for running and tuning large
language models on Intel hardware — Intel Arc GPUs, Intel Data Center GPUs, and
Intel CPUs — through a unified Python API. It builds on the oneAPI software stack
(Intel Extension for PyTorch, SYCL/XPU runtime, oneDNN, oneCCL) to deliver
optimized inference and fine-tuning for popular transformer architectures without
changing your model code. It is for developers who want the best out-of-box LLM
performance on Intel XPU/CPU and a drop-in path from a Hugging Face model to a
hardware-accelerated serving pipeline.

## Features

- `optimize(model, device="xpu")` fuses IPEX kernels, applies AMP bf16, and enables
  XPU graph capture for faster decoder iterations on Arc and PVC GPUs.
- Built-in quantization paths: weight-only INT8/INT4 via oneDNN and SmoothQuant/
  AWQ-compatible pipelines, with calibrated accuracy hooks.
- Drop-in `transformers` integration: load with `from_pretrained(...,
  device_map="xpu", use_ipex=True)` and the extension wires SYCL kernels in.
- CPU-optimized inference for Xeon with NUMA-aware threading and AVX-512 AMX
  acceleration where available.
- `serve(model, ...)` helper launches an OpenAI-compatible endpoint on XPU or CPU,
  with continuous batching and KV-cache reuse.

## Installation

```bash
pip install intel-extension-for-llm
# IPEX + oneAPI runtime for XPU
pip install "intel-extension-for-llm[xpu]"
# CPU-only path (Xeon)
pip install "intel-extension-for-llm[cpu]"
```

## Quick start

```python
import torch, intel_extension_for_llm as ill
from transformers import AutoModelForCausalLM, AutoTokenizer

dev = "xpu" if torch.xpu.is_available() else "cpu"
tok = AutoTokenizer.from_pretrained("meta-llama/Llama-3-8B")
model = AutoModelForCausalLM.from_pretrained(
    "meta-llama/Llama-3-8B", torch_dtype=torch.bfloat16
).to(dev)

model = ill.optimize(model, device=dev, quantize="int8_weight_only")

ids = tok("Explain oneAPI in one sentence.", return_tensors="pt").to(dev)
print(tok.decode(model.generate(**ids, max_new_tokens=64)[0]))
```

## API

- `ill.optimize(model, *, device, quantize=None, amp="bf16")` — kernel fusion +
  optional quantization, returns the optimized model.
- `ill.quantize(model, *, scheme, calibration_data=None)` — INT8/INT4 quantization.
- `ill.serve(model, *, host, port, batch_size)` — OpenAI-compatible XPU/CPU server.

## Configuration

Device selection honors `IPEX_DEVICE` (or `device=` args). XPU memory usage is
controlled via `SYCL_PI_LEVEL_ZERO_USE_IMMEDIATE_COMMANDLISTS=1` and the standard
ZE_* environment flags; see the oneAPI docs for the full set.

## License

MIT
