﻿# How can Python hash randomization change benchmark worker assignment?

A practical investigation of how can Python hash randomization change benchmark worker assignment?, with explicit observations, control cases and evidence limits.

Author: Retrivium team
Updated: 2026-11-06
Canonical URL: https://retrivium.ai/journal/field-bench-python-hash-worker-assignment/
Language: en

## The comparison being tested

A replay client assigns a conversation to a worker using the built-in hash of its text key and the worker count. Repeated runs use the same trace and random sampling seed, yet conversations reach different workers. Cache locality and per-worker request mix can change before either candidate executes. The hidden experimental variable is routing identity, not the selected model’s generation randomness.

## The confounding mechanism

Python documents salted hashes for strings and bytes: their values remain stable within one process but are not predictable across repeated interpreter invocations by default. The interpreter’s hash-seed controls are distinct from NumPy or model sampling seeds. Setting an ordinary application variable after startup does not retroactively initialize the interpreter’s hashing policy. Invocation options can also change whether environment variables are honored.

## Fix the experimental contract

Define whether assignment must be stable across runs, processes and worker-count changes. Preserve the exact key encoding, worker population and assignment algorithm. For a fixed replay, a materialized item-to-worker map may be sufficient. A durable routing design may require a separately specified stable function. Do not mistake built-in hash values for portable persistent identifiers or evidence that unrelated runtimes agree.

## A step-by-step comparison

First export a safe assignment manifest for the same trace across fresh interpreter invocations. Compare conversation-to-worker mappings before making performance requests. Then repeat under the chosen explicitly controlled routing contract. Include a control with unchanged request bytes but a different interpreter hash initialization, checking whether the audit detects assignment changes. Keep model sampling settings fixed so their effects do not obscure the routing test.

## Evidence required for the result

Retain the effective interpreter invocation, version, worker count and mapping digest alongside workload identity. Report class distributions and cache-affinity changes by worker, not just total request counts. Acceptance means the comparison either preserves the declared mapping or explicitly treats remapping as a varied factor. A matching global request histogram cannot prove equivalent locality, queue state or session grouping inside each worker.

## Interpretation and limits

A fixed mapping does not guarantee balanced load, safe tenant isolation or identical outputs. Different worker counts may intentionally require redistribution, which needs another declared comparison. Nor is one interpreter seed a universal cross-version hash specification. This protocol proposes a routing reproducibility check; it does not claim any measured cache benefit. Its scope is keeping an accidental hash-policy change from masquerading as candidate performance.

## Primary references and related reading

A reproducible request trace does not fix worker assignment when routing uses process-local salted hashes. [Python hash randomization environment](https://docs.python.org/3/using/cmdline.html); [Python object hash contract](https://docs.python.org/3/reference/datamodel.html).

The proposed investigation of python hash worker assignment is not an executed deployment benchmark. Related reading: [Reproducible inference stacks: preserving a GPU pilot’s result](/journal/software-stack-reproducibility/); [Prefix caching: when repeated context helps a GPU pool](/journal/prefix-caching/).
