HUGGING FACE PRO LAB SERIES · 10 GPU/ZEROGPU LABS
PRO Lab Series 05: Squeezing Every Watt — Quantization, Optimum & Low-Latency Serving
This dedicated PRO lab series harnesses Hugging Face PRO capabilities (8× ZeroGPU priority, Inference Providers routing, private datasets, and Spaces Dev Mode) across ten reproducible exercises—combining Debian 12/13 scripts with multi-stage non-root OCI containers that bind the NVIDIA Container Toolkit strictly where GPU acceleration is used.
Authored by Imad Soltani (human author, sole release authority) with Antigravity (Google DeepMind, non-human co-author).
1. Series Architecture, Hardware & Hugging Face Curriculum Linkage
7. Self-Check Comprehension Gate
Why does this lab series enforce a non-root multi-stage OCI container and idempotent Debian setup?
Multi-stage builds strip compilers and build secrets from the runtime layer, non-root UID execution limits blast radius if a dependency or prompt-triggered tool misbehaves, and idempotent Debian setup ensures repeatable runs across workstations and CI without hidden host drift.
How does the 30/30/30/10 progression split map to operational readiness?
Labs 01–03 establish clean data and deterministic baselines (Beginner), Labs 04–06 integrate adaptation, paired evaluation, and OCI packaging (Practitioner), Labs 07–09 harden latency, security boundaries, and governance compliance (Expert), and Lab 10 consolidates artifacts and primary documentation links (Capstone).
Complete 10-Lab Progression (30% Beginner · 30% Practitioner · 30% Expert · 10% Capstone & Resources)
| ID | Series-Specific Lab Module | Level | Duration | Cost / Tier | Expected Result & Capability |
|---|
| LAB-PRO-05-01 | Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | Beginner | 35 min | PRO ($9/mo) | Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F): Design, verify, and deploy reproducible 'Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-02 | KV-Cache Sizing & PagedAttention Arithmetic | Beginner | 40 min | PRO ($9/mo) | Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F): Design, verify, and deploy reproducible 'KV-Cache Sizing & PagedAttention Arithmetic' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-03 | Optimum Export & Kernel Fusion Verification | Beginner | 45 min | PRO ($9/mo) | Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F): Design, verify, and deploy reproducible 'Optimum Export & Kernel Fusion Verification' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-04 | Calibration-Dataset Sensitivity in Post-Training Quantization | Practitioner | 50 min | PRO ($9/mo) | Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F): Design, verify, and deploy reproducible 'Calibration-Dataset Sensitivity in Post-Training Quantization' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-05 | Continuous Batching & Speculative Decoding Benchmarks | Practitioner | 55 min | PRO ($9/mo) | Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F): Design, verify, and deploy reproducible 'Continuous Batching & Speculative Decoding Benchmarks' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-06 | Rootless GPU Serving Container (Docker / containerd / CRI-O) | Practitioner | 60 min | PRO ($9/mo) | Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F): Design, verify, and deploy reproducible 'Rootless GPU Serving Container (Docker / containerd / CRI-O)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-07 | Intelligence-per-Watt Telemetry via NVML / Power Sampling | Expert | 65 min | PRO ($9/mo) | Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F): Design, verify, and deploy reproducible 'Intelligence-per-Watt Telemetry via NVML / Power Sampling' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-08 | Quantization-Induced Safety & Hallucination Regression Tests | Expert | 70 min | PRO ($9/mo) | Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F): Design, verify, and deploy reproducible 'Quantization-Induced Safety & Hallucination Regression Tests' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-09 | Dedicated Inference Endpoints Autoscaling Blueprint | Expert | 75 min | PRO ($9/mo) | Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F): Design, verify, and deploy reproducible 'Dedicated Inference Endpoints Autoscaling Blueprint' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
| LAB-PRO-05-10 | Capstone: Hardware-Efficient Serving Playbook & Optimum Docs | Capstone & Resources (10%) | 45 min | PRO ($9/mo) | Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: Hardware-Efficient Serving Playbook & Optimum Docs' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
Living Semantics & Disambiguation Table
| Term | Domain | Operational Definition |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Executable Lab Kit (Bash / Python / OCI — kept in canonical LTR code format below)
SÉRIE PRATIQUE PRO HUGGING FACE · 10 TRAVAUX PRATIQUES GPU / ZEROGPU
Série pratique PRO 05 : Exploiter chaque watt — quantification, Optimum et inférence basse latence
Cette série PRO dédiée exploite pleinement les capacités Hugging Face PRO (priorité ZeroGPU 8×, fournisseurs d’inférence, jeux de données privés et Spaces Dev Mode) sur dix exercices reproductibles, avec liaison explicite au NVIDIA Container Toolkit uniquement pour les charges GPU.
Rédigé par Imad Soltani (auteur humain, seule autorité de publication) avec Antigravity (Google DeepMind, co-auteur non humain).
1. Architecture de la série, matériel et lien avec Hugging Face Learn
7. Auto-évaluation de compréhension
Pourquoi cette série impose-t-elle un conteneur OCI multi-étapes non-root et un script Debian idempotent ?
La construction multi-étapes élimine les compilateurs de l’image finale, l’exécution sans privilèges root réduit la surface d’impact en cas d’outil compromis, et l’idempotence garantit des exécutions reproductibles sous Debian 12/13 sans dérive de configuration.
Comment la répartition 30/30/30/10 prépare-t-elle au déploiement réel ?
Les travaux 01 à 03 posent les bases reproductibles (Débutant), 04 à 06 couvrent l’adaptation, l’évaluation appariée et l’empaquetage OCI (Praticien), 07 à 09 traitent la performance, la sécurité et la conformité (Expert), et le travail 10 consolide la synthèse et les sources officielles.
Progression complète en 10 laboratoires (30 % Débutant · 30 % Praticien · 30 % Expert · 10 % Synthèse)
| ID | Module de laboratoire dédié | Niveau | Durée | Coût / Palier | Résultat attendu et capacité |
|---|
LAB-PRO-05-01 | Module technique : Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | Débutant | 35 min | PRO (9 $/mois) | Livrable vérifié : Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F) : Design, verify, and deploy reproducible ’Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-02 | Module technique : KV-Cache Sizing et PagedAttention Arithmetic | Débutant | 40 min | PRO (9 $/mois) | Livrable vérifié : Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F) : Design, verify, and deploy reproducible ’KV-Cache Sizing et PagedAttention Arithmetic’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-03 | Module technique : Optimum Export et Kernel Fusion Verification | Débutant | 45 min | PRO (9 $/mois) | Livrable vérifié : Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F) : Design, verify, and deploy reproducible ’Optimum Export et Kernel Fusion Verification’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-04 | Module technique : Calibration-Dataset Sensitivity in Post-Training Quantization | Praticien | 50 min | PRO (9 $/mois) | Livrable vérifié : Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F) : Design, verify, and deploy reproducible ’Calibration-Dataset Sensitivity in Post-Training Quantization’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-05 | Module technique : Continuous Batching et Speculative Decoding Benchmarks | Praticien | 55 min | PRO (9 $/mois) | Livrable vérifié : Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F) : Design, verify, and deploy reproducible ’Continuous Batching et Speculative Decoding Benchmarks’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-06 | Module technique : Rootless GPU Serving Container (Docker / containerd / CRI-O) | Praticien | 60 min | PRO (9 $/mois) | Livrable vérifié : Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F) : Design, verify, and deploy reproducible ’Rootless GPU Serving Container (Docker / containerd / CRI-O)’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-07 | Module technique : Intelligence-per-Watt Telemetry via NVML / Power Sampling | Expert | 65 min | PRO (9 $/mois) | Livrable vérifié : Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F) : Design, verify, and deploy reproducible ’Intelligence-per-Watt Telemetry via NVML / Power Sampling’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-08 | Module technique : Quantization-Induced Safety et Hallucination Regression Tests | Expert | 70 min | PRO (9 $/mois) | Livrable vérifié : Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F) : Design, verify, and deploy reproducible ’Quantization-Induced Safety et Hallucination Regression Tests’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-09 | Module technique : Dedicated Inference Endpoints Autoscaling Blueprint | Expert | 75 min | PRO (9 $/mois) | Livrable vérifié : Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F) : Design, verify, and deploy reproducible ’Dedicated Inference Endpoints Autoscaling Blueprint’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-10 | Module technique : Capstone : Hardware-Efficient Serving Playbook et Optimum Docs | Synthèse | 45 min | PRO (9 $/mois) | Livrable vérifié : Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F) : Design, verify, and deploy reproducible ’Capstone : Hardware-Efficient Serving Playbook et Optimum Docs’ workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
Table de sémantique vivante et désambiguïsation
| Terme | Domaine | Définition opérationnelle |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | Définition technique : Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | Définition technique : Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | Définition technique : Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Définition technique : Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Définition technique : Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Définition technique : Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Définition technique : Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Kit exécutable de laboratoire (Bash / Python / OCI — conservé en format de code canonique LTR ci-dessous)
HUGGING FACE PRO 实战系列 · 10 个 GPU / ZEROGPU 实验
PRO 实战系列 05:压榨每瓦算力——量化、Optimum 与低延迟推理服务
本独立 PRO 专题系列充分利用 Hugging Face PRO 权益(8× ZeroGPU 优先配额、Inference Providers 路由、私有数据集与 Spaces Dev Mode),将 Debian 12/13 脚本与多阶段非 root OCI 容器结合,仅在 GPU 负载中按需绑定 NVIDIA Container Toolkit。
由 Imad Soltani(人类作者,唯一生产发布授权人)与 Antigravity(Google DeepMind,非人类合著者)共同编写。
1. 系列架构、硬件要求与 Hugging Face 官方课程映射
7. 自测理解关卡
为何本实验系列同时要求多阶段非 root OCI 容器与幂等 Debian 脚本?
多阶段构建将编译工具链剥离出运行层,非 root 用户限制依赖或工具越权时的爆炸半径,而幂等脚本确保在任意 Debian 12/13 主机上重复运行都能得到一致结果。
30/30/30/10 进阶结构如何支撑真实系统落地?
实验 01–03 建立可复现基线(入门),04–06 完成任务适配、成对评测与容器封装(实践),07–09 强化性能、安全边界与合规披露(专家),实验 10 汇总成果并索引权威文档。
完整 10 阶实验路线(30% 入门 · 30% 实践 · 30% 专家 · 10% 综合封顶)
| 编号 | 专题实验模块 | 等级 | 时长 | 成本 / 层级 | 预期成果与工程能力 |
|---|
LAB-PRO-05-01 | 专题模块:Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | 入门 | 35 分钟 | PRO(9美元/月) | 验证成果:Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F): Design, verify, and deploy reproducible 'Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-02 | 专题模块:KV-Cache Sizing & PagedAttention Arithmetic | 入门 | 40 分钟 | PRO(9美元/月) | 验证成果:Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F): Design, verify, and deploy reproducible 'KV-Cache Sizing & PagedAttention Arithmetic' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-03 | 专题模块:Optimum Export & Kernel Fusion Verification | 入门 | 45 分钟 | PRO(9美元/月) | 验证成果:Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F): Design, verify, and deploy reproducible 'Optimum Export & Kernel Fusion Verification' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-04 | 专题模块:Calibration-Dataset Sensitivity in Post-Training Quantization | 实践 | 50 分钟 | PRO(9美元/月) | 验证成果:Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F): Design, verify, and deploy reproducible 'Calibration-Dataset Sensitivity in Post-Training Quantization' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-05 | 专题模块:Continuous Batching & Speculative Decoding Benchmarks | 实践 | 55 分钟 | PRO(9美元/月) | 验证成果:Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F): Design, verify, and deploy reproducible 'Continuous Batching & Speculative Decoding Benchmarks' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-06 | 专题模块:Rootless GPU Serving Container (Docker / containerd / CRI-O) | 实践 | 60 分钟 | PRO(9美元/月) | 验证成果:Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F): Design, verify, and deploy reproducible 'Rootless GPU Serving Container (Docker / containerd / CRI-O)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-07 | 专题模块:Intelligence-per-Watt Telemetry via NVML / Power Sampling | 专家 | 65 分钟 | PRO(9美元/月) | 验证成果:Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F): Design, verify, and deploy reproducible 'Intelligence-per-Watt Telemetry via NVML / Power Sampling' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-08 | 专题模块:Quantization-Induced Safety & Hallucination Regression Tests | 专家 | 70 分钟 | PRO(9美元/月) | 验证成果:Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F): Design, verify, and deploy reproducible 'Quantization-Induced Safety & Hallucination Regression Tests' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-09 | 专题模块:Dedicated Inference Endpoints Autoscaling Blueprint | 专家 | 75 分钟 | PRO(9美元/月) | 验证成果:Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F): Design, verify, and deploy reproducible 'Dedicated Inference Endpoints Autoscaling Blueprint' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-10 | 专题模块:Capstone: Hardware-Efficient Serving Playbook & Optimum Docs | 综合封顶 | 45 分钟 | PRO(9美元/月) | 验证成果:Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: Hardware-Efficient Serving Playbook & Optimum Docs' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
动态语义与术语消歧表
| 术语 | 所属领域 | 工程操作定义 |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | 技术定义:Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | 技术定义:Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | 技术定义:Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | 技术定义:Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | 技术定义:Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | 技术定义:Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | 技术定义:Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
可执行实验代码套件(Bash / Python / OCI — 下方保持规范 LTR 代码格式)
HUGGING FACE PRO 實作系列 · 10 個 GPU / ZEROGPU 實驗
PRO 實作系列 05:壓榨每瓦算力——量化、Optimum 與低延遲推理服務
本獨立 PRO 專題系列充分利用 Hugging Face PRO 權益(8× ZeroGPU 優先配額、Inference Providers 路由、私有資料集與 Spaces Dev Mode),結合 Debian 12/13 腳本與多階段非 root OCI 容器,僅於 GPU 負載按需繫結 NVIDIA Container Toolkit。
由 Imad Soltani(人類作者,唯一生產發布授權人)與 Antigravity(Google DeepMind,非人類合著者)共同撰寫。
1. 系列架構、硬體需求與 Hugging Face 官方課程對應
7. 自我檢測理解關卡
為何本實驗系列同時要求多階段非 root OCI 容器與冪等 Debian 腳本?
多階段建置將編譯工具鏈自執行層剝離,非 root 使用者能降低相依套件或工具越權時的影響範圍,而冪等腳本確保在任何 Debian 12/13 主機重複執行都能獲得一致結果。
30/30/30/10 進階結構如何支撐真實系統落地?
實驗 01–03 建立可重現基線(入門),04–06 完成任務適配、成對評測與容器封裝(實踐),07–09 強化效能、安全邊界與合規揭露(專家),實驗 10 彙整成果並索引權威文件。
完整 10 階實作進程(30% 入門 · 30% 實務 · 30% 專家 · 10% 總結專題)
| 編號 | 專題實作模組 | 級別 | 時長 | 費用 / 層級 | 預期成果與工程能力 |
|---|
LAB-PRO-05-01 | 專題模組:Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | 入門 | 35 分鐘 | PRO(9美元/月) | 驗證成果:Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F): Design, verify, and deploy reproducible 'Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-02 | 專題模組:KV-Cache Sizing & PagedAttention Arithmetic | 入門 | 40 分鐘 | PRO(9美元/月) | 驗證成果:Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F): Design, verify, and deploy reproducible 'KV-Cache Sizing & PagedAttention Arithmetic' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-03 | 專題模組:Optimum Export & Kernel Fusion Verification | 入門 | 45 分鐘 | PRO(9美元/月) | 驗證成果:Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F): Design, verify, and deploy reproducible 'Optimum Export & Kernel Fusion Verification' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-04 | 專題模組:Calibration-Dataset Sensitivity in Post-Training Quantization | 實務 | 50 分鐘 | PRO(9美元/月) | 驗證成果:Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F): Design, verify, and deploy reproducible 'Calibration-Dataset Sensitivity in Post-Training Quantization' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-05 | 專題模組:Continuous Batching & Speculative Decoding Benchmarks | 實務 | 55 分鐘 | PRO(9美元/月) | 驗證成果:Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F): Design, verify, and deploy reproducible 'Continuous Batching & Speculative Decoding Benchmarks' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-06 | 專題模組:Rootless GPU Serving Container (Docker / containerd / CRI-O) | 實務 | 60 分鐘 | PRO(9美元/月) | 驗證成果:Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F): Design, verify, and deploy reproducible 'Rootless GPU Serving Container (Docker / containerd / CRI-O)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-07 | 專題模組:Intelligence-per-Watt Telemetry via NVML / Power Sampling | 專家 | 65 分鐘 | PRO(9美元/月) | 驗證成果:Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F): Design, verify, and deploy reproducible 'Intelligence-per-Watt Telemetry via NVML / Power Sampling' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-08 | 專題模組:Quantization-Induced Safety & Hallucination Regression Tests | 專家 | 70 分鐘 | PRO(9美元/月) | 驗證成果:Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F): Design, verify, and deploy reproducible 'Quantization-Induced Safety & Hallucination Regression Tests' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-09 | 專題模組:Dedicated Inference Endpoints Autoscaling Blueprint | 專家 | 75 分鐘 | PRO(9美元/月) | 驗證成果:Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F): Design, verify, and deploy reproducible 'Dedicated Inference Endpoints Autoscaling Blueprint' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-10 | 專題模組:Capstone: Hardware-Efficient Serving Playbook & Optimum Docs | 總結專題 | 45 分鐘 | PRO(9美元/月) | 驗證成果:Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: Hardware-Efficient Serving Playbook & Optimum Docs' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
動態語意與術語消歧對照表
| 術語 | 領域 | 工程操作定義 |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | 技術定義:Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | 技術定義:Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | 技術定義:Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | 技術定義:Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | 技術定義:Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | 技術定義:Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | 技術定義:Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
可執行實作程式碼套件(Bash / Python / OCI — 下方維持標準 LTR 程式碼格式)
SERIA LABORATORYJNA PRO HUGGING FACE · 10 LABORATORIÓW GPU / ZEROGPU
Seria laboratoryjna PRO 05: Maksimum wydajności z wata — kwantyzacja, Optimum i serwowanie niskolatencyjne
Ta dedykowana seria PRO wykorzystuje możliwości planu Hugging Face PRO (priorytet 8× ZeroGPU, routing Inference Providers, prywatne zbiory danych i Spaces Dev Mode) w dziesięciu ćwiczeniach z obsługą NVIDIA Container Toolkit wyłącznie dla zadań GPU.
Autor: Imad Soltani (autor ludzki, wyłączny decydent wydań produkcyjnych) we współpracy z Antigravity (Google DeepMind, współautor nieludzki).
1. Architektura serii, wymagania sprzętowe i powiązanie z Hugging Face Learn
7. Pytania kontrolne (samosprawdzenie)
Dlaczego ta seria wymaga wieloetapowego kontenera OCI bez uprawnień root oraz idempotentnego skryptu Debian?
Budowa wieloetapowa usuwa kompilatory z warstwy uruchomieniowej, brak uprawnień root ogranicza skutki błędów zależności, a idempotentność zapewnia powtarzalne środowisko na każdym hoście Debian 12/13.
W jaki sposób podział 30/30/30/10 buduje gotowość produkcyjną?
Laboratoria 01–03 ustanawiają powtarzalną bazę (Początkujący), 04–06 obejmują adaptację, ewaluację parowaną i pakowanie OCI (Praktyk), 07–09 wzmacniają wydajność, bezpieczeństwo i zgodność (Ekspert), a laboratorium 10 spina artefakty i źródła.
Pełna ścieżka 10 laboratoriów (30% Podstawowy · 30% Praktyk · 30% Ekspert · 10% Zwieńczenie)
| ID | Dedykowany moduł laboratoryjny | Poziom | Czas | Koszt / Plan | Oczekiwany rezultat i kompetencja |
|---|
LAB-PRO-05-01 | Moduł techniczny: Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | Podstawowy | 35 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F): Design, verify, and deploy reproducible 'Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-02 | Moduł techniczny: KV-Cache Sizing & PagedAttention Arithmetic | Podstawowy | 40 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F): Design, verify, and deploy reproducible 'KV-Cache Sizing & PagedAttention Arithmetic' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-03 | Moduł techniczny: Optimum Export & Kernel Fusion Verification | Podstawowy | 45 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F): Design, verify, and deploy reproducible 'Optimum Export & Kernel Fusion Verification' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-04 | Moduł techniczny: Calibration-Dataset Sensitivity in Post-Training Quantization | Praktyk | 50 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F): Design, verify, and deploy reproducible 'Calibration-Dataset Sensitivity in Post-Training Quantization' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-05 | Moduł techniczny: Continuous Batching & Speculative Decoding Benchmarks | Praktyk | 55 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F): Design, verify, and deploy reproducible 'Continuous Batching & Speculative Decoding Benchmarks' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-06 | Moduł techniczny: Rootless GPU Serving Container (Docker / containerd / CRI-O) | Praktyk | 60 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F): Design, verify, and deploy reproducible 'Rootless GPU Serving Container (Docker / containerd / CRI-O)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-07 | Moduł techniczny: Intelligence-per-Watt Telemetry via NVML / Power Sampling | Ekspert | 65 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F): Design, verify, and deploy reproducible 'Intelligence-per-Watt Telemetry via NVML / Power Sampling' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-08 | Moduł techniczny: Quantization-Induced Safety & Hallucination Regression Tests | Ekspert | 70 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F): Design, verify, and deploy reproducible 'Quantization-Induced Safety & Hallucination Regression Tests' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-09 | Moduł techniczny: Dedicated Inference Endpoints Autoscaling Blueprint | Ekspert | 75 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F): Design, verify, and deploy reproducible 'Dedicated Inference Endpoints Autoscaling Blueprint' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-10 | Moduł techniczny: Capstone: Hardware-Efficient Serving Playbook & Optimum Docs | Zwieńczenie | 45 min | PRO (9 USD/mies.) | Zweryfikowany rezultat: Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: Hardware-Efficient Serving Playbook & Optimum Docs' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
Tabela żywej semantyki i ujednoznaczniania
| Termin | Domena | Definicja operacyjna |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | Definicja techniczna: Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | Definicja techniczna: Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | Definicja techniczna: Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | Definicja techniczna: Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | Definicja techniczna: Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | Definicja techniczna: Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | Definicja techniczna: Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
Wykonywalny zestaw laboratoryjny (Bash / Python / OCI — poniżej w kanonicznym formacie LTR)
سلسلة مختبرات Hugging Face PRO · 10 مختبرات GPU / ZeroGPU
سلسلة المختبرات الاحترافية 05: استثمار كل واط — التكميم وأدوات Optimum وخدمة الاستدلال منخفضة الكمون
تستثمر هذه السلسلة الاحترافية (PRO) مزايا اشتراك Hugging Face PRO (أولوية 8× ZeroGPU ومزوّدي الاستدلال ومجموعات البيانات الخاصة ووضع التطوير) عبر عشرة مختبرات مع ربط NVIDIA Container Toolkit حصرًا عند الحاجة لتسريع البطاقات الرسومية.
بقلم عماد سلطاني (Imad Soltani، المؤلف البشري وصاحب الصلاحية الحصرية لإعلان الإصدارات الإنتاجية) بمشاركة Antigravity (Google DeepMind) كمؤلف غير بشري.
1. بنية السلسلة والعتاد وربطها بمنصة Hugging Face Learn
7. اختبار الفهم الذاتي
لماذا تفرض هذه السلسلة حاوية OCI متعددة المراحل دون صلاحيات root مع نص تهيئة Debian قابل لإعادة التشغيل؟
يزيل البناء متعدد المراحل أدوات الترجمة من طبقة التشغيل، ويحد التشغيل دون صلاحيات الجذر من أثر أي خلل أمني، وتضمن القابلية لإعادة التشغيل نتائج متطابقة عبر أي بيئة Debian 12/13.
كيف يرتبط تقسيم 30/30/30/10 بالجاهزية الإنتاجية؟
ترسي المختبرات 01–03 الأساس الحتمي (مبتدئ)، وتغطي 04–06 التكييف والتقييم المقارن وحزم OCI (ممارس)، وتعالج 07–09 الأداء والأمن والحوكمة (خبير)، ويجمع المختبر 10 النتائج والمصادر الرسمية.
مسار المختبرات العشرة الكامل (30% مبتدئ · 30% ممارس · 30% خبير · 10% مشروع ختامي)
| الرمز | وحدة المختبر المتخصصة | المستوى | المدة | التكلفة / الفئة | النتيجة المتوقعة والقدرة الهندسية |
|---|
LAB-PRO-05-01 | الوحدة التطبيقية: Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ) | مبتدئ | 35 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Compare memory-bandwidth ceilings across BF16, FP8, and INT4 checkpoints Reader capability (10F): Design, verify, and deploy reproducible 'Weight-Only vs Activation Quantization (FP8 / AWQ / GPTQ)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-02 | الوحدة التطبيقية: KV-Cache Sizing & PagedAttention Arithmetic | مبتدئ | 40 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Compute exact concurrent-user capacity given GPU VRAM and GQA head counts Reader capability (10F): Design, verify, and deploy reproducible 'KV-Cache Sizing & PagedAttention Arithmetic' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-03 | الوحدة التطبيقية: Optimum Export & Kernel Fusion Verification | مبتدئ | 45 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Export SafeTensors checkpoints to optimized inference graphs with parity checks Reader capability (10F): Design, verify, and deploy reproducible 'Optimum Export & Kernel Fusion Verification' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-04 | الوحدة التطبيقية: Calibration-Dataset Sensitivity in Post-Training Quantization | ممارس | 50 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Measure perplexity and downstream accuracy drift across calibration sets Reader capability (10F): Design, verify, and deploy reproducible 'Calibration-Dataset Sensitivity in Post-Training Quantization' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-05 | الوحدة التطبيقية: Continuous Batching & Speculative Decoding Benchmarks | ممارس | 55 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Profile p50/p95/p99 latency and tokens/sec/watt under synthetic traffic Reader capability (10F): Design, verify, and deploy reproducible 'Continuous Batching & Speculative Decoding Benchmarks' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-06 | الوحدة التطبيقية: Rootless GPU Serving Container (Docker / containerd / CRI-O) | ممارس | 60 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Package an optimized serving runtime with NVIDIA Container Toolkit bindings Reader capability (10F): Design, verify, and deploy reproducible 'Rootless GPU Serving Container (Docker / containerd / CRI-O)' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-07 | الوحدة التطبيقية: Intelligence-per-Watt Telemetry via NVML / Power Sampling | خبير | 65 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Calculate verified tasks solved per joule across model sizes and precisions Reader capability (10F): Design, verify, and deploy reproducible 'Intelligence-per-Watt Telemetry via NVML / Power Sampling' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-08 | الوحدة التطبيقية: Quantization-Induced Safety & Hallucination Regression Tests | خبير | 70 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Verify INT4/FP8 quantization does not weaken refusal boundaries or factual precision Reader capability (10F): Design, verify, and deploy reproducible 'Quantization-Induced Safety & Hallucination Regression Tests' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-09 | الوحدة التطبيقية: Dedicated Inference Endpoints Autoscaling Blueprint | خبير | 75 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Design scale-to-zero and min-replica SLO policies for bursty workloads Reader capability (10F): Design, verify, and deploy reproducible 'Dedicated Inference Endpoints Autoscaling Blueprint' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
LAB-PRO-05-10 | الوحدة التطبيقية: Capstone: Hardware-Efficient Serving Playbook & Optimum Docs | مشروع ختامي | 45 دقيقة | PRO (9 دولار/شهر) | المخرج المتحقق: Consolidate VRAM calculators, energy metrics, and Optimum/TGI documentation Reader capability (10F): Design, verify, and deploy reproducible 'Capstone: Hardware-Efficient Serving Playbook & Optimum Docs' workflows grounded in https://huggingface.co/learn/llm-course/chapter2/1 and https://huggingface.co/docs/optimum/index. |
جدول الدلالات الحية وإزالة الالتباس
| المصطلح | المجال | التعريف التشغيلي |
|---|
| Activation-Aware Weight Quantization (AWQ) | Quantization | توصيف معياري: Salience-preserving 4-bit quantization scaling critical weight channels to minimize accuracy loss without retraining. |
| Intelligence per Watt | Efficiency | توصيف معياري: Systems metric measuring verified benchmark task completions per watt-hour of accelerator and host power. |
| Speculative Decoding | Serving | توصيف معياري: Drafting multiple candidate tokens with a tiny model and verifying them in one parallel target-model forward pass. |
| Hugging Face Hub Token (`HF_TOKEN`) | Security | توصيف معياري: Fine-grained bearer token authorizing read/write access to gated weights, private datasets, and Inference Providers without hardcoding secrets. |
| OCI Multi-Stage Non-Root Image | Infrastructure | توصيف معياري: Open Container Initiative (`opencontainers.org`) image discarding build compilers and running strictly under unprivileged UID `10001`. |
| 30 / 30 / 30 / 10 Mastery Split | Pedagogy | توصيف معياري: Curriculum pacing allocating 30% Beginner, 30% Practitioner, 30% Expert labs, plus 10% Capstone synthesis and verified HF Learn/Docs URLs. |
| Idempotent Debian Setup | Reproducibility | توصيف معياري: Setup discipline allowing `setup.sh` to re-run safely on Debian 12/13 with explicit destructive warnings (`--reset`) and isolated `.venv`. |
حزمة المختبر التنفيذية (Bash / Python / OCI — محفوظة أدناه بصيغة شيفرة قياسية من اليسار إلى اليمين)
Debian 12/13 Commented Idempotent Setup & Domain Python Runner (10C)
setup.sh (Debian 12/13 Bash)
#!/usr/bin/env bash
# ==============================================================================
# SolarisK Lab Series Setup — LAB-PRO-05 (series_05_pro-quantization-optimum-serving)
# Target OS: Latest stable Debian Linux (Debian 12 Bookworm / 13 Trixie)
# Idempotent setup with inline comments & explicit destructive-reset warning.
# ==============================================================================
set -euo pipefail
# Isolated virtual environment path so Debian system Python stays untouched
LAB_VENV="${HOME}/.venvs/solarisk-lab-pro-05"
# Warn explicitly before destructive environment reset (--reset)
if [[ "${1:-}" == "--reset" ]]; then
echo "[WARNING] Destructive reset: deleting ${LAB_VENV} in 5s (Ctrl+C to cancel)..."
sleep 5
rm -rf "${LAB_VENV}"
fi
# Confirm Debian python3 & venv tooling exist before creating environment
if ! command -v python3 >/dev/null 2>&1; then
echo "[ERROR] Missing python3. Install on Debian: sudo apt-get update && sudo apt-get install -y python3 python3-venv python3-pip"
exit 1
fi
# Verify NVIDIA driver & Container Toolkit (required ONLY for local GPU execution)
if command -v nvidia-smi >/dev/null 2>&1; then
nvidia-smi --query-gpu=name,memory.total --format=csv,noheader
else
echo '[INFO] No local NVIDIA GPU detected — use Hugging Face PRO ZeroGPU Spaces or Inference Providers.'
fi
# Idempotently create virtual environment
if [[ ! -d "${LAB_VENV}" ]]; then
echo "[SETUP] Creating Debian virtual environment at ${LAB_VENV}..."
python3 -m venv "${LAB_VENV}"
fi
# Install series-specific packages cleanly inside the isolated virtualenv
"${LAB_VENV}/bin/pip" install --quiet --upgrade pip
"${LAB_VENV}/bin/pip" install --quiet optimum transformers accelerate huggingface_hub
echo "[READY] Activate: source ${LAB_VENV}/bin/activate"
echo "[READY] Run self-test: ${LAB_VENV}/bin/python3 run_lab.py --check"
run_lab.py (Executable Series-Specific Python Kernel)
#!/usr/bin/env python3
"""
SolarisK Executable Lab Runner — LAB-PRO-05: PRO Lab Series 05: Squeezing Every Watt — Quantization, Optimum & Low-Latency Serving
Hugging Face Learn: https://huggingface.co/learn/llm-course/chapter2/1
Hugging Face Docs: https://huggingface.co/docs/optimum/index
"""
import argparse, json, os, platform
from datetime import datetime, timezone
def run_domain_demo() -> dict:
"""Series-specific reproducible verification kernel (runs offline or online)."""
out = {"series_id": "LAB-PRO-05", "tier": "PRO", "uses_gpu": True}
try:
# Domain kernel preview (safe offline fallback if optional weights/packages not yet pulled)
exec_ns = {}
code = "import json\nparams_b = 8.0\nprint(json.dumps({'model_params_B': params_b, 'bf16_vram_gb': params_b*2.0, 'fp8_vram_gb': params_b*1.0, 'int4_vram_gb': params_b*0.55}))"
exec(compile(code, "<LAB-PRO-05>", "exec"), exec_ns)
out["kernel_status"] = "EXECUTED"
except Exception as exc:
out["kernel_status"] = "DEFERRED_INSTALL"
out["hint"] = f"Run ./setup.sh first to install [optimum transformers accelerate huggingface_hub]: {exc}"
return out
def main() -> None:
parser = argparse.ArgumentParser(description="SolarisK LAB-PRO-05 Reproducible Runner")
parser.add_argument("--check", action="store_true", help="Verify Debian/OCI runtime & run domain kernel")
args = parser.parse_args()
report = {
"series_id": "LAB-PRO-05",
"timestamp_utc": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"python": platform.python_version(),
"os": platform.platform(),
"hf_token_present": bool(os.environ.get("HF_TOKEN")),
"hf_learn": "https://huggingface.co/learn/llm-course/chapter2/1",
"hf_docs": "https://huggingface.co/docs/optimum/index",
"domain_check": run_domain_demo(),
}
print(json.dumps(report, indent=2, ensure_ascii=False))
if __name__ == "__main__":
main()
OCI Multi-Stage Non-Root Container & Docker / containerd / CRI-O Runbook (10D)
Containerfile (opencontainers.org)
# syntax=docker/dockerfile:1
# OCI-compliant multi-stage non-root Containerfile for LAB-PRO-05 (opencontainers.org)
FROM python:3.11-slim-bookworm AS builder
WORKDIR /build
RUN python3 -m venv /opt/venv && /opt/venv/bin/pip install --no-cache-dir --upgrade pip optimum transformers accelerate huggingface_hub
FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04 AS runtime
LABEL org.opencontainers.image.title="SolarisK LAB-PRO-05" \
org.opencontainers.image.source="https://github.com/ximad/solarisk/tree/main/lab/v126.0/pro/series_05_pro-quantization-optimum-serving" \
org.opencontainers.image.authors="Imad Soltani <bsdimad@gmail.com>"
ENV NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=compute,utility
RUN groupadd -g 10001 solarisk && useradd -u 10001 -g 10001 -m -s /usr/sbin/nologin solarisk
COPY --from=builder /opt/venv /opt/venv
WORKDIR /app
COPY --chown=10001:10001 run_lab.py /app/run_lab.py
ENV PATH="/opt/venv/bin:$PATH" HF_HOME="/tmp/hf_cache" PYTHONDONTWRITEBYTECODE=1
USER 10001:10001
ENTRYPOINT ["python3", "/app/run_lab.py"]
CMD ["--check"]
Docker, containerd (nerdctl), and CRI-O Commands
# GPU lab: NVIDIA Container Toolkit (nvidia-ctk) is required ONLY for local NVIDIA GPU execution.
# 1. Docker (OCI-compliant multi-stage non-root image)
docker build -f Containerfile -t solarisk/lab-pro-05:latest .
docker run --rm --gpus all --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-pro-05:latest
# 2. containerd via nerdctl (rootless OCI workflow)
nerdctl build -f Containerfile -t solarisk/lab-pro-05:latest .
nerdctl run --rm --gpus all --read-only --tmpfs /tmp -e HF_TOKEN="$HF_TOKEN" solarisk/lab-pro-05:latest
# 3. CRI-O / Podman (Kubernetes CRI-O node verification via crictl / podman)
podman build -f Containerfile -t localhost/solarisk/lab-pro-05:latest .
podman run --rm --device nvidia.com/gpu=all --userns=keep-id -e HF_TOKEN="$HF_TOKEN" localhost/solarisk/lab-pro-05:latest
# On CRI-O cluster nodes, pull the OCI image and inspect pod sandbox via: crictl images | grep lab-pro-05
Troubleshooting: Two Most Common Errors & Deterministic Fixes (10E)
Error 1: CUDA / ZeroGPU Out-of-Memory (OOM) or Driver MismatchReduce micro-batch size, enable gradient checkpointing or 4-bit NF4 quantization, verify `nvidia-smi` on Debian 12/13, and confirm `nvidia-ctk runtime configure` before launching Docker, containerd, or CRI-O.
Error 2: Gated Hub Model 401/403 or Venv ShadowingRun `./setup.sh --reset` to rebuild the isolated `.venv`, export a fine-grained `HF_TOKEN` with read permission, and accept the upstream Model Card license on huggingface.co.
No comments:
Post a Comment