Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Hugging Face 7 min read How-to mediumAdept

A Chatbot on your Laptop: Phi-2 on Intel Meteor Lake

Microsoft's 2.7B-parameter Phi-2 can run as a usable local chatbot on a mid-range Intel Core Ultra 7 155H (Meteor Lake) laptop once its weights are quantized to 4-bit with OpenVINO through Hugging Face's Optimum Intel library. The walkthrough covers Meteor Lake's CPU, iGPU (Xe Vector Engines with DP4a) and NPU, then shows code using OVWeightQuantizationConfig with bits=4, group_size=128 and ratio=0.8, where 80% of weights go to 4-bit and the rest to 8-bit. Lowering ratio or group size improves accuracy but costs model size and latency. Generation quality and speed are shown only through demo videos, with no measured benchmarks.

Assumes: Hugging Face TransformersLLM quantization basics

Related posts

  • Making LLMs lighter with AutoGPTQ and transformers

    Hugging Face mediumAdept

    AutoGPTQ is now integrated into Hugging Face Transformers (via Optimum), letting users quantize and run LLMs at 8, 4, 3 or 2 bits with the GPTQ post-training method. GPTQ needs a calibration dataset and quantizes only the weights: int4 weights are dequantized on the fly in a fused kernel while compute stays in fp16. That gives nearly 4x memory savings with negligible accuracy loss at 4-bit. On an A100 at batch size 1, Llama-2-7B with the exllama kernel dropped peak memory from about 29 GB to 10.5 GB with slightly better per-token latency than fp16. Text-Generation-Inference can now serve a 70B model on a single 80GB GPU and PEFT adapters can be fine-tuned on top, but the kernels slow down at larger batch sizes and W4A8 or Triton kernels remain open work.

  • Optimize and deploy with Optimum-Intel and OpenVINO GenAI

    Hugging Face mediumAdept

    Hugging Face Transformers LLMs can be exported to OpenVINO IR with Optimum-Intel, quantized with NNCF, and deployed through the lightweight OpenVINO GenAI LLMPipeline from Python or C++. Models over one billion parameters default to INT8 weights during export. For Llama 3.1 8B the recommendation is to stack AWQ, scale estimation and mixed INT4/INT8 quantization using a calibration dataset. Wikitext perplexity goes from 7.34 in FP32 to 7.35 at INT8 and 7.83 at INT4. Code examples cover export via API and CLI, generation config, streaming, and chat mode that reuses the KV cache across turns.

  • Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA

    Hugging Face mediumAdept

    bitsandbytes now integrates 4-bit quantization into Hugging Face transformers, letting most accelerate-loadable models (text, vision, multimodal) run in 4-bit and be fine-tuned via QLoRA, which backpropagates through a frozen 4-bit base model into LoRA adapters. QLoRA stores weights in NF4 and dequantizes to bfloat16 for compute, adds double quantization (saving ~0.4 bits per parameter) and paged optimizers, and matches 16-bit fine-tuning while fitting a 33B model on a 24GB GPU or 65B on a 48GB GPU. The post explains FP8/FP4 bit layouts and shows BitsAndBytesConfig usage. Recommended defaults are NF4 for precision, double quant for memory pressure, and a 16-bit compute dtype for speed.

  • Quanto: a PyTorch quantization backend for Optimum

    Hugging Face mediumAdept

    Quanto is a PyTorch quantization backend for Optimum that works in eager mode on any device (CPU, CUDA, MPS), supports int2/int4/int8/float8 weights and int8/float8 activations, and accelerates int8-int8, fp16-int4, bf16-int8 and bf16-int4 matmuls on CUDA. The workflow runs from dynamic quantization through optional activation calibration and quantization-aware training to freezing integer weights, then serializing with safetensors plus a quantization map for reloading via requantize. It integrates with transformers through QuantoConfig, works across modalities such as Whisper, and is torch.compile-friendly when activations are left unquantized.

  • Blazing Fast SetFit Inference with 🤗 Optimum Intel on Xeon

    Hugging Face mediumAdept

    Post-training static int8 quantization of a SetFit model body with Optimum Intel and Intel Neural Compressor speeds up inference on Xeon CPUs by up to 7.8x in throughput with negligible accuracy loss. The walkthrough calibrates on 100 rotten_tomatoes samples, quantizes a bge-small SetFit model with the IPEX backend, and benchmarks it against fp32 Transformers and IPEX bf16 with TorchScript. At batch size 1, latency drops from 15.69 ms to 4.55 ms (3.45x), model size shrinks from 127 MB to 45 MB, and sst2 accuracy moves only from 88.4% to 88.1%.

The quest for software engineering knowledge.

Look:
Layout: