Reducing LLM Guard scanning latency on a deployment you must keep running
Latency tuning means cutting the per-request delay that LLM Guard adds without weakening the guardrail: every scanner you switch off, sample or cache must be a decision you can defend to your security team. LLM Guard was archived by its owner on 9 July 2026, and its README states that the project and its Hugging Face models are no longer maintained, so DeployOpen does not recommend new rollouts. Tuning here is about keeping a running deployment within its latency budget until it is replaced, not about extending its life indefinitely. Start by measuring where time goes, per scanner and per request type, so changes target the actual bottleneck.
The first lever is fail_fast mode. LLM Guard's best practices recommend it, so a request stops at the first failing scanner instead of waiting for every scanner to finish. Confirm in the LLM Guard best practices guidance and your own tests how it reports results, because your callers must still log which scanner blocked a request for audit purposes. The second lever is running only relevant scanners. Remove scanners that do not match the application's input and output types, and document each removal, since a dropped scanner is a reduction in coverage that the replacement plan must account for. Under heavy load, the best practices also suggest running slower scanners on a sample of requests rather than all of them. Record which scanners are sampled, the sampling rate and the risk you accept for unsampled traffic.
Caching is the third lever, and it needs care. Cache only results where the same input reliably produces the same verdict, and key cache entries on the full input and scanner configuration so a configuration change invalidates them. ONNX Runtime and smaller models may also reduce inference time, but confirm both against the individual scanner documentation, because model swaps change detection behavior. Each change should be tested against a fixed set of known-bad and known-good prompts, with results kept for your audit evidence. Ask your team to confirm which changes are supported by the pinned version you run.
Which latency lever fits which bottleneck
This table pairs each latency lever with the bottleneck it addresses, the security cost it carries, and what to confirm in the LLM Guard documentation for version 0.3.16. Read it by finding your slowest stage first, then checking which levers target that stage without weakening the scanners you rely on.
| Lever | Bottleneck it fits | Security trade-off | Confirm for version 0.3.16 |
|---|---|---|---|
| Fail-fast mode | Requests that trigger an early block but still wait for every remaining scanner to finish | Stops evaluating later scanners once one fails, so the logs show fewer findings per request | Confirm the fail_fast setting name and whether results from skipped scanners are reported |
| Scanner selection | Input or output pipelines running scanners that do not apply to the application's traffic | Removing a scanner removes its coverage, so each dropped scanner needs a documented reason | Confirm which scanners each application path actually needs and which are run by default |
| ONNX Runtime models | CPU-bound inference in transformer-based scanners such as Prompt Injection or Toxicity | Converted models can score differently from the original, so compare results on a test set before cutting over | Confirm which scanners support ONNX model files and where the model_path settings are documented |
| Smaller models | Scanners whose model size drives memory use and per-request inference time | Smaller models usually miss more attacks or flag more benign text, so detection rates need retesting | Confirm which smaller model variants are available for each scanner, since Hugging Face models are unmaintained |
| Sampling slow scanners under load | Expensive scanners that slow peak traffic but are not needed on every request | Unsampled requests pass without that check, so attackers can exploit gaps in coverage | Confirm how the best-practice sampling is configured and whether it is set in code or in the API server |
| Result caching | Repeated identical prompts or outputs, such as templated queries or retries | Cached verdicts can go stale and can hide changes in scanner behavior, and cache keys must avoid storing sensitive text | Confirm whether LLM Guard provides caching at all, and if not, where a cache layer must sit in your application |
How to find which scanner adds the delay
Tuning starts with measurement, not with changing settings. Before you touch fail-fast mode, model choices or sampling, time each input and output scanner separately on representative traffic. A single end-to-end number hides which scanner is responsible, and the slowest scanner is often not the one people expect. Capture the same request mix you see in production, including long prompts, long model outputs and the share of requests that trigger each scanner, because a scanner that is fast on short test strings can be slow on real documents.
Separate model load time from per-request inference. Load time is paid at container start, after a restart or when a worker is recycled, and it shows up as slow starts or delayed first requests. Per-request inference is what every caller feels on every call. Record them as two distinct measurements. If load time dominates, the fix is in the model loading and memory section of this group, not in the scanner configuration. Then record p95 latency under the concurrency you expect at peak, not only average latency at idle. Tail latency is what breaks timeouts in calling applications, and it usually worsens sharply once concurrent requests queue behind a single model instance.
Confirm which timing signals your current API server and reverse proxy already expose before you build anything. This page does not assume that LLM Guard or your deployment emits per-scanner metrics, and the version you run may not provide them. Check your gateway's request duration logs, your container runtime's resource metrics and any tracing you already run, then decide whether you need to add timers around each scanner call in a test harness. Ask your own platform team which of these signals are retained and for how long, because a baseline you cannot reproduce later is of little use when you compare settings.
How to apply latency changes safely in order
This sequence lets you cut LLM Guard scanning delay one change at a time, with a blocking check after each change so a faster guardrail never quietly stops blocking what it blocked before.
Baseline current latency and block rates
The platform or application team records per-request latency for each scanner, along with the scanner list in use and the share of requests each scanner blocks, using a replay of recent traffic from a test environment that mirrors production settings. Store a set of known-bad prompts and outputs that the current deployment blocks, since this set is the reference for every later check. The step is done when the team has a latency table per scanner and a fixed block-test set with expected verdicts. Ask the owner of the scanner configuration to confirm the set covers each input and output scanner in use.
Decide which scanners must run synchronously
The security owner and the application owner go through each enabled scanner and mark it as synchronous (must finish before the response is returned) or as non-blocking for this route. Scanners that protect against the highest-impact risks for the application, such as prompt injection or secrets exposure where the application has a relevant data path, usually stay synchronous, while lower-risk checks are candidates for removal from the hot path. The output is a signed-off list that names each scanner, its risk owner and its mode. Confirm the list with whoever approves risk acceptance for the deployment before any configuration changes.
Enable fail_fast in a test environment
The platform team turns on fail_fast mode in a non-production copy of the deployment, which stops scanning once a scanner flags the content instead of running every remaining scanner. Run the known-bad test set and the baseline traffic replay against this copy. The check passes only when every item that was blocked at baseline is still blocked and the latency table shows the expected reduction. Any item that is no longer blocked stops the change, and the team records which scanner and input caused it before trying again.
Test ONNX models loaded from a local path
Where a scanner supports an ONNX-based model, the team loads it from a local, controlled path and compares its verdicts and latency with the default model on the same test set. This step is also where the team confirms the model files are pinned and copied locally, which matters because the Hugging Face models behind LLM Guard are no longer maintained. The step is done when the ONNX variant matches baseline verdicts on the known-bad set and the latency change is measured. If verdicts differ, keep the original model for that scanner and record the gap in the decommission plan.
Add sampling only for approved scanners
Sampling runs a slow scanner on a fraction of requests, which trades coverage for latency, so it is applied only to scanners the risk owner has approved for sampling in writing. The best practices documentation describes running slower scanners on a sample of requests under heavy load, so the team should confirm that the approved scanners are the slow ones and not the protective ones. Test the sampled configuration against the known-bad set and record the coverage loss in writing. The step is done when the risk owner signs off on the sampling rate and the block-test set still passes for the requests that are scanned.
Add caching only where verdicts cannot leak
The team adds caching only for scanner results where a cached verdict can be reused safely, meaning the cache key includes everything that determines the verdict and the cache is partitioned by tenant, user or caller so one caller's content or verdict is never returned to another. Anonymized or sensitive content must not be stored in a shared cache. Verify this by sending the same content from two callers with different permissions and checking that no verdict or cached text crosses the boundary. The step is done when the isolation test passes and the known-bad set still returns the expected verdicts from the cache.
Run the final regression and record the result
The team runs the complete block-test set, the traffic replay and the latency measurements against the final configuration, then compares them with the baseline from the first step. Every change is recorded with its scanner, its owner, its measured effect and its test result so that auditors and the decommission team can trace the configuration. Promote the configuration to production only after the security owner approves the result in writing. The step is done when the final report shows no regressions in blocked content and the latency change is documented.
Trade-offs by team and risk situation
When every input and output scanner is part of the control that protects the application, latency levers must preserve each scanner's verdict. Fail-fast mode is usually acceptable here, because it stops evaluating after the first failing scanner and still blocks the request. Changes that alter what gets evaluated, such as skipping a scanner or scanning only a sample, reduce coverage and should be treated as a change to the risk acceptance, not a tuning step.
- Fail-fast mode: Confirm that the blocked response is the same as before and that logs still record which scanner triggered.
- Runtime changes: Moving to ONNX Runtime can change scores slightly, so re-run your recorded test set and compare verdicts before rollout.
- Smaller models: Treat a different model as a different control. Retest detection on attack samples that your scanners were chosen to catch.
- Sampling and skipping: Do not apply these to security-critical scanners. Record any reduction as an accepted risk with an owner.
- Caching: Cache only where the key includes the full scanner input and configuration, so a cached pass cannot cover a changed prompt.
Before changing anything, check whether your risk register names each scanner as a control and whether a latency change needs approval under it.
When traffic peaks push latency past what users or upstream services tolerate, and some scanners are advisory rather than blocking, the best-practice levers have more room. The LLM Guard best practices suggest choosing relevant scanners instead of running all of them synchronously and running slower scanners on a sample of requests under heavy load. This works when the team has agreed which scanners are advisory and which are blocking, and when sampled results are reviewed rather than discarded.
- Scanner selection: Remove scanners that do not match the application's input types, and document why each one was removed.
- Sampling slow scanners: Run expensive advisory scanners on a fixed share of requests during peaks and log the sampled results for review.
- Asynchronous checks: Where the response can return before a slow advisory check finishes, record the verdict and alert on failures afterward.
- Fail-fast ordering: Place cheap, high-value scanners first so blocked requests return sooner.
- Capacity: Adding replicas can reduce queueing without changing coverage, so confirm this option before reducing scanners.
Agree in advance which scanners are advisory. A sampled scanner that nobody reviews is no longer a control, so check the review process before enabling sampling.
When the guardrail is already covered by a documented risk acceptance, for example while an archived deployment is still running, the rule is that latency work must not widen the gap that was accepted. The archived project is no longer maintained, so any change that reduces what it checks increases exposure to attacks it may not catch in its current form. Latency work in this situation is limited to changes that keep the same scanners, the same models and the same verdicts.
- Allowed changes: Infrastructure changes such as more replicas, faster storage for models, or tuned worker counts, provided scanner settings stay the same.
- Changes needing sign-off: Fail-fast mode, sampling, skipping scanners or changing model files. Each one should go through the risk owner before rollout.
- Evidence: Keep before and after test results with the same inputs, so the acceptance record shows coverage did not change.
- Rollback: Keep the previous image and configuration available so a latency change can be reverted quickly.
- Replacement timing: If latency problems keep recurring, treat them as input to the replacement plan rather than a reason to weaken scanning.
Check your acceptance record for an expiry date or review trigger, because latency changes made after it lapses may need a new decision.
Where scanning delay enters the request path
The diagram starts at the client, whose request passes through the API gateway to the LLM Guard API server, which runs the selected input scanners before the model call and the selected output scanners before the response returns. Check where fail_fast stops the chain early, which scanners run on a sample of requests, and that model loading happens at startup rather than inside the request path.
Scanner stages sit in the request path, while model loading happens before traffic arrives.
Security effects of cutting latency
Every latency shortcut trades speed for coverage. The four changes below can each let a prompt or response pass without the check you intended, so record each one before you deploy it. The risk acceptance and audit evidence for an archived guardrail depend on that record.
Skipped scanners
Dropping scanners from the pipeline removes the detections they provided. If you keep only the scanners your team judges relevant, the removed ones, such as Prompt Injection or Secrets, stop catching their attack classes entirely. Before removing a scanner, write down which threat it covered, which callers send traffic through it, and who approved the gap. Then check whether an upstream control still covers the same risk. Treat each removal as a coverage change, not a tuning detail.
Best practices docsSampled scans that miss attacks
Running a slow scanner on a sample of requests under heavy load means unsampled requests pass without that check. An attacker who learns the sampling rate or timing can send payloads in the unsampled portion. Record the sampling rule, the trigger for turning it on, and the share of traffic it covers. Confirm whether sampling is random or tied to load, and whether attackers can influence it through request volume. Sampling should be a documented, time-limited exception, not a permanent default.
Cache entries with stale verdicts
Caching scanner results saves repeated computation, but a cached verdict stays valid only while the scanner, its model and its configuration stay the same. A cache keyed only on prompt text can serve an old verdict after a model file changes or a scanner setting is edited. Check that cache keys include scanner name, model version and configuration hash, and that the cache expires. Verify that a stale verdict cannot survive a model swap during a replacement.
Cross-tenant cache verdicts
A shared cache can return one tenant's verdict to another tenant if the key omits tenant identity or per-tenant scanner settings. Tenants may also have different allow lists, thresholds or anonymization rules, so a verdict valid for one may be wrong for another. Confirm that the cache is partitioned by tenant and by policy, and that cached entries never store raw sensitive content. Test this with two tenants whose policies differ before enabling the cache for production.
Changed error handling on scanner failure
Fail-fast settings and timeout changes alter what happens when a scanner errors or times out. If a failed scanner returns a pass by default, an overloaded or crashing scanner silently stops enforcing policy. Decide explicitly whether a scanner error blocks the request, passes it with logging, or routes it to review. Record the chosen behavior, the timeout value and the alert that fires on scanner failure. Test the failure path under load, since that is when shortcuts are most likely to be used.
Questions teams ask before tuning LLM Guard latency
Can our own engineers tune LLM Guard latency without outside help?
Yes, if you have engineers who can read Python, run load tests and change container configuration. The main tuning levers are documented in the project's best practices: fail-fast mode, choosing only the scanners each route needs, and running slower scanners on a sample of requests under heavy load. Each change alters what the guardrail blocks, so the hard part is proving that a faster configuration still catches what the slower one caught. Your team will need that test evidence regardless of who makes the change.
How much effort does latency tuning take, and what drives it?
Effort rises mainly with the number of scanners enabled, the number of distinct request paths or applications calling the API, and how much traffic you must replay to be confident. A deployment with a few input scanners on one route is a small exercise. Many scanners across several applications, with separate thresholds per route, means more measurement and more sign-off. Ask any partner for a quote built from your scanner list, your call volume and the test environment you can provide, rather than a generic figure.
What do we need to provide before tuning starts?
Tuning needs three things from your side. First, representative test traffic, ideally captured or anonymized from production, that includes both normal prompts and the attack and edge cases the scanners exist to catch. Second, a named risk owner who accepts any change in blocking behavior in writing. Third, access to a non-production environment with the same container image, hardware class and model files as production, plus the metrics needed to measure latency per scanner. Without these, timing numbers do not tell you much.
Can we roll back a latency change if it causes problems?
Yes, if each change is made through configuration you version and deploy the same way as the rest of the service. Scanner selection, fail-fast behavior, sampling rates and any cache settings should live in version-controlled files, so you can return to the previous set in one deployment. Record the baseline blocking results for your test traffic before each change, so a rollback is judged against the same evidence. Confirm your container rollout and rollback process before you start, not during an incident.
Does caching scan results create a security risk?
It can. A cached result is only valid while the input, the scanner version and its configuration are unchanged, and a cache keyed on the wrong data can return a stale allow decision for a prompt that should be blocked. Cache keys should include the full input, the scanner name and version, and the threshold settings. Involve your security reviewer before enabling it, and test with prompts that differ by one character or by invisible characters to confirm the cache does not merge them.
Sampling slow scanners means some requests go unscanned. Is that acceptable?
Only if your risk owner accepts it for the specific scanners and routes involved. Running a slow scanner on a sample reduces load but means the unsampled requests pass without that check, so the protection is partial by design. Write down which scanners are sampled, the sampling rule, and the traffic classes that must always be fully scanned. Treat sampling as a compensating control to record in your risk register, not as a performance fix that disappears from the review.
When does tuning stop being worthwhile compared with planning replacement?
Stop tuning when the remaining latency gap cannot be closed without dropping scanners your risk owner requires, or when the effort to re-prove blocking behavior after each change exceeds the value of the change. LLM Guard is archived and no longer maintained, so every tuning decision also adds to a deployment that will not receive fixes. If tuning has brought latency to an acceptable level, move the effort into replacement planning with a maintained guardrail such as NeMo Guardrails, and keep the tuned configuration pinned until cutover.
When tuning stops being the right answer
Latency work extends a deployment that is already archived, and it does not change the underlying risk. The LLM Guard repository was archived by its owner on 9 July 2026, and its README states that the project and its associated Hugging Face models are no longer under active development or maintained. Every improvement in this topic, from fail-fast mode to ONNX Runtime to sampling slow scanners, shortens the time a request waits for a scanner that will receive no further fixes. Tuning changes how fast the guardrail answers, not whether its models, dependencies and Python runtime keep receiving security updates.
Treat any tuning change as a stopgap with a defined end date. Before spending effort on it, confirm which scanners are on the request path, which models each one loads, and whether the owning team has a dated plan to retire them. The decommission planning page covers the inventory of callers, the risk acceptance needed while the guardrail runs, and the replacement milestones. If sampling or skipped scanners are adopted, record which requests were not fully scanned, because that gap is part of the risk the organization is accepting.
No new LLM Guard rollout is recommended. If a team is still choosing a guardrail, or is starting a new application, the next step is a maintained option such as NeMo Guardrails, and the migration page describes replacing LLM Guard scanner by scanner while proving the replacement blocks at least what LLM Guard did. Use the latency measurements from this work as the baseline for that comparison, so the replacement is judged on the same traffic and the same thresholds.
How DeployOpen scopes latency work on existing deployments
Latency work on a running LLM Guard deployment changes what blocks, what gets logged and what gets evidenced, so it is scoped as a fixed engagement with written deliverables. The cards below describe how that scope is set, measured, documented and supported after the first release of changes.
Fixed scope agreed in writing
Before any change, DeployOpen and your team agree in writing which endpoints, scanners and request volumes are in scope, which latency targets matter, and what each deliverable contains. The scope names the current fail_fast setting, the scanners in each input and output chain and the environment where changes will be tested. Ask for the written scope before accepting any quote. DeployOpen does not publish a price list, so the quote follows from that document.
Baseline latency measurement
The engagement starts by recording latency per scanner, per endpoint and under realistic concurrency, using traffic that resembles production. Without this baseline, a change such as ONNX Runtime or sampling cannot be shown to help, and a regression can be mistaken for noise. Ask for the percentile figures, the request mix and the hardware used for the measurement.
Before and after blocking verification
Every latency change is tested against a fixed set of prompts that LLM Guard should block or allow today. Moving a scanner to a sample, skipping it under load or changing its model can alter what gets blocked. DeployOpen compares results before and after each change, so you can see which blocked prompts stopped being blocked and decide whether that is acceptable.
Change records for audit evidence
Each change is recorded with the reason, the configuration diff, the test results and the approver. Auditors and customer security reviewers often ask how a security control was changed while it ran, so these records are kept with the version pinning and compensating controls. The records are delivered as part of the written deliverables.
Rollback and staged rollout
Changes go to a staging environment first, then to a limited share of production traffic, with a documented rollback to the prior configuration and model set. Confirm with your operations team which metrics trigger a rollback before the rollout starts. This keeps a faster but weaker guardrail from reaching all users at once.
Retainers for ongoing support
Once the changes are live, the scanners, models and Python environment still need watching. DeployOpen offers retainers for ongoing support, periodic re-measurement and retesting after updates. Retainer scope, response expectations and what is included are set in writing. Ask whether re-measurement is included each quarter or billed separately when your traffic pattern changes.

