Skip to content

Implement cross-architecture verification for WebAssembly targets via QEMU emulation #232

Description

@0xGeorgii

Background & Motivation

The inference compiler currently targets WebAssembly (wasm-encoder) as its primary output. While WebAssembly is an architecture-agnostic bytecode format, its execution strictly depends on a host runtime (e.g., Wasmtime, V8) that must translate this bytecode into native machine instructions via Ahead-of-Time (AOT) or Just-In-Time (JIT) compilation.

Currently, our validation pipeline implicitly tests this Wasm-to-native translation only against the host machine's architecture (typically x86_64).

Problem Statement

Testing exclusively on x86_64 leaves a significant validation gap. It assumes that the underlying Wasm runtime will generate semantically identical machine code and exhibit identical execution behavior across all ISAs. However, architectural differences in floating-point handling (e.g., NaN payloads), memory ordering, and underlying runtime code-generation bugs can cause a formally correct .wasm payload to fail or behave non-deterministically when executed on aarch64, riscv64, or other edge architectures.

Proposed Solution

To guarantee strict semantic equivalence and determinism across all supported deployment targets, I propose integrating QEMU user-mode emulation into our CI/CD pipeline.

By executing our generated Wasm artifacts within runtimes running on emulated non-native architectures, we can validate the complete compilation lifecycle—from inference source down to physical machine execution—without requiring bare-metal hardware.

Implementation Plan

  • CI Infrastructure Expansion: Update the GitHub Actions workflows to provision qemu-user-static (specifically targeting qemu-aarch64 and qemu-riscv64).
  • Cross-Architecture Test Execution: Modify the test runner suite to parameterize execution. Tests should invoke the Wasm runtime wrapped in the QEMU emulator (e.g., compiling AOT for aarch64, then executing via qemu-aarch64).
  • Determinism Assertions: Implement strict comparisons of exit codes, stdout/stderr, and memory state across both native x86_64 execution and the QEMU-emulated environments.
  • Proof Mode Validation: Ensure that unoptimized proof mode outputs maintain the exact same structural invariants and operational semantics across all emulated ISAs as they do natively.

Expected Impact

This integration will mathematically enforce the "write once, run anywhere" guarantee of our WebAssembly output. It will proactively catch backend regressions, edge-case architecture disparities, and runtime JIT/AOT translation errors before they reach production environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsUnit, fuzzing, performance, etc.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions