Hypothetical scenario. Northwind serves a tenant-specific adapter over a base model. Dev sees a repeated prefix and proposes reusing its KV state. Maya recognizes the same visible text; Priya asks which model and adapter produced the cached blocks.
Maya: “The instructions look identical to the earlier request.”
Dev: “The adapter can change the state computed from those instructions.”
Priya: “Check computation identity before calling this a reusable prefix.”
You will separate training LoRA or QLoRA-derived artifacts from serving them, then trace prefix/KV eligibility across model, adapter and execution identity. Reusing compatible state does not remove the logical context or the remaining decode work.
Which computation produced the prefix state?
LoRA trains low-rank adapter updates while keeping a base model fixed. QLoRA combines low-rank adaptation with a quantized base during training; it is not itself a universal serving format. Serving must support the actual base, adapter, quantization and runtime combination. Do not assume that loading an adapter trained under one configuration makes every prefix state compatible with another.
vLLM's prefix-cache design describes reuse of KV blocks for compatible prefixes. Across nodes, a shared directory or transfer path still needs ownership, eligibility and lifetime decisions. The prefix tokens alone are insufficient when a model or adapter changes the state computation. Use model, adapter, position and relevant execution identity in the eligibility contract, with tenant isolation as required.
Hypothetical scenario. A repeated 600-token prefix and a new 100-token suffix contain 700 input tokens. A fully eligible prefix hit can avoid recomputing those 600 prefix tokens, leaving 100 new input tokens for this simplified prefill ledger. It does not reduce the logical context to 100 tokens, and the response still needs decoding. An adapter mismatch makes that hit ineligible even if the visible prefix is identical.
The policy is retrieved, but the answer has the wrong structure
Northwind's assistant finds the current returns policy but mixes customer explanations with internal routing notes. Priya can describe the desired separation. Dev proposes an adapter trained on approved demonstrations. Sam asks which artifacts would change and how the team would reverse the change if another support task became worse.
Training on every previously accepted conversation is an inadequate specification. Some conversations may contain old policy, copied credentials or permissions specific to one caller. Acceptance of a particular response does not establish that every token should become a reusable target. Define the behavior to learn before collecting demonstrations, including evidence requirements, abstention and the distinction between proposing and executing an action.
Bind prefix reuse to the computation that produced it
Hypothetical scenario. Two requests share visible prefix text but select different adapters. Their hidden prefix states need not be interchangeable. A reuse identity includes the actual model and adapter computation, token prefix and relevant positional/layout configuration.
| Artifact | Concrete evidence | Decision boundary |
|---|---|---|
| Adapter artifact | base model, adapter revision/composition | Prediction computation |
| Prefix identity | token IDs, model/adapter, position/layout | Eligible state reuse |
| Response identity | task, evidence, caller authority | Different reuse contract |
LoRA or QLoRA training choices do not by themselves define compatible inference state. Adapter loading, composition and serving have separate memory and interference costs. Prefix reuse avoids selected recomputation; it does not remove logical context or make final responses equivalent. Keep response caching separate, because an answer can depend on current source evidence and caller permission even when prefix computation is identical.
A demonstration supplies a conditional prediction target
Supervised fine-tuning, or SFT, supplies an input and a target response. Optimization increases the probability of target tokens given the input and earlier target tokens. Training can score selected response positions while retaining prompt positions as unscored context. Formatting and loss masking therefore change what the training objective rewards.
Northwind's target might contain a customer explanation and a separate routing proposal. Examples should also show insufficient evidence, unsupported requests and necessary clarification. If all targets confidently recommend an action, the model receives little demonstration of when to stop. A general instruction about caution cannot compensate reliably for a contradictory collection of examples.
The Hugging Face SFT Trainer documentation provides a concrete reference for dataset formats and loss controls. Check the actual configuration rather than assuming an implementation default matches the task. A tool can optimize the supplied objective faithfully while that objective rewards the wrong response pattern.
Compute a training improvement before interpreting it
Hypothetical scenario. Select a target with three scored tokens. Suppose their correct conditional-token probabilities are 0.5, 0.25 and 0.8. Natural-log negative log probabilities are approximately 0.6931, 1.3863 and 0.2231. Their sum is 2.3025; the mean is 2.3025 / 3 ≈ 0.7675.
A second model assigns probabilities 0.6, 0.5 and 0.8. Its terms are approximately 0.5108, 0.6931 and 0.2231. Their sum is 1.4270 and the mean is 1.4270 / 3 ≈ 0.4757. Under these chosen probabilities it predicts this target better. This example is arithmetic, not an observed training result or a promised gain.
The calculation says nothing about whether the target follows today's policy, cites a real paragraph or proposes an authorized action. It also hides how cases are weighted. A long easy template can dominate token-averaged loss while a short important refusal remains poor. Evaluate response categories separately and keep examples that were not used to choose labels, prompts or checkpoints.
LoRA expresses an update through smaller matrices
For a selected layer with weight matrix W, LoRA adds a scaled update represented by a product BA. The original matrix can remain frozen while the two smaller matrices are trained. The rank specifies the update representation's size. It is a design choice to compare empirically, not a direct measure of task competence.
Choose a square 4,096-by-4,096 base matrix. It contains 4,096 × 4,096 = 16,777,216 parameters. At selected rank 8, A contains 8 × 4,096 = 32,768 entries and B contains 4,096 × 8 = 32,768. Their total is 65,536 trainable entries. For this particular matrix, 65,536 / 16,777,216 = 1 / 256 = 0.390625%.
This is not the fraction of total training memory consumed. The frozen base, activations, temporary buffers, adapter gradients and optimizer state still require storage. Adding target modules or other trainable components changes the count. Quantization and activation checkpointing address different parts of the resource budget and must be accounted for separately.
Learning a tool proposal does not grant its permission
Demonstrations can teach a model to select a tool name, construct arguments and interpret observations. This is learned behavior. Northwind's executor still needs to authenticate the caller, validate the request and enforce its resource scope. A correct-looking tool proposal can refer to an unauthorized account or to state that changed after training.
Training targets should distinguish a proposed call from an actual returned observation. Inventing a successful tool result inside a demonstration teaches a different pattern from grounding a response in a recorded result. Include unavailable tools, rejected arguments and uncertain attempts where the task requires them. Do not include live secret credentials simply because an execution service needs credentials outside the model.
The tool-selection chapter explains runtime eligibility. SFT adds a way to learn which eligible proposal is useful, while authorization remains enforced when the model selects incorrectly. This distinction is essential for an agent: learned competence reduces mistakes but cannot replace the control that limits their effects.
Adapter composition has an algebra before it has a benchmark
Two compatible adapters can represent updates B1A1 and B2A2 to the same base layer. A weighted sum of those updates defines one candidate transformation. Independent usefulness does not establish that the combined transformation preserves either task. Base revision, target modules, shapes and scaling must agree before task comparison even begins.
Consider scalar factors A1 = 1, B1 = 2, A2 = 3 and B2 = 4. Their updates are 2 and 12. An equal-weight average of the updates is (2 + 12) / 2 = 7. Independently averaging the factors gives A = 2 and B = 3, whose product is 6. Cross terms make these different transformations. Matching dimensions is not a proof that an averaging method has the intended effect.
The PEFT model-merging guide documents supported combination methods. Use the method's defined behavior and restrictions rather than calling every transformation “merging” and assuming capability addition. Record the components and combination settings, then test the resulting artifact as a new candidate.
Several loaded adapters require an explicit request identity
Serving adapters separately allows a service to select a reviewed specialization. Bind the base-model revision and adapter revision for the request's lifetime. A task label alone is insufficient if it can resolve to another artifact during an extended workflow. Include the effective combination in cache identity, evaluation records and diagnostic evidence.
An adapter is also not a tenant security boundary. It may encode information from its training examples, and a shared service still processes the request. Enforce who may load or invoke an adapter and how its data and artifacts are retained. Small file size does not establish confidentiality, isolation or suitability for a different customer's task.
Merging an adapter into a base changes rollback packaging. A separate adapter can be deactivated; a merged release requires restoring the prior complete artifact. Compare that packaging simplicity with the routing and memory responsibilities of separate adapters. The choice depends on the actual workload, not a universal preference for one deployment shape.
In the wild: tooling separates training from parameter configuration
The SFT Trainer reference describes example handling and objective controls. The PEFT LoRA reference describes adapter configuration. Together they illustrate distinct responsibilities: defining what to reward and defining which parameter update is available. They do not establish that a particular Northwind workload improves.
Hypothetical scenario. A routing adapter passes its task test, then is accidentally served with another base revision. The process starts but responses change. Diagnose the complete artifact mismatch before blaming training randomness. Preserve a known-good combination and check compatibility when loading, rather than relying on successful startup as the release gate.
Compare against the base with the same task contract
Evaluate the unchanged model with the current prompt first. Compare the adapter under the same evidence and decoding assumptions where they affect fairness. Score formatting, evidential support, refusal, tool selection and authorized execution separately. A formatting improvement should remain visible beside a support regression, rather than disappearing into one average.
Write down why training was chosen over repairing retrieval, clarifying a prompt or adding an application rule. Adaptation is reasonable for recurring learnable response patterns with suitable demonstrations. It is a poor replacement for current source retrieval or a missing permission check. Resolve disputes about target behavior before optimizing more faithful imitation of it.
Release data identity, objective masking, base and adapter identifiers, task results and rollback together. Inspect representative failures as well as aggregate metrics. A lower loss may simply make a labeling mistake more consistent. A small update may still change an important behavior beyond the narrow examples chosen for the initial review.
Capacity, interference and evidence remain separate questions
There is no universal rank that balances adaptation capacity and preservation. More trainable parameters can express more changes, but the useful effect depends on the task, demonstrations and optimization. Reducing rank is not a substitute for checking what information was included in examples, and increasing rank cannot make an incorrect label become correct.
Experts can reasonably choose separate adapters to preserve independent release decisions or a combined artifact to simplify serving. Evaluate the real operational difference: deployment identity, cache partitioning, rollback and task interference. The relevant disagreement concerns observable tradeoffs. It cannot be settled by assuming that adapter arithmetic or a lower training loss proves generalization.
Test the adapter artifact boundary
The adapter changes but the prompt text does not. Can the old KV entry remain a hit?
Reveal the design reasoning
Only with established computational equivalence under the implementation contract; ordinary text equality is insufficient. Invalidate or partition the cache identity and remeasure memory and latency.
Decision: Version adapter and cache identities independently from application answer reuse.
Explain what the trained change actually proves
Loss falls while unsupported policy answers increase. Should rank increase?
First inspect target correctness and the mismatch between token prediction and supported answering. Training improved imitation of the supplied examples. It did not satisfy the application task. Keep the previous deployment while repairing data or the task design.
Do factors (1, 2) and (3, 4) yield the same averaged update when their factors are averaged separately?
No. The updates 2 and 12 average to 7, while averaged factors 2 and 3 multiply to 6. Specify the actual composition method and evaluate the new artifact rather than assuming factor averaging preserves update averaging.
A fine-tuned model reliably selects a restricted refund tool. Can the service remove authorization?
No. Training changes a proposal distribution. The service still needs current caller and resource authority. Include learned tool selection in evaluation while keeping runtime scope enforcement independent.
Northwind decision log
- Define valid demonstrations and a held-out response task before training.
- Version the base and adapter combination, including composition and serving identity.
- Evaluate learned tool use while enforcing permissions independently.
Go deeper: gradients and generalization
- Video lecture: Building makemore Part 3: Activations & Gradients, BatchNorm, Andrej Karpathy. Understand gradients and training dynamics before interpreting an adaptation result.
- Book chapter: Deep Learning: Foundations and Concepts, chapter 8: Backpropagation, Christopher M. Bishop with Hugh Bishop. Explain how an objective supplies parameter gradients.
- Book chapter: Deep Learning: Foundations and Concepts, chapter 9: Regularization, the same authors. Connect training restrictions with generalization rather than guaranteed quality.
- Primary document: SFT Trainer, Hugging Face. Inspect dataset formats and loss controls against the desired behavior.
Check the mechanism in this lesson
May two identical visible prefixes share KV state when they were computed with different adapters?
Compare the explanation
Not without an established compatibility guarantee. The adapter can change the state computation. Preserve model, adapter and execution identity in eligibility rather than comparing only the prefix text.
Carry the decision forward
Northwind can decide when intermediate state is reusable. Page 35 asks a different question: when may an already completed response be returned under current task, authority and freshness conditions?