What sampling determinism invariants must survive cross-region inference routing?
**Date of Record:** 2026 October 27 **Scope:** Applies when an agentic session relies on deterministic sampling (fixed seed, temperature=0, or deterministic decoding) and routes inference across multiple regions or inference providers, and the sampling output can diverge across regions due to different RNG state, model versions, or hardware. Does not apply to sessions using strictly probabilistic sampling (temperature > 0) where determinism is not expected, or sessions with all inference in a single region.
Core Distinction
The separation between **deterministic sampling policy** (the configuration says "deterministic") and **deterministic sampling guarantee** (the actual outputs match across all routes). Relying on policy creates the **Cross-Region RNG Divergence**: the session requests deterministic sampling, but different regions have different RNG seed initialization, floating-point precision, or model micro-versions, and the "deterministic" outputs diverge silently.
What Was Observed
In cross-region agent architectures, failing to verify sampling determinism produces three primary failure modes:
- **Silent Output Divergence:** The same prompt produces slightly different outputs in region A vs. region B, and the session's downstream comparison logic sees the divergence as noise rather than a real difference.
- **Cache Miss Cascade:** The session's cache key assumes deterministic output, but region B produces different output, causing cache misses that trigger re-inference and cost overruns.
- **Reproducibility Break:** A bug report says "same prompt produces output X," but the developer running from their region gets output Y, wasting debugging cycles.
Recorded Elements
- **`sampling_configuration_signature`:** The exact sampling parameters (seed, temperature, top_p, top_k), signed by the session and sent to all regions.
- **`regional_rng_fingerprint_receipt`:** Per-region, a cryptographic fingerprint of the region's RNG initialization and model micro-version, allowing the session to detect which regions have compatible sampling.
- **`cross_region_determinism_test_receipt`:** A periodic test where the same prompt is sent to all active regions, and their outputs are compared, with a cryptographic record of the pass/fail status.
- **`sampling_divergence_attribution_receipt`:** When divergence is detected, the exact regional attributes (RNG version, model version, hardware) that explain the divergence.
Condition of Validity
* **Applies when:** The session expects deterministic sampling, inference can route across regions, and reproducibility matters for cache, debugging, or audits. * **Does not apply when:** The session uses probabilistic sampling (temperature > 0), or all inference is in a single region with a single model version.
Decision Boundary
- **Does the session require deterministic sampling?** If no, standard sampling applies. If yes, proceed.
- **Has the `cross_region_determinism_test_receipt` been validated recently (within acceptable freshness)?** If no, the session cannot guarantee determinism. It must re-run the test.
- **Does the test show divergence across regions?** If yes, the session must restrict routing to compatible regions or accept divergence with explicit acknowledgment.
- **Conversely, when can the session use cross-region inference without determinism verification?** Only when the session's task is tolerant to sampling variance, or all inference is forced to a single pinned region.
Operational Effect
- **Divergence Detection:** Periodic tests reveal cross-region sampling divergence before it affects downstream logic.
- **Cache Integrity:** Ensures cache keys based on deterministic output remain valid.
- **Reproducibility:** Provides the data needed to reproduce bugs across regions.
from dataclasses import dataclass
from enum import Enum, auto
import hashlib
import json
class SamplingVerdict(Enum):
NON_DETERMINISTIC = auto()
DETERMINISM_VERIFIED = auto()
DIVERGENCE_DETECTED = auto()
TEST_STALE = auto()
@dataclass(frozen=True)
class SamplingState:
requires_determinism: bool
determinism_test_epoch: float
current_epoch: float
divergent_regions: tuple[str, ...]
all_regions_checked: bool
@dataclass(frozen=True)
class SamplingPolicy:
max_test_staleness_sec: float
@dataclass(frozen=True)
class SamplingManifest:
verdict: SamplingVerdict
directive: str
manifest_digest: str
class SamplingDeterminismGuard:
@staticmethod
def _hash(data: str) -> str:
return hashlib.sha256(data.encode("utf-8")).hexdigest()
@classmethod
def evaluate_determinism(
cls, state: SamplingState, policy: SamplingPolicy
) -> SamplingManifest:
# Gate 1: No determinism required
if not state.requires_determinism:
digest = cls._hash(json.dumps({
"determinism": "NOT_REQUIRED"
}, sort_keys=True))
return SamplingManifest(
verdict=SamplingVerdict.NON_DETERMINISTIC,
directive="PROCEED: Sampling is probabilistic by policy.",
manifest_digest=digest
)
# Gate 2: Test freshness
age = state.current_epoch - state.determinism_test_epoch
if age > policy.max_test_staleness_sec:
return SamplingManifest(
verdict=SamplingVerdict.TEST_STALE,
directive=f"HALT: Determinism test {age:.0f}s stale > {policy.max_test_staleness_sec:.0f}s. Re-test.",
manifest_digest=cls._hash(f"STALE:{age:.0f}")
)
# Gate 3: All regions checked
if not state.all_regions_checked:
return SamplingManifest(
verdict=SamplingVerdict.TEST_STALE,
directive="HALT: Determinism test did not cover all regions.",
manifest_digest=cls._hash("PARTIAL_TEST")
)
# Gate 4: Divergence
if state.divergent_regions:
return SamplingManifest(
verdict=SamplingVerdict.DIVERGENCE_DETECTED,
directive=f"HALT: Divergence in regions {sorted(state.divergent_regions)}.",
manifest_digest=cls._hash(f"DIVERGENT:{len(state.divergent_regions)}")
)
# Gate 5: Verified
digest = cls._hash(json.dumps({
"test_epoch": f"{state.determinism_test_epoch:.0f}",
"age": f"{age:.0f}",
"regions_checked": "ALL"
}, sort_keys=True))
return SamplingManifest(
verdict=SamplingVerdict.DETERMINISM_VERIFIED,
directive=f"PROCEED: Cross-region determinism verified {age:.0f}s ago.",
manifest_digest=digest
)