Runtime
Pinned Source-Framework Oracle and Layerwise First-Divergence Forensics
Report summary
The validation of browser-local, hardware-accelerated machine learning engines requires absolute mathematical rigor to guarantee that localized optimizations do not silently corrupt the inferential logic of a neural network. This report defines an exhaustive, layer-wise numerical forensics laborator
Key topics
- Runtime
- AI
- .NET
- Angular
- Python
- Rust
- Privacy
- Semantic Systems
Research provenance
For citation, use the report title and canonical URL. Archival presence does not establish authorship or promote report statements into portfolio evidence.
This page renders the archived Markdown as safe, formatted HTML. It is background research and does not become a portfolio claim without evidence review.
Full report
On this page
1. Executive Oracle Recommendation and Assumptions
The validation of browser-local, hardware-accelerated machine learning engines requires absolute mathematical rigor to guarantee that localized optimizations do not silently corrupt the inferential logic of a neural network. This report defines an exhaustive, layer-wise numerical forensics laboratory to evaluate the execution fidelity of a clean-slate, prelaunch product, TinyRustLM. The objective is to establish an unbroken, cryptographically verifiable proof chain connecting a hermetic source-framework oracle to a converted scalar-native reference, subsequently to optimized native kernels, and finally to browser-WebAssembly (WASM) execution. The reference model is strictly pinned to the Qwen/Qwen3-0.6B architecture at the immutable revision c1899de289a04d12100db370d81485cdf75e47ca1. This specific artifact represents a dense, decoder-only causal language model comprising 28 hidden layers, a hidden dimension of 1024, an intermediate size of 3072, 16 query attention heads, and 2 key/value heads implementing Grouped-Query Attention (GQA)4. It utilizes SwiGLU activation functions, Pre-Root Mean Square Normalization (RMSNorm), and Rotary Position Embeddings (RoPE)4. The vocabulary size is explicitly declared as 151,936 tokens6. The methodology operates under strict project-supplied constraints. TinyRustLM is defined as a single-path execution engine lacking legacy runtimes, compatibility modes, fallback backends, hidden response repairs, or best-of-N sampling arrays. Because the product utilizes a publisher-exact tokenizer, chat template, and sampling identity, the forensic laboratory must stringently differentiate between semantic-layer misconfigurations (such as template whitespace discrepancies) and structural matrix-kernel defects in the WASM implementation. The baseline depends exclusively on public checkpoint files—config.json, tokenizer.json, and model.safetensors—fetched precisely from the pinned commit hash6. No assumptions are permitted regarding transitive confidence, benchmark familiarity, or heuristic end-to-end evaluations. Every transition across the compilation and execution stack requires explicit, layer-wise evidence of numerical equivalence. Final text comparison is inherently rejected as an evaluation metric, as it obscures catastrophic intermediate tensor collapse beneath the discrete argmax function of token selection.
2. Hermetic Source-Framework Closure
Establishing a flawless baseline necessitates a hermetic source-framework closure. An unpinned PyTorch environment is susceptible to nondeterministic execution paths, dynamic kernel selection, floating-point accumulation variations, and compiler-level optimizations that alter tensor topology. The oracle must be cryptographically locked at the system, framework, and algorithmic levels to facilitate exact offline replay. The Python environment must be sealed utilizing a strict dependency lockfile defining specific, immutable wheel closures for the runtime stack. Transitive dependency resolution must be disabled, forcing the installation of mathematically identical binaries across all validation machines. The required software stack includes torch, transformers (pinned to a version preceding problematic monkey-patching regressions, e.g., strictly auditing conversion\_mapping.py), tokenizers, and safetensors9. PyTorch inherently leverages nondeterministic algorithms for certain tensor operations, particularly those accelerated by cuDNN or cuBLAS, to maximize hardware throughput. The oracle must explicitly disable these heuristics to ensure bit-for-bit reproducibility across multiple evaluation runs on identical hardware. The following environmental and runtime constraints are mandatory:
| Configuration Directive | Implementation Layer | Enforcement Rationale |
|---|---|---|
| CUBLAS\_WORKSPACE\_CONFIG=:4096:8 | OS Environment | Forces cuBLAS matrix multiplication kernels to utilize a strictly deterministic memory workspace, preventing atomic accumulation races10. |
| torch.use\_deterministic\_algorithms(True) | PyTorch Runtime | Commands the execution engine to select deterministic variants of operations (e.g., aggregations, scatter-adds). Raises a RuntimeError if a deterministic kernel is unavailable13. |
| torch.backends.cudnn.benchmark \= False | PyTorch Backend | Disables dynamic kernel autotuning, forcing the framework to use predictable, albeit potentially slower, convolution and matrix operations11. |
The Attention mechanism presents a unique vector for numerical nondeterminism. The scaled\_dot\_product\_attention (SDPA) operation in modern PyTorch automatically routes to FlashAttention, Memory-Efficient Attention, or a standard Math backend based on tensor shapes and hardware capability17. FlashAttention-2 relies on block-wise thread tiling and non-associative atomic additions, producing sub-Unit in the Last Place (ULP) nondeterminism that rapidly accumulates over extended sequence lengths11. To build an irreproachable oracle, the attention backend must be aggressively constrained to the unoptimized C++ Math implementation utilizing the native context manager:
Python with torch.nn.attention.sdpa\_kernel(\[SDPBackend.MATH\]): output \= torch.nn.functional.scaled\_dot\_product\_attention(query, key, value, ...)
The SDPBackend.MATH forces all intermediates to be calculated in standard IEEE 754 single-precision (FP32) without hardware-specific operation reordering, serving as the sole mathematically reproducible baseline for comparative numerical forensics11. Furthermore, the random number generator (RNG) must be seeded universally across random, numpy, and torch domains.
3. Input and Semantic-Layer Separation
Divergence in generated output is frequently misdiagnosed as an arithmetic kernel failure when it actually originates from upstream semantic processing. The data pipeline must be rigidly isolated into four distinct validation strata: Raw Unicode Conversation, Rendered Chat Text, Token Arrays/Masks, and Model Tensor Inputs. The interaction begins with raw Unicode strings. The transition to rendered chat text applies the Jinja template embedded within the tokenizer\_config.json of the pinned Qwen3-0.6B model. Validating this stage ensures that specific conversational framing boundaries are identically constructed in both the Python oracle and the TinyRustLM WASM pipeline. A failure here is a template engine defect, not a tensor math issue. Qwen3 utilizes a Byte-level Byte-Pair Encoding (BPE) tokenizer20. Unlike traditional character-level BPEs, byte-level BPE maps all out-of-vocabulary characters into raw UTF-8 bytes, ensuring an absolute lack of \<unk\> tokens and enabling seamless handling of raw binary data or unformatted code20. Complex Unicode strings—such as Brahmic scripts, emojis, or zero-width joiners—may fallback to multiple byte-tokens per character22. Discrepancies at this layer diagnose fundamental tokenizer defects. For example, edge cases surrounding add\_prefix\_space behaviors, regex-free pre-tokenization steps, or whitespace offset tracking must precisely mirror the standard cl100k or tiktoken behavior implemented in the Hugging Face tokenizers library24. The final semantic layer is the assembly of the input\_ids, attention\_mask, and position\_ids. The position IDs are particularly critical for Rotary Position Embeddings (RoPE). A discrepancy at this layer—such as providing a 1D tensor of IDs versus a 2D tensor with incorrect padding dimensions—will catastrophically alter the embedding retrieval and the positional frequency mapping, manifesting deceptively as a deep-layer attention matrix failure. Comparisons at this boundary definitively isolate context assembly logic from runtime matrix computation.
4. Instrumentation and Capture-Point Design
To execute first-divergence localization, both the PyTorch oracle and the TinyRustLM system must capture the exact intermediate states of the computational graph. Capturing every tensor at every sub-operation is prohibitively expensive in memory and I/O overhead. Strategic, semantically preserved capture nodes must be defined across the 28 Transformer layers.
| Capture Point | Dimensionality | Forensic Diagnostic Value |
|---|---|---|
| Embeddings | [Figure omitted from source export] | Validates token-ID routing and embedding lookup table extraction prior to normalization. |
| Normalized Activations | [Figure omitted from source export] | Captures the output of the Pre-RMSNorm operations. Diagnoses numerical instability in variance calculation or [Figure omitted from source export] addition ([Figure omitted from source export])4. |
| Linear Projections (Q/K/V) | [Figure omitted from source export] | Output of self\_attn.q\_proj, k\_proj, and v\_proj. Validates the foundational [Figure omitted from source export] matrix multiplications28. |
| Rotated Q/K States | [Figure omitted from source export] | Captured immediately following apply\_rotary\_pos\_emb. Validates sinusoidal frequency calculation and interleaved half-rotation mechanics27. |
| Attention Scores / Probs | [Figure omitted from source export] | The pre-softmax and post-softmax matrices. Diagnoses causal masking failures and exponential accumulation anomalies7. |
| Attention Output | [Figure omitted from source export] | Context vectors post-repeat\_kv (broadcasting 2 KV heads to 16 Query heads) and final output projection32. |
| MLP Gates & Outputs | [Figure omitted from source export] | Intermediate states following gate\_proj (SwiGLU activation) and down\_proj. Isolates non-linear activation faults34. |
| Residual States | [Figure omitted from source export] | The accumulating residual stream. Identifies delayed divergence propagating through sequential addition35. |
| Final Logits | [Figure omitted from source export] | Output prior to argmax or nucleus sampling. Provides the ultimate distributional distance mapping. |
Instrumentation must guarantee semantic preservation. In the PyTorch oracle, tensors must be extracted using non-blocking, detached hooks (e.g., tensor.detach().clone().cpu().to(torch.float32)) to prevent unintended autograd synchronization, inplace memory corruption, or precision loss during transfer. For the WASM runtime, capture points must utilize conditionally compiled zero-copy memory views, streaming contiguous byte arrays directly from the heap to the hashing engine to avoid massive memory allocation overhead during inference.
5. Privacy-Preserving Observation Records
Publicly broadcasting raw captured tensors violates the privacy constraints of a prelaunch product, as these tensors inherently encode the user's private prompts, internal system directives, and proprietary chat templates. Therefore, the diagnostic pipeline must rely entirely on content-addressed observation records. Exact-byte hashes transform raw tensors into canonical cryptographic representations. BLAKE3 is the mandatory algorithm for this operation. Operating on a Merkle tree structure and leveraging SIMD instructions, BLAKE3 achieves hashing throughputs exceeding 10,000 MB/s, whereas SHA-256 bottlenecks at approximately 2,300 MB/s36. This extreme speed differential is critical when processing tens of gigabytes of intermediate tensor states per forward pass. The Merkle tree architecture of BLAKE3 inherently facilitates chunked, layer-wise proofs without requiring complete file buffering37. Prior to hashing, tensors must be strictly cast to a canonical IEEE 754 little-endian representation, enforcing standardization of [Figure omitted from source export] to [Figure omitted from source export] and canonicalizing all NaN payloads to a uniform bit pattern, as NaN payloads can vary wildly across x86 and ARM architectures38. Because floating-point arithmetic across dissimilar architectures inevitably produces sub-ULP deviations, strict bit-for-bit hashes will fracture immediately after the first non-trivial math operation. Therefore, bounded numerical summaries must accompany the hashes. These scalar summaries—comprising the minimum, maximum, [Figure omitted from source export] norm, arithmetic mean, and variance of the tensor—are inherently lossy and mathematically irreversible, perfectly masking the original text. They serve as robust, privacy-safe diagnostics for catastrophic layer collapse (e.g., an exploding gradient, activation saturation, or a completely zeroed matrix). For public auditability without prompt leakage, the system implements pseudo-randomly sampled coordinate proofs. A verifiable random function, seeded by a public hash of the execution context, selects 100 specific scalar coordinates from a multi-million element matrix. Publishing these exact coordinates provides rigorous statistical evidence of numerical parity, permitting independent mathematical verification without allowing reconstruction of the original semantic sequence. Exact-byte hashes support exact-match deterministic debugging, while bounded summaries and coordinate proofs support public auditing.
6. Metrics and Preregistered Threshold Derivation
Declaring mathematical equivalence across computing backends requires defining the precise boundaries of acceptable numerical drift. A global, arbitrary tolerance (e.g., declaring [Figure omitted from source export] as "close enough") selected retroactively after observing a preferred model's output is fundamentally unscientific and often masks critical, compounding accumulation errors40. Thresholds must be preregistered, analytically derived, and specific to the tensor type.
Evaluation Metrics by Tensor Type
1. Unit in the Last Place (ULP): Measures the absolute distance between two adjacent floating-point numbers. For FP32, the machine epsilon is [Figure omitted from source export] ([Figure omitted from source export]); for bfloat16, it is [Figure omitted from source export] ([Figure omitted from source export])41. Measuring ULP divergence is critical for internal linear projections, cleanly separating unavoidable hardware-level quantization noise from fundamental arithmetic algorithmic flaws.
2. Maximum Coordinate Error ([Figure omitted from source export] Norm): The absolute maximum difference between any two corresponding elements in a tensor. It detects isolated coordinate failures (e.g., a single NaN or Infinity propagating through an activation gate).
3. Normalized Root Mean Square Error (NRMSE): Provides a global magnitude of tensor divergence, normalized against the variance of the ground-truth tensor. Essential for evaluating the health of the residual stream over time.
4. Cosine Similarity: Evaluates the directional alignment of high-dimensional vectors, crucial for attention contexts where angular distance governs token selection. However, cosine similarity mathematically masks sign disagreements in near-zero vectors, demanding it be strictly paired with absolute error checks43.
5. Jensen-Shannon Divergence (JSD): Applied exclusively to the final probability logits. Unlike Kullback-Leibler (KL) divergence, which is asymmetric and prone to numerical instability (yielding infinity) when probabilities approach zero, JSD is bounded between [Figure omitted from source export], symmetric, and mathematically smooth44. It precisely quantifies the distributional distance between the PyTorch output and the WASM output.
6. Greedy-Token Identity / Top-K Set Overlap: Tracks the final discrete output. Highly limited as a diagnostic metric, as severe internal numerical divergence can still produce the exact same top token if the logit margin is wide, creating a false sense of security.
Principled Threshold Derivation
The threshold for acceptable error in dot products is derived from Wilkinson's error bounds for floating-point arithmetic46. For an inner product of length [Figure omitted from source export], the forward error is strictly bounded by [Figure omitted from source export], where [Figure omitted from source export] is the unit roundoff48. In Qwen3-0.6B, the matrix multiplications in the Multi-Layer Perceptron (MLP) feature an inner dimension of 1024, projecting up to 3072\. Therefore, the maximum theoretical accumulation error for a single FP32 dot product is mathematically boundable. The preregistered threshold for any linear projection is strictly defined as the Wilkinson bound applied to the specific tensor depth, adjusted for the accumulator precision. If the WASM target relies on Fused Multiply-Add (FMA), the error bound is mathematically tighter, as FMA executes the calculation with a single rounding step rather than two49. Errors exceeding these deterministic bounds definitively indicate a flawed implementation—such as incorrect tiling, memory misalignment, or overflow—not acceptable floating-point drift.
7. First-Divergence Localization Algorithm
When the Jensen-Shannon Divergence of the final logits exceeds the preregistered threshold, the diagnostic laboratory initiates a deterministic, staged localization algorithm to isolate the exact sub-operation responsible. Because large language model architectures are deeply sequential, a subtle error in layer 2 will catastrophically cascade into layer 28, making every subsequent tensor appear profoundly defective35. The localization utilizes a precise, stage-gated binary-search bisection:
1. Stage 1: Layer-wise Bisection. The orchestrator inspects the residual stream outputs at layer 14\. If the Maximum Coordinate Error is below the ULP-derived threshold, the defect lies in layers 15 through 28\. If it exceeds the threshold, the defect originated in layers 1 through 14\. This process continues logarithmically ([Figure omitted from source export]) until the exact boundary layer of initial divergence is identified.
2. Stage 2: Sub-Operation Bisection. Within the isolated defective layer, the bisection shifts to structural sub-operations. The orchestrator isolates the Pre-RMSNorm output, the QKV projections, the RoPE transformation, the attention context output, and the SwiGLU MLP.
3. Stage 3: Token Position and Head Isolation. If the attention output is flagged, the system drills into divergence on a per-head and per-token basis. For instance, if only tokens with sequence indices [Figure omitted from source export] exhibit divergence, the defect is definitively isolated to a RoPE dynamic scaling fault or a static KV-cache boundary violation.
4. Stage 4: Tensor Chunking. For massive projection matrices, the BLAKE3 Merkle tree hash allows the system to isolate the exact memory chunk (e.g., a specific [Figure omitted from source export] tile of the MLP gate\_proj matrix) that produced the arithmetic violation, mapping the failure directly to a specific hardware thread or SIMD lane37.
8. Quantization-Versus-Kernel Fault Isolation
Deploying TinyRustLM to a browser environment invariably requires quantization to accommodate strict WebAssembly memory constraints and client-side bandwidth limits. It is imperative to methodically separate expected algorithmic degradation (quantization error) from execution engine defects (flawed WASM SIMD integer kernels)34. To isolate these distinct vectors, a tiered "reconstructed-weight oracle" methodology is employed:
1. Float Reconstructed-Weight Oracle: The base FP32/BF16 weights of the pinned Qwen3 model are numerically quantized using the exact scheme intended for the browser (e.g., INT8 symmetric group quantization). Immediately, these weights are mathematically dequantized back into FP32 format within the Python environment. This yields a set of degraded, yet high-precision, weights.
2. Oracle Execution: The PyTorch oracle executes the forward pass using these dequantized, reconstructed weights. This establishes the theoretical upper bound of accuracy for the chosen quantization scheme, isolating the pure information loss.
3. Quantized Scalar Oracle: A pure-Rust, scalar (non-SIMD) implementation executes the model using the actual integer weights and integer arithmetic. This validates the bitwise logic of the dequantization multipliers and zero-point shifts.
4. Packed-Kernel Comparison: Finally, the highly optimized WASM SIMD implementation runs. The resulting tensors are compared against the Quantized Scalar Oracle.
If the native WASM execution diverges from the scalar oracle beyond the strictly calculated accumulation bounds for integer math, the defect resides within the kernel implementation—typically an integer overflow in the accumulator, flawed bitwise dispatch, or improper memory alignment. If they perfectly match, any degradation in end-to-end generation quality is firmly attributed to the inherent entropy loss of the quantization algorithm itself, clearing the implementation of fault.
9. Determinism and Stochastic Controls
Achieving exact numerical reproducibility across vastly different computing architectures requires rigorous control of nondeterminism, addressing factors ranging from high-level thread scheduling to low-level silicon floating-point specifications.
WASM SIMD and relaxed_madd
WebAssembly introduces specific determinism challenges via the Relaxed SIMD standard. Opcodes such as f32x4.relaxed\_madd (Fused Multiply-Add) intentionally permit architectural nondeterminism to leverage host hardware speed49. On hardware that natively supports FMA (e.g., modern ARM64 or AVX2 x86\_64), this instruction performs the multiplication and addition with a single rounding step, yielding higher accuracy. On hardware lacking native FMA, it may fallback to separate multiply and add instructions, introducing a secondary rounding error49. The laboratory must stringently characterize this divergence. The WASM promotion gates cannot demand strict bit-for-bit parity across different browser runtimes if relaxed\_madd is employed. Instead, the testing suite analytically validates that the output tensors fall perfectly within the mathematical union of the single-rounded and double-rounded possibility space.
Denormals and Flush-to-Zero (FTZ)
The IEEE 754-2019 standard defines subnormal (denormal) numbers to allow gradual underflow, preventing abrupt drops to zero39. Handling denormals is notoriously slow on many hardware architectures, prompting compilers and runtimes to employ a "Flush-to-Zero" (FTZ) or "Denormals-Are-Zero" (DAZ) policy50. Differences in FTZ policies between the PyTorch Oracle (which may preserve denormals on the CPU but flush them aggressively on certain CUDA atomic operations50) and the V8/SpiderMonkey browser WASM engines will produce microscopic sign and magnitude deviations. The diagnostic lab forces an explicit, declared FTZ policy for both the PyTorch baseline and the WASM runtime to align their lowest-level floating-point behaviors.
Thread Reductions and Parallelism
In multi-threaded environments, floating-point addition is fundamentally non-associative; [Figure omitted from source export] due to intermediate rounding steps50. When attention scores or MLP outputs are reduced across multiple threads or WASM Web Workers, the accumulation order can vary wildly based on OS thread scheduling. The forensic laboratory requires that parallel reductions utilize fixed-stride, deterministic chunking or deterministic atomic trees, enforcing a strict hierarchical reduction order that exactly mirrors the scalar-native reference, completely removing thread-scheduling as a variable.
10. Sealed Diagnostic and Adversarial Suite
To systematically trigger edge-case defects without exposing actual proprietary product prompts or internal routing instructions, a sealed suite of diagnostic inputs is executed against the pinned Qwen3-0.6B oracle. Each case is strictly bound by a private BLAKE3 hash, a generator version, an isolated RNG seed, and a specific exclusion set.
| Diagnostic Case | Verification Objective | Theoretical Stress Point |
|---|---|---|
| Empty/Minimal Framing | Initialization and basic connectivity. | Ensures template application handles null or whitespace-only inputs without crashing or indexing out of bounds. |
| Complex Unicode & Emojis | Tokenizer boundaries and byte-fallback. | Verifies Brahmic script, emojis, and irregular byte sequences do not trigger BPE buffer overflows or regex failures20. |
| Long Prefill (\>4096 tokens) | RoPE dynamic scaling and memory allocation. | Stresses large position\_ids, the boundaries of the pre-allocated KV cache, and ring-buffer implementations5. |
| Repeated Token Sequences | Attention matrix uniformity and saturation. | Tests if the attention softmax mathematically saturates or handles high-entropy probability spikes safely without producing NaNs. |
| Boundary Context | Multi-turn cache reuse. | Triggers execution across chunked context windows, validating that persistent mHC (multi-Head Cache) states are correctly preserved and updated35. |
| Cancellation / Interruption | Thread and memory safety. | Verifies that aborting an inference request mid-generation cleanly deallocates WASM memory without corrupting the state of subsequent requests. |
| Adversarial Logits | Arithmetic overflow under massive values. | Inputs specifically designed to push SwiGLU activations to their upper numerical limits, testing FTZ handling and NaN/Inf propagation55. |
11. Immutable Failure-to-Regression Workflow
When the first-divergence algorithm flags a failure, the engineering investigation follows a strict Test-Driven Development (TDD) workflow designed exclusively for numerical forensics.
1. Preservation of Evidence: The raw, private divergence data (the exact user prompt or the precise intermediate tensor) is cryptographically hashed, and the bounded metrics (Max Error, JSD) are logged. The raw private tensor is never committed to public repositories or shared across unsecured channels.
2. Minimal Generic Regression: The validation engineer synthesizes a minimal, generic unit test that replicates the exact arithmetic failure without utilizing the private input. For instance, if an MLP gate\_proj failed due to a SIMD alignment issue, the regression test isolates a generic [Figure omitted from source export] randomized, non-proprietary float matrix multiplication that triggers the identical sub-ULP accumulator fault.
3. Targeted Remediation: The underlying cause is addressed (e.g., fixing a byte-alignment issue in a WASM memory view or correcting a GQA repeat\_kv dimension mismatch32).
4. Partial Invalidation Rerun: Only the pipeline phases explicitly invalidated by the fix are rerun, saving vast amounts of compute time.
5. Immutability: A previous successful comparison record is never overwritten or averaged away. Each run creates a cryptographic append-only ledger, definitively proving that a specific version of the WASM binary conforms to the PyTorch oracle on a specific set of diagnostic vectors.
12. Tiered Numerical Promotion Gates
The progression from PyTorch source to optimized browser execution must pass through three objective promotion gates. Transit through a gate requires passing predefined, algorithmically verified mathematical thresholds. Subjective claims or "benchmark familiarity" (e.g., stating that the model looks like it generates coherent text) are expressly prohibited.
Gate 1: Source-Framework to Scalar-Native Reference
- Target: Comparing the PyTorch SDPBackend.MATH execution against a single-threaded, pure-scalar (non-SIMD) Rust implementation of the model.
- Allowed Claims: Strict, bit-for-bit mathematical equivalence for all integer operations; exact ULP-bounded conformity based on standard IEEE-754 properties for floating-point operations.
- Prohibited Claims: Real-world performance viability.
- Residual Uncertainty: The system is completely unoptimized, incredibly slow, and untestable at consumer scale.
Gate 2: Scalar-Native to Optimized Native
- Target: Comparing the Scalar-Native reference against a multi-threaded, SIMD-accelerated (e.g., AVX2/NEON) Rust binary execution.
- Allowed Claims: Execution maintains sub-ULP accuracy under vectorized instructions and multi-threaded hierarchical reductions. The quantization dequantization scheme matches the float reconstructed-weight oracle.
- Prohibited Claims: Proof of browser compatibility or WebAssembly memory safety.
- Residual Uncertainty: The execution is tied to native OS threading and memory management, which differ vastly from the sandboxed browser environment.
Gate 3: Optimized Native to Browser-WASM
- Target: Comparing the Optimized Native execution against execution within the V8/SpiderMonkey WASM runtimes.
- Allowed Claims: Safe, stable deployment within strict Jensen-Shannon Divergence thresholds on the final logits. WASM memory alignment and SIMD (including relaxed\_madd) handle Qwen3's specific SwiGLU and GQA tensor topologies correctly without heap corruption.
- Prohibited Claims: Absolute uniformity across all consumer devices.
- Residual Uncertainty: Extreme edge-case variation dependent on the client's underlying CPU architecture (e.g., host FMA support altering the relaxed SIMD rounding step) remains present but statistically bound.
13. Unknowns Requiring Private Execution
Despite a mathematically exhaustive public forensics laboratory, certain critical execution properties fundamentally cannot be proven without executing on private, local data. Publicly, the laboratory can cryptographically prove that the matrix multiplication kernels, the Byte-level BPE tokenizer, and the RoPE calculations are mathematically sound within bounded thresholds. However, the exact timing profiles, multi-level cache latency, and thermal throttling behavior of the browser's Just-In-Time (JIT) compiler running the WASM payload on proprietary edge devices cannot be extracted into the public domain. Furthermore, while the bounded numerical summaries prove that the model does not suffer from catastrophic matrix collapse, the actual semantic validity of the responses to highly specific, adversarial, or deeply context-dependent private user prompts can only be evaluated locally, securely behind the privacy wall of the end-user's browser. The numerical forensic laboratory establishes the unshakeable foundation of mathematical trust, but the final experiential validation remains the exclusive domain of the private execution environment.
14. Annotated Primary-Source Bibliography
The following primary sources and pinned revisions inform the strict constraints and mathematical boundaries of this validation framework:
1. 4 Hugging Face Optimum Internal Testing (c1899de289a04d12100db370d81485cdf75e47ca): Directly confirms the architectural specifications of the Qwen3-0.6B pinned revision, validating the 28 hidden layers, 1024 hidden size, and exact GQA topology required for the oracle.
2. 6 DaoyuanLi2816/mini-verl & Qwen2.5 Documentation: Confirms the vocabulary size of 151,936 for the Qwen architecture, crucial for defining the final logit tensor dimensionality and JSD bounds.
3. 10 PyTorch Reproducibility Documentation: Establishes the authoritative guidelines for enforcing strict numerical determinism in PyTorch, mandating torch.use\_deterministic\_algorithms(True) and the configuration of the CUBLAS\_WORKSPACE\_CONFIG environment variable.
4. 49 WebAssembly Relaxed SIMD Specification (W3C): Details the introduction and behavior of non-deterministic floating-point instructions in WASM, specifically f32x4.relaxed\_madd, outlining the architectural divergence between FMA single-rounding and discrete double-rounding.
5. 20 Tokenization in LLMs & BrahmicTokenizer-131K Research: Analyzes the mechanics of Byte-level BPE, highlighting failure modes, regex-free edge cases, and the multi-token fallback behavior for complex Unicode and non-Latin scripts.
6. 36 BLAKE3 vs SHA-256 Performance Benchmarks & Cryptography: Provides empirical evidence for selecting BLAKE3 for tensor hashing, citing its SIMD optimizations, Merkle tree chunking capabilities, and superior throughput over legacy algorithms.
7. 11 PyTorch Scaled Dot Product Attention (SDPA) Source: Documents the routing logic of PyTorch's attention mechanisms and the inherent floating-point accumulation deviations present in FlashAttention, justifying the strict constraint to SDPBackend.MATH for the oracle.
8. 27 Qwen3 & Transformers Source Code (modeling\_qwen3.py): Defines the exact implementation of Rotary Position Embeddings (RoPE), including the interleaved half-rotation mechanics (apply\_rotary\_pos\_emb) that must be flawlessly mirrored in the WASM kernels.
9. 32 Grouped-Query Attention Implementations: Outlines the structural memory requirements of GQA and the mathematical necessity of the repeat\_kv function to broadcast key and value matrices across query heads.
10. 39 IEEE 754-2019 Standard for Floating-Point Arithmetic: The foundational mathematical text defining floating-point representation, Machine Epsilon, rounding modes, NaN canonicalization, and the handling of subnormal values via Flush-to-Zero (FTZ) policies.
11. 43 Information Theory & Numerical Divergence (Koulanurag, et al.): Provides the mathematical justification for utilizing Jensen-Shannon Divergence over Kullback-Leibler Divergence for comparing logit distributions, and highlights the limitations of cosine similarity in detecting sign disagreements.
12. 46 Wilkinson's Error Analysis for Floating-Point Computations: Establishes the theoretical foundation for bounding accumulation errors in matrix inner products, providing the rigorous formula ([Figure omitted from source export]) used to preregister acceptance thresholds.
Works cited
1. vhallac/qwen3-0.6b-rope-recal-1b · Hugging Face, https://huggingface.co/vhallac/qwen3-0.6b-rope-recal-1b
2. hashformers/benchmarks/qwen/README.md at master \- Fastly, https://ithub.global.ssl.fastly.net/ruanchaves/hashformers/blob/master/benchmarks/qwen/README.md
3. Cryptanalytic Extraction of Isolated Bias-Free GLU Feed-Forward, https://arxiv.org/pdf/2608.06631
4. neuronxcc-2.19.8089.0+8ab9f450/0\_REGISTRY/0.3.1.dev3/qwen3, https://huggingface.co/optimum-internal-testing/neuron-testing-cache/blob/9899dc8169d76f155bbde940d03d9a5a086d70dc/neuronxcc-2.19.8089.0%2B8ab9f450/0\_REGISTRY/0.3.1.dev3/qwen3/Qwen/Qwen3-0.6B/d8be6db6f1d1a6b128d2.json
5. Qyrou/Vega-1-65m-exp-base \- Hugging Face, https://huggingface.co/Qyrou/Vega-1-65m-exp-base
6. mini-verl/docs/reproducibility.md at main · DaoyuanLi2816/mini-verl, https://ithub.global.ssl.fastly.net/DaoyuanLi2816/mini-verl/blob/main/docs/reproducibility.md
7. Chronicals: A High-Performance Framework for LLM Fine-Tuning, https://arxiv.org/html/2601.02609v1
8. vllm-cpp \- crates.io: Rust Package Registry, https://crates.io/crates/vllm-cpp
9. Qwen3.5: DeepSpeed ZeRO-3 fails to load weights for ... \- GitHub, https://github.com/huggingface/transformers/issues/45313
10. transformer.ipynb \- Colab, https://colab.research.google.com/github/jaspock/me/blob/main/docs/materials/transformers/assets/notebooks/transformer.ipynb
11. Optimizing PyTorch Inference Without Sacrificing Determinism, https://deveshshetty.com/blog/torch-compile-determinism/
12. Reproducibility not possible despite following PyTorch guidelines, https://discuss.pytorch.org/t/reproducibility-not-possible-despite-following-pytorch-guidelines/155793
13. torch.use\_deterministic\_algorithms — PyTorch 2.13 documentation, https://docs.pytorch.org/docs/stable/generated/torch.use\_deterministic\_algorithms.html
14. torch.use\_deterministic\_algorithms — PyTorch master documentation, https://alband.github.io/doc\_view/generated/torch.use\_deterministic\_algorithms.html
15. Interlude: Getting reproducible training results with Fast.ai \+ PyTorch, https://dronelab.dev/posts/getting-reproducible-results/
16. Deterministic Training and Reproducibility — Tao Toolkit, https://docs.nvidia.com/tao/tao-toolkit/latest/text/deterministic\_training.html
17. torch.nn.functional.scaled\_dot\_product\_attention — PyTorch 2.13, https://docs.pytorch.org/docs/stable/generated/torch.nn.functional.scaled\_dot\_product\_attention.html
18. Inconsistent output between flash attention and eager, https://discuss.huggingface.co/t/inconsistent-output-between-flash-attention-and-eager/170448
19. Why does NVIDIA LocateAnything-3B only produce valid output with, https://stackoverflow.com/questions/79981714/why-does-nvidia-locateanything-3b-only-produce-valid-output-with-torch-2-7-0
20. Chapter 5: Tokens, vocabularies, and the tokenizer is the bug, https://www.kunwar.page/chapter/005-tokens-vocabularies-and-the-tokenizer-is-the-bug
21. Tokenization in Large Language Models (LLMs) \- ingoampt, https://ingoampt.com/tokenization-in-large-language-models-llms/
22. BPE Stays on SCRIPT \- OpenReview, https://openreview.net/pdf?id=AO78CqwaUO
23. BrahmicTokenizer-131K: An Indic-Capable Drop-In Replacement for, https://arxiv.org/html/2605.29379v1
24. I'm training a tokenizer and model from scratch — how do I prepare, https://discuss.huggingface.co/t/i-m-training-a-tokenizer-and-model-from-scratch-how-do-i-prepare-my-dataset-and-set-the-correct-tokenizer-parameters/172131
25. Peek2: Regex-free Byte-level Byte-Pair Encoding Pretokenizer for, https://www.researchgate.net/publication/399614199\_Peek2\_Regex-free\_Byte-level\_Byte-Pair\_Encoding\_Pretokenizer\_for\_LLM\_Inference\_on\_Edge\_Devices
26. FiX: Introducing Fine-grained Forget Gate into Softmax Attention, https://openreview.net/pdf?id=WsNpCXq6SG
27. Qwen3 from scratch — Nouman Memon, https://n03an.me/scratch/qwen3.html
28. model.safetensors.index.json · ckaskr/qwen-3b-brain-v1 at main, https://huggingface.co/ckaskr/qwen-3b-brain-v1/blob/main/model.safetensors.index.json
29. Megatron Bridge Conversion Technical Details, https://docs.nvidia.com/nemo/megatron-bridge/0.2.0/bridge-tech-details.html
30. 1B\_baseline/modeling\_qwen3.py · QwQZh/gated\_attention at main, https://huggingface.co/QwQZh/gated\_attention/blob/main/1B\_baseline/modeling\_qwen3.py
31. transformers/src/transformers/models/qwen2/modeling\_qwen2.py at, https://github.com/huggingface/transformers/blob/main/src/transformers/models/qwen2/modeling\_qwen2.py
32. aws-neuron/neuronx-distributed-inference · GitHub, https://github.com/aws-neuron/neuronx-distributed-inference/blob/main/src/neuronx\_distributed\_inference/modules/attention/attention\_base.py
33. Understanding Llama2: KV Cache, Grouped Query Attention, Rotary, https://ai.plainenglish.io/understanding-llama2-kv-cache-grouped-query-attention-rotary-embedding-and-more-c17e5f49a6d7
34. \[Bug\] Compiling Qwen3-Embedding model fails · Issue \#3404 \- GitHub, https://github.com/mlc-ai/mlc-llm/issues/3404
35. Tracing Numerical State through Sparse MoE Inference \- arXiv, https://arxiv.org/pdf/2607.28097
36. Choosing a hash function for 2030 and beyond: SHA-2 vs SHA-3 vs, https://kerkour.com/fast-secure-hash-function-sha256-sha512-sha3-blake3
37. Flock: Fast Proving for Batch Boolean Computations \- arXiv, https://arxiv.org/pdf/2607.27491
38. Ladybird WebAssembly Update \#2 \- dzfrias, https://dzfrias.dev/blog/ladybird-wasm-2/
39. IEEE 754 \- Wikipedia, https://en.wikipedia.org/wiki/IEEE\_754
40. Spectral Compression of Neural Networks: \- Research Explorer, https://research.manchester.ac.uk/files/1901258142/08\_-\_Pierre\_-\_Tese\_Final.pdf
41. ULP Difference of Float Numbers \- emmtrix Wiki, https://www.emmtrix.com/wiki/ULP\_Difference\_of\_Float\_Numbers
42. Numerical Precision in ONNX and AI Inference \- emmtrix Wiki, https://www.emmtrix.com/wiki/Numerical\_Precision\_in\_ONNX\_and\_AI\_Inference
43. Finding the Evidence: Discovering Decision-Supporting Tokens for, https://arxiv.org/html/2606.22830v1
44. How to Calculate the KL Divergence for Machine Learning, https://machinelearningmastery.com/divergence-between-probability-distributions/
45. Information Theory for Machine Learning \- Anurag Koul, https://koulanurag.dev/notebooks/information-theory/
46. ζ(s) Arb, https://arblib.org/arb-2.5.0.pdf
47. September 2022 – Nick Higham, https://nhigham.com/2022/09/
48. A Class of Fast and Accurate Summation Algorithms, https://www.semanticscholar.org/paper/A-Class-of-Fast-and-Accurate-Summation-Algorithms-Blanchard-Higham/c49d249df8f89a971f47840ab79c1b0d19d25c6e
49. Relaxed SIMD · Issue \#1401 · WebAssembly/design \- GitHub, https://github.com/WebAssembly/design/issues/1401
50. 5.5. Floating-Point Computation — CUDA Programming Guide, https://docs.nvidia.com/cuda/cuda-programming-guide/05-appendices/mathematical-functions.html
51. TTrace: Lightweight Error Checking and Diagnosis for Distributed, https://www.alphaxiv.org/abs/2506.09280
52. WebAssembly Specification \- Ng Zhi An, https://www.ngzhian.com/relaxed-simd/core/\_download/WebAssembly.pdf
53. WebAssembly 3.0 Brings Real-Time Garbage Collection to Robot, https://robotsfirst.org/webassembly-3-brings-real-time-garbage-collection-to-robot-control-loops/
54. (PDF) Floating-point arithmetic \- ResearchGate, https://www.researchgate.net/publication/370713387\_Floating-point\_arithmetic
55. IEEE-754 Floating Point · Mighty Professional Tutorials, https://mightyprofessionalgaming.com/tutorials/floating-point-from-scratch
56. LLaMA's Architectural Innovations \- Grasp, https://paths.grasp.study/modules/169875f1-c764-418f-b04e-1f4eadd4f116/lessons/74d1376f-2fbe-40f9-8dfc-210e1e73e353