Lecțiile acestui traseu sunt publicate deocamdată doar în engleză, așa că lecția de mai jos apare în engleză. Restul — module, quiz și materiale — funcționează la fel.
Capstone: Serve a Small Model Two Ways and Write the Report
Vei putea să:
You can download an open-weight model, serve it with two different stacks or precisions on your own machine, benchmark both with a fixed workload, check that quality survived, and turn the numbers into a one-page cost-and-latency report with a recommendation and its caveats.
The capstone: one model, two configurations, one honest page
Everything in this track converges on a short report that a decision-maker can read in five minutes and an engineer could reproduce in an afternoon. This lesson is the procedure for producing it on hardware you already own, with no account and no paid tool. The absolute numbers matter less than the discipline — your laptop is not a production server: fixed workload, stated metrics, quality check, cost derivation, caveats.
Choosing the model and the two configurations
Pick a small open-weight instruction-tuned model, in the 0.5B–1.5B range, in GGUF format from Hugging Face; many are published by the model's own authors and download without a login. Small is deliberate: it fits in under about a gigabyte at 4-bit, runs at usable speed on a CPU, and allows several benchmark runs within the time box.
Then choose a pair of configurations that differ in one thing you have studied:
- Precision: the same model at Q8_0 and at Q4_K_M in llama.cpp. This isolates module 2's trade-off — bytes per weight against quality.
- Runtime: PyTorch Transformers (16-bit or whatever your machine supports) against llama.cpp. This isolates kernel and memory-layout differences from module 5.
- If you have a CUDA GPU with enough memory, vLLM against llama.cpp is the production-relevant pair; the vLLM quickstart gets a server up in minutes, but it is optional, not required.
The llama.cpp server README shows how to start an OpenAI-compatible HTTP endpoint with a given GGUF and context size; the llama-bench README documents the tool that measures prompt-processing and generation speed for one model under several settings and prints a table. The Hugging Face guide "Optimizing LLMs for Speed and Memory" is the reference for the Transformers side: loading in lower precision, enabling the fast attention path, and understanding the KV cache that the generate loop keeps.
The procedure
- Fix the workload. Write 30 prompts in a text file: ten short questions, ten that include a 400–800-word passage to summarise or answer from, ten that ask for structured output (a list, JSON, a table). Set max output tokens to 150 for all. Same file for every run.
- Warm up and run. Discard the first three requests of each run; models and kernels are slower while memory is first touched. Then run all 30 prompts at concurrency 1, recording per request: time to first token, total time, prompt tokens, output tokens. Repeat at concurrency 4 using the server's HTTP endpoint and a small script (or a load tool) that fires four requests at once and keeps four in flight.
- Compute the metrics from module 6. Per configuration and concurrency: median and p99 TTFT, median and p99 end-to-end latency, per-request decode tokens/s (output tokens ÷ (total − TTFT)), and aggregate output tokens/s over the whole run. Percentiles from all 27 kept samples, not averages of averages.
- Check quality. Save every output. For ten prompts (pick before looking at results), place the two configurations' answers side by side and mark each: equivalent, slightly worse, clearly worse. Count. If one configuration produces broken JSON or repetition loops the others do not, that is a finding more important than any speed number.
- Derive cost. Pick an hourly price you can defend — a public cloud listing for a machine like yours, or an amortised estimate for your own hardware — and state it. Cost per million output tokens = price ÷ (aggregate output tokens/s × 3,600). Compute it at concurrency 4, which is the closer approximation to a server, and show the arithmetic.
- Write the page. One results table (rows: configuration × concurrency; columns: the metrics above and cost), one quality tally, one paragraph of recommendation, and two or three caveats.
What to expect, and what to be suspicious of
Expect the 4-bit model to decode faster than the 8-bit one by somewhat less than 2×: Q4_K_M actually stores about 4.9 bits per weight against Q8_0's 8.5 (a ratio near 1.75×), and the KV cache and per-step overheads do not shrink; module 1 predicted this. Expect llama.cpp on CPU to beat unoptimised Transformers by a large margin that is mostly kernel quality. Expect concurrency 4 to raise aggregate tokens/s by less than 4× on a laptop, since memory bandwidth saturates quickly — and note whether per-request latency at concurrency 4 would still be acceptable to a user.
Be suspicious if TTFT is near zero on long prompts (prefix caching may be on — state it or disable it), if tokens/s is identical across configurations (you are probably measuring your script, not the model), or if the quality tally is perfect (check that max tokens did not truncate everything before the differences appear).
Writing the caveats like an engineer
The recommendation is where most reports lose credibility, in both directions. "Q4 is 1.7× faster and quality was equivalent on 10 of 10 prompts, so ship Q4" is defensible if the table backs it. Add the caveats a reader would otherwise raise: a laptop's bandwidth and thermal behaviour are nothing like a server GPU; ten prompts is a smoke test, not an evaluation; concurrency 4 is not concurrency 64; a 1B model's sensitivity to quantization is not a 70B model's. Naming the limits of your evidence makes the claims you do make believable.
What is still unsettled
There is no agreed standard for local inference benchmarks: every tool defines prompt-processing and generation speed slightly differently, and GGUF quantization types evolve. One more reason to publish your exact commands and versions, so the next person can reproduce rather than trust.
What to remember
- Change one variable between configurations; keep the model, workload, max tokens and hardware fixed.
- Warm up, record per-request timings, and report percentiles from the full sample at each concurrency.
- A side-by-side quality tally on a pre-chosen subset is mandatory; speed without quality is not a result.
- Show the cost arithmetic and the assumed price, then write the caveats before the reader does.
Materiale selectate
1.6hMunca de profunzime se întâmplă aici — lecția este briefingul tău.
În direct pe aiqbench
Subiectul acestei lecții în restul site-ului, astăzi.
În știri, ultimele 30 de zile
- GPU decoder keeps pace with a superconducting qubit clock on a continuous stream, with NVIDIA NVQLink interconnectAlice & Bob ·
- DeepSeek Opens Source Production-Level Ascend Inference Code36Kr ·
- NVIDIA and Cerebras Partner to Accelerate AI Agent Inference with Two-Stage Compute Architecture36Kr ·
Mergi mai departe
- Care model merită?Preț, viteză și hardware alături de capabilitate.
- Întreabă AI despre această lecțieDeschide Întreabă AI cu o întrebare despre această lecție, cu răspuns din arhiva de știri, cu surse.
- Skill-uri de agent pentru această muncăSkill-uri gata făcute pentru agenți AI de programare, verificate și evaluate.
Testează-ți cunoștințele
5 întrebări în 100 de secunde, pe o pagină separată. Citește mai întâi tot ce este mai sus.
Testează-ți cunoștințele →Misiunea modulului
60–90 minServe one small open-weight instruct model (for example a 0.5B–1.5B GGUF from Hugging Face, which needs no account) two ways on your own machine: llama.cpp at Q8_0 and at Q4_K_M, or PyTorch Transformers versus llama.cpp. Run the same 30 prompts through both at concurrency 1 and 4 using llama-bench or a short script, record TTFT, decode tokens/s and p50/p99 latency, and compare the outputs on ten prompts for obvious quality loss. Write a one-page report: a results table, cost per million output tokens at an assumed machine price, which configuration you would ship, and two caveats about how your laptop numbers would not transfer to production.
Se încarcă lucrarea ta…