Optional Modal host: review a plan before spending
Use Modal when you want to evaluate GPT-OSS-20B without hosting a GPU locally.
Recall Guard uses OpenAICompatibleClient and the existing evidence and
calibration contracts. Start with the offline plan below. A working endpoint,
valid token evidence and a useful contamination score are separate results.
The deployment recipe and bounded runner are verified offline. The
2026-11-06 live pilot verified weight staging,
deployment, remote expiry arming and unauthenticated HTTP 401 before readiness.
Attempt 08 reached model readiness and authenticated generation, but strict token
alignment failed on its one eligibility response. No measurement prompts ran;
that historical response remains excluded from scoring. The
runner verified model-app shutdown, and final inventory confirmed every owned
model, expiry and diagnostic app stopped.
The response-handling diagnostic
later found an adapter bug: vLLM reports full Harmony-generation
probabilities separately from final-answer text. Use the explicit Harmony profile
below. The mismatch was not a finding that GPT-OSS lacks usable logprobs, and
different generations are never required to match.
Startup diagnostics identified the inherited vLLM entrypoint and an incompatible
typing_extensions import. The recipe clears that entrypoint and pins 4.16.0;
a fresh CPU-only check confirmed Sentinel and pydantic_core imports. Keep every image operation
before deferred local-file additions. Weights are retained after app shutdown.
The GPU request was A100-40GB; the observed device was A100-SXM4-80GB. Preserve both facts in comparisons. This historical run establishes neither 40 GB fit nor actual attributable GPU cost. The separately authorized diagnostic observed an A100-40GB; its response was captured for offline mapping replay without further inference. The original local CPU result is in the local integration guide.
Select the GPT-OSS Harmony response profile
For this pinned vLLM/GPT-OSS response contract, opt into the response mapper
explicitly. It reuses the existing transport and request budget. Run credentialed
code in the development container and pass only the proxy credential by name,
for example docker compose run --rm -e MODAL_PROXY_BEARER dev ...; Compose reads
its value from the root .env, and the code does not print it. The image
excludes models/, so mount the staged tokenizer read-only with
-v ./models:/app/models:ro.
from pathlib import Path
from recall_guard.core.completion import ModelConfig
from recall_guard.core.harmony_evidence import HarmonyTokenMap
from recall_guard.core.providers import HarmonyOpenAICompatibleClient
from recall_guard.core.request_control import CallBudget
tokenizer_revision = "6cee5e81ee83917806bbde320786a8fb61efebee"
tokenizer_directory = (
Path("models/hub/models--openai--gpt-oss-20b/snapshots") / tokenizer_revision
)
token_map = HarmonyTokenMap.from_tokenizer_json(
tokenizer_directory / "tokenizer.json", tokenizer_revision=tokenizer_revision,
)
config = ModelConfig(
protocol="openai_chat", provider="modal", model="openai/gpt-oss-20b",
endpoint="https://your-registered-host.modal.run/v1/chat/completions",
credential_ref="MODAL_PROXY_BEARER",
parameters={"temperature": 0, "top_p": 1, "max_tokens": 512,
"logprobs": True, "top_logprobs": 5, "return_token_ids": True},
max_retries=0, timeout_s=120,
)
client = HarmonyOpenAICompatibleClient(config, CallBudget(1), token_map=token_map)
# Construction makes no request. Measurement still requires an explicit run plan.
Control IDs come from the pinned tokenizer; no tokenizer framework is loaded. Original output IDs and logprob entries share one position axis. The mapper selects one complete final-message span and preserves its probabilities and alternatives. It rejects unsupported or ambiguous layouts instead of guessing a text suffix. The generic client is still available for other response contracts. The diagnostic validates mapping by replaying the same captured response; fresh calibration is required before scoring claims.
Inspect the plan without an SDK or account
From the repository root, in the development container:
docker compose run --rm dev uv run --no-sync python deploy/modal/manifest.py configs/modal/gpt-oss-20b-pilot.json
docker compose run --rm dev uv run --no-sync python scripts/probe_modal_model.py
The development image excludes models/. To plan against a staged tokenizer,
use the operator container below, which mounts the checkout.
Both commands are verified offline. They do not import Modal, resolve credentials,
download artifacts, deploy or send inference. The runner prints mode: plan,
inference_posts: 0 and cloud_mutations: 0. Missing workspace, endpoint,
provider budget, account approval, pinned tokenizer and remote cache are explicit
blockers. A successful plan exit does not mean execution is ready. No endpoint
or model is substituted on failure.
The manifest configs/modal/gpt-oss-20b-pilot.json pins model and tokenizer commit
6cee5e81ee83917806bbde320786a8fb61efebee, MXFP4, vLLM 0.17.0 and the full
Linux AMD64 image digest. Inspect it for the complete digest, sources, license
record and dated pricing assumptions.
| Planned bound | Value |
|---|---|
| Host | One A100 40 GB; four physical CPU cores; 32 GiB RAM (32768 MiB API request) |
| Parallel work | One model container, one request, tensor parallel size one, one scheduled sequence |
| Idle scaling | Minimum zero, buffer zero, maximum one; 60-second scaledown window |
| Context | 4096 tokens including input and output allowance |
| Inference | One eligibility probe, then at most seven fixed measurements; zero retries |
| Generation | Temperature 0, top_p 1, logprobs true, top_logprobs 5 |
| Output | At most 512 tokens per request, 4096 across eight requests |
| Time | 120 seconds per request; 600 seconds startup within a 1200-second GPU phase; 120 seconds cleanup |
Install the optional operator tools
The operator tooling runs in a container through scripts/modal_operator.sh,
from a WSL, Linux or macOS shell in the repository root. This first run downloads
Python tooling and the pinned uv Python 3.12 image, not models or remote images:
sh scripts/modal_operator.sh plan
The script mounts the checkout at /app, syncs the locked deploy/modal
environment into the Docker volume rg-modal-venv, prints the Modal and
Transformers versions, and runs the offline plan. Its other modes are apps,
lock, execute RECEIPT APPROVAL and stop APP_ID. plan and lock read no
credentials. The finance study's serving arm adds stage MANIFEST STAGE_LIMITS
RECEIPT, serve MANIFEST STAGE_LIMITS RECEIPT and stop-serve MANIFEST RECEIPT
(scripts/serve_modal_model.py), and measure-plan accepts a trailing
--modal-manifest PATH.
The isolated lock includes Modal 1.6.3, the editable local Recall Guard package,
Transformers 4.55.4, Hugging Face Hub 0.34.4 and Jinja2 3.1.6 for chat templates.
The operator project requires Python 3.12 (deploy/modal/.python-version);
the operator image provides that minor independently of the root development
environment.
Modal serializes the serving class and expiry function, so the operator's Python
minor must match both remote images. Execution and recipe construction reject
other minors locally, before SDK import, cache inventory or deployment. Offline
planning still works on the root project's supported Python versions.
The pinned vLLM image uses Python 3.12, matching the expiry image's explicit
debian_slim(python_version="3.12"). On 2026-11-06, read-only Docker Registry
manifest/config requests confirmed config digest
sha256:700d8ac4f37a3f2975b79e67406d7f2689bdd8c87e3e7a62721bf03921940935:
its build history records PYTHON_VERSION=3.12 and selects that interpreter as
python3. No image layers were pulled for this check.
The image also inherits ENTRYPOINT ["vllm", "serve"]; the recipe resets it with
image.entrypoint([]) so Modal can execute its bootstrap arguments. A live
CPU-only check observed typing_extensions 4.12.2 lacking Sentinel, which
prevented pydantic_core import. The explicit image dependency override remains
outside the core package and the local operator lock. The recipe pins 4.16.0
before all deferred file additions; verify its effective import in the resulting
image. See Modal's existing-image guidance.
Use the provider-registered endpoint, including its regional hostname when present. The runner checks it against the explicit manifest before HTTP traffic or GPU readiness. It never silently redirects requests to a guessed address.
The local tokenizer needs no PyTorch, CUDA or vLLM install. Python 3.12 tooling, chat-template rendering and lazy serving/expiry construction were checked with network socket operations blocked. Transformers reports that only tokenizer/configuration utilities are available without a model framework.
Recall Guard's default installation has no Modal or accelerator dependency.
deploy/modal/serve.py constructs recipes only when called. Use the bounded
runner for execution; there is no module-level app for modal deploy.
Configure account access and budgets after review
These are operator setup instructions, not verified account procedures. No account state or credentials were inspected for this delivery.
Use the single repository-root .env for credentials. The tracked .env.sample
lists the fields; if .env already exists, add missing fields without replacing
the file. Obtain an account API token in Modal's dashboard and put its ID and
secret in MODAL_TOKEN_ID and MODAL_TOKEN_SECRET. Do not use shell exports,
OS/user environment secrets, separate provider files or modal token new.
Create or select the dedicated recall-guard-pilot environment in the intended
workspace. Verify permission to deploy apps, read provenance and stop experiment
compute. Keep values out of shell output and Git.
Create a separate Modal proxy token in workspace settings. Supply its ID and
secret joined by a period in MODAL_PROXY_BEARER in that same root .env.
The credentialed operator modes (apps, execute, stop) pass the root .env
to that one container with docker run --env-file, so every variable in the file
reaches that container and no other. Inside it the script trims
surrounding whitespace from the Modal values; .env is not modified. Offline
planning (plan, lock) reads no credentials. This bearer protects the Web Function; SDK control-plane
credentials are separate. The recipe sets requires_proxy_auth=True.
Modal proxy authentication
documents this scheme (checked 2026-11-06). Live denial without waking a GPU
is still a required task 10.2 check.
Set target.workspace and the explicit https://YOUR-HOST.modal.run/v1 endpoint
in the reviewed manifest before freezing its hash. Confirm the expected URL
with the operator; the runner neither discovers a URL nor silently rewrites one.
Keep cost.provider_budget null: the reviewed budget belongs in the separate
approval record. The serving recipe uploads the canonical manifest, so its app,
environment, artifacts, resources and limits must match the runner's plan.
Review the pinned model card, Apache-2.0 license and applicable notices before download or redistribution. Public metadata access recorded in the manifest is not proof of this account's allowance or successful weight access.
Review monthly gross usage and remaining allowance, including prior usage. Modal budgets distinguish workspace usage from environment compute coverage; environment budgets require an eligible plan (checked 2026-11-06). Have the responsible owner configure suitable policy in the dashboard. The runner never overwrites shared policy. Unavailable billing requires an explicitly operator-confirmed allowance; unknown usage is null.
The configured 1200-second compute subtotal is
1200 * (0.000583 + 4 * 0.0000131 + 32 * 0.00000222) = USD 0.847728.
It excludes staging, builds, storage, CPU expiry control, cleanup tails, egress
and excess CPU/RAM use. USD 5 is a target, not an exact ceiling. The total estimate
is unknown until these additional costs are reviewed. Recheck
prices before approval. See the
receipt and cost contract for accounting and reconciliation.
Stage pinned weights separately, without a GPU
No staging command has been executed or automated by the GPT-OSS-20B runner.
The stage mode above exists for the finance study's Gemma 3 4B weights; this
manual strategy is still the GPT-OSS-20B route. It is for a separately approved setup window and needs disk/network and
storage cost review. Local Ollama GGUF blobs are incompatible with this vLLM
MXFP4/safetensors recipe. Do not upload the Ollama store or the checkout.
The following snippet uses the pinned Hub client on the local CPU, in the
operator image after sh scripts/modal_operator.sh plan has synced its
environment. Run it from a WSL, Linux or macOS shell in the repository root.
It downloads selected snapshot files into the ignored models/ directory, using
the exact directory layout expected by the runner and remote server. No model
framework or GPU is invoked. The download itself is unverified here.
docker run --rm -i -v "$PWD:/app" -w /app -v rg-modal-venv:/opt/modal-venv -e UV_PROJECT_ENVIRONMENT=/opt/modal-venv ghcr.io/astral-sh/uv:0.9.7-python3.12-bookworm-slim uv run --project deploy/modal --no-sync python - <<'EOF'
import json
from pathlib import Path
from huggingface_hub import hf_hub_download, snapshot_download
plan = json.loads(Path("configs/modal/gpt-oss-20b-pilot.json").read_text(encoding="utf-8"))
artifacts = plan["artifacts"]
assert artifacts["model"] == artifacts["tokenizer"]
assert artifacts["model_revision"] == artifacts["tokenizer_revision"]
revision = artifacts["model_revision"]
snapshot = Path("models/hub/models--openai--gpt-oss-20b/snapshots") / revision
snapshot.mkdir(parents=True, exist_ok=True)
index_path = hf_hub_download(artifacts["model"], "model.safetensors.index.json",
revision=revision, local_dir=snapshot, token=False)
shards = set(json.loads(Path(index_path).read_text(encoding="utf-8"))["weight_map"].values())
assert shards and all(Path(name).name == name for name in shards)
files = sorted(shards | {"model.safetensors.index.json", "config.json", "tokenizer.json",
"tokenizer_config.json", "chat_template.jinja", "generation_config.json", "LICENSE", "NOTICE"})
snapshot_download(artifacts["model"], revision=revision, local_dir=snapshot,
allow_patterns=files, token=False, max_workers=1)
required = shards | {"model.safetensors.index.json", "config.json", "tokenizer.json", "tokenizer_config.json"}
assert all((snapshot / name).is_file() and (snapshot / name).stat().st_size > 0 for name in required)
EOF
token=False avoids reading a cached Hugging Face credential for this public
artifact. Optional template/notice files are copied when present. The pinned
Hub API
supports revision and local directory selection (checked 2026-11-06).
After reviewing these exact files, upload only this snapshot's selected files to
the dedicated volume, retaining the same hub/models--.../snapshots/COMMIT/ path.
For Modal 1.6.3, Volume.from_name(name, environment_name=..., create_if_missing=True)
and with volume.batch_upload() as batch: batch.put_file(local_file, remote_path)
provide a local upload route without creating a GPU. Build remote_path from
hub/models--openai--gpt-oss-20b/snapshots/ plus the pinned revision and filename.
Use volume recall-guard-gpt-oss-20b-weights in the reviewed environment. Validate
resolved local paths remain inside the snapshot, reject symlinks/junctions and
upload only files from the snippet that exist; exclude Hub .cache metadata.
Do not recursively upload models/. This is a manual strategy, not a verified
end-to-end upload procedure. The installed SDK signatures were checked against
the Volume API on 2026-11-06.
Rerun the offline plan after staging the local tokenizer. It counts the actual one-user-message chat template locally with downloads disabled, hashes tokenizer files and checks each input plus 512 output tokens against context. Before GPU deployment the runner inventories the existing remote volume and rejects a missing index, missing/nonpositive indexed shard or missing required config. Inventory proves presence, not shard content integrity or a successful vLLM load.
Freeze approval and start only the reviewed pilot
Save approval outside tracked files, for example runs/container/modal-approval.json.
This is the record shape the runner accepts, left unauthorized on purpose. Replace
hashes with the final plan output and all review assertions with actual evidence;
copying this example cannot grant approval.
{
"paid_execution_authorized": false,
"account_access_verified": false,
"operator_allowance_confirmed": false,
"model_access_verified": false,
"pricing_and_budget_reviewed": false,
"manifest_sha256": "FINAL_PLAN_MANIFEST_SHA256",
"prompts_sha256": "FINAL_PLAN_PROMPTS_SHA256",
"workspace": "YOUR_WORKSPACE",
"provider_budget_reference": "operator_budget_review",
"monthly_budget": {
"scope": "environment_compute",
"workspace": "YOUR_WORKSPACE",
"environment": "recall-guard-pilot",
"period_month": "2026-11",
"checked_at": "2026-11-06T08:00:00Z",
"source": "operator_budget_review",
"monthly_limit_usd": 20,
"prior_usage_usd": null,
"requested_allowance_usd": 5,
"accounting_available": false,
"operator_confirmed": false
}
}
All five top-level assertions must be exactly true for execution. Workspace and
both hashes must match. monthly_budget needs the current UTC month and a
nonfuture timezone-aware check time; use actual reviewed amounts. With accounting
available, prior usage must be known; otherwise operator confirmation must be
true. Known insufficient headroom always fails. scope also accepts workspace.
source is a 1-100 character letters/digits/underscore/hyphen reference, not raw
billing data. The allowance must cover the compute subtotal; human review must
also cover excluded costs. This record is a review snapshot, not reserved funds.
Only after separate paid approval and prerequisite checks, run from a WSL, Linux or macOS shell:
sh scripts/modal_operator.sh execute runs/container/modal-pilot-NEW.json runs/container/modal-approval.json
This mode runs scripts/probe_modal_model.py --execute --harmony-eligibility-only:
one eligibility request, the form used live on 2026-11-08. The full measurement
pilot has no operator mode yet. Under runs/container, the receipt is also
visible to the development container as /outputs for
billing reconciliation.
The receipt path must be new and its parent must exist. Never resume or replay an existing receipt. Startup deploys the CPU expiry controller before the serving app, arms the deadline, waits for acknowledgment, then invokes SDK readiness without generating tokens. Missing acknowledgment fails closed. The serving hook refuses to start vLLM without the armed expiry. The uploaded image is offline for weights; startup cannot silently download another revision.
Stop, recover and interpret the receipt
Cancellation, deadline, eligibility failure, HTTP authentication failure or an
uncertain transport result stops admission without replay. The runner's finally
path stops only the recorded experiment app ID and verifies its state for up to
two minutes. Local process loss leaves the separately armed CPU controller to
stop that same app at its deadline, without calling inference. Network or control
plane failure can still leave cleanup unverified.
For unverified cleanup, use the exact app ID from the receipt:
sh scripts/modal_operator.sh stop ap-YOUR_EXPERIMENT_ID
sh scripts/modal_operator.sh apps
The receipt's recovery_command field gives the same modal_operator.sh stop
command with the exact app ID. Run with the reviewed workspace credentials and
verify the stopped state in that environment; apps lists the
recall-guard-pilot environment. Never stop by reusable name or stop unrelated
apps.
When the experiment app is verified stopped, the runner also stops the armed CPU
expiry controller, so it does not idle until its deadline. If that stop is
unverified, the receipt's lifecycle.expiry_cleanup says so; stop that app by
its ID too. After a run, check that nothing is left running:
sh scripts/modal_operator.sh inventory
It lists apps, volumes and dicts in recall-guard-pilot. Stopped apps cost
nothing. What remains is storage: the weight volume (about 13 GiB) is kept on
purpose until the last planned Modal measurement, then deleted (release-1.0 task
M4.4). The small provenance Dict stays with it. Scale-to-zero does not delete
storage or replace verified shutdown. The recorded storage assumption is USD
0.09/GiB-month; actual billing and retention duration are unknown.
Receipt attempts have one row per physical inference intent/outcome; position
is a zero-based frozen prompt index. Lifecycle/control rows are separate.
For new failures, read the legacy error type together with error_stage and
diagnostics. Stages distinguish budget preflight, cache inventory, CPU controller
deployment, model deployment, expiry arming, proxy denial, readiness, endpoint
checks and provenance. Each diagnostic contains a bounded sanitized message and
up to twelve filename/function/line-number frames; chained errors are bounded to
four type/message records. No source lines or locals are captured. Inference
attempt diagnostics contain type and frame metadata only, with the existing
provider failure reason and HTTP status; response bodies and generated text are
excluded. The first failure remains authoritative when cleanup or final
provenance collection also fails; read later diagnostics and cleanup state too.
Inference ancestry and provider response-error branches remain opaque through
later cleanup exception chains, including their nested causes.
Redaction uses nonempty credential values already present in the executing child
process, including proxy bearer components, and never opens .env. Default
planning does not depend on credentials. Old receipts are unchanged and
cannot recover previously omitted exception messages.
Token positions in the adapter are generated-token positions, alternatives align at that same position, and probabilities use natural logarithms. Top-five evidence is partial, never a renormalized full-vocabulary distribution. GPT-OSS reasoning and final-answer text must align as returned; stripping or retokenizing to force acceptance is forbidden. Raw output and token arrays are not published.
Read evidence_status, environment_status, calibration, cleanup and
cost_report separately. Usable evidence requires nonempty aligned logprobs and
five alternatives. Runtime, quantization, tokenizer/template, model, context or
score-semantics changes require fresh capability checks and calibration
revalidation. Configured A100 resources are not observed hardware. Unknown/drifted
provenance cannot establish a calibration match. The pilot performs no calibration.
The cost contract distinguishes cold startup, inference wall time, failed attempts, usable measurements, estimates and observed charges. Eligibility is excluded from the usable measurement denominator. Unknown cost or zero usable measurements gives null cost per usable measurement, never a claimed zero. Later billing is appended without rewriting attempts or frozen rates.
Observed token evidence establishes endpoint feasibility. A held-out AUC would measure discrimination; calibration and mitigation efficacy require their own experiments. Jane Street's approach motivates the separate divergence work (source checked 2026-11-06). This provider extension does not establish generation control or successful divergence decoding. Frontier APIs without logprobs stay on the separate completion-only workflow, with no silent fallback here.