Troubleshooting Guide¶
Quick Diagnostics¶
Is WASM Working?¶
from multilingualprogramming.runtime.backend_selector import BackendSelector
selector = BackendSelector()
print(f"WASM Available: {selector.is_wasm_available()}")
print(f"Selector: {selector}")
If WASM Available: False → See WASM Not Available
If WASM Available: True → WASM is working ✓
Common Issues & Solutions¶
Issue 1: ModuleNotFoundError - No module named 'wasmtime'¶
Symptom:
Cause: wasmtime runtime not installed
Solutions:
# Option 1: Install WASM package
pip install multilingualprogramming[wasm]
# Option 2: Install wasmtime directly
pip install wasmtime
# Option 3: Use Python fallback (no WASM)
pip install multilingualprogramming
Code Workaround:
from multilingualprogramming.runtime.backend_selector import BackendSelector, Backend
# Force Python (will always work)
selector = BackendSelector(prefer_backend=Backend.PYTHON)
result = selector.call_function("fibonacci", 10)
Issue 2: WASM Not Available¶
Symptom:
Diagnosis:
from multilingualprogramming.runtime.backend_selector import BackendSelector
import sys
import platform
selector = BackendSelector()
print(f"WASM: {selector.is_wasm_available()}")
print(f"Python: {sys.version}")
print(f"Platform: {platform.system()} {platform.machine()}")
Possible Causes:
-
Wasmtime not installed
-
WASM binaries missing from package
-
If empty → Reinstall:
pip install --force-reinstall multilingualprogramming[wasm] -
Platform not supported
- Linux ARM64: Use Python fallback
- Windows ARM64: Use Python fallback
- Solution: Use Python backend
from multilingualprogramming.runtime.backend_selector import Backend
selector = BackendSelector(prefer_backend=Backend.PYTHON)
- WASM module corruption
Issue 3: Performance Not Improved¶
Symptom:
Diagnosis:
import time
from multilingualprogramming.runtime.backend_selector import BackendSelector, Backend
def benchmark(func_name, *args):
# Python
sel_py = BackendSelector(prefer_backend=Backend.PYTHON)
start = time.perf_counter()
result = sel_py.call_function(func_name, *args)
py_time = time.perf_counter() - start
# WASM
sel_wasm = BackendSelector(prefer_backend=Backend.WASM)
start = time.perf_counter()
result = sel_wasm.call_function(func_name, *args)
wasm_time = time.perf_counter() - start
speedup = py_time / wasm_time if wasm_time > 0 else 1
print(f"Python: {py_time*1000:.2f}ms, WASM: {wasm_time*1000:.2f}ms, Speedup: {speedup:.1f}x")
# Test
benchmark("fibonacci", 25)
benchmark("matrix_multiply", [[1,2],[3,4]], [[5,6],[7,8]])
Possible Causes:
- Operation too small (< 1ms)
- WASM overhead dominates
-
Solution: Batch operations
-
WASM not actually being used
- Check:
selector.is_wasm_available() -
Solution: See WASM Not Available
-
Incorrect operation
- Not all operations have WASM acceleration
-
Solution: Check FALLBACK_REGISTRY
-
Timing interference
- First call loads module (10-50ms overhead)
- Solution: Warm up before timing
Issue 4: OutOfMemory Error with WASM¶
Symptom:
Cause: WASM memory (1GB) exceeded
Diagnosis:
import sys
# Check data size
matrix = [[1.0 for _ in range(10000)] for _ in range(10000)]
size_mb = sys.getsizeof(matrix) / 1024 / 1024
print(f"Matrix size: {size_mb:.1f} MB")
if size_mb > 64:
print("TOO LARGE for WASM! Max ~64MB")
Solutions:
-
Use smaller data
# Bad: 100×100 = 10,000 elements, 80KB (OK) # Worse: 1000×1000 = 1M elements, 8MB (OK) # Too much: 10000×10000 = 100M elements, 800MB (TOO LARGE) # Use Python fallback for large data from multilingualprogramming.runtime.backend_selector import Backend selector = BackendSelector(prefer_backend=Backend.PYTHON) -
Stream processing
-
Use Python directly
Issue 5: ImportError on Windows¶
Symptom:
Cause: Visual C++ Redistributables missing
Solutions:
- Install Visual C++ Redistributables
- Download: Microsoft Visual C++ Redistributable
-
Install for your Python architecture (32-bit or 64-bit)
-
Use vcpkg (Advanced)
-
Update pip & setuptools
-
Use Python fallback
Issue 6: TypeError - Type Conversion Failed¶
Symptom:
Cause: Invalid data type passed to WASM function
Diagnosis:
from multilingualprogramming.runtime.backend_selector import BackendSelector
# WASM supports: int, float, str, list, dict
# WASM doesn't support: custom objects, functions
# Good
result = selector.call_function("fibonacci", 10) # int ✓
# Bad
result = selector.call_function("fibonacci", lambda: 10) # function ✗
Solutions:
-
Convert to supported type
-
Use Python for custom types
Issue 7: Assertion Error - Operation Produces Different Results¶
Symptom:
Cause: Bug in WASM code or type conversion
Diagnosis:
from multilingualprogramming.runtime.backend_selector import BackendSelector, Backend
func_name = "factorial"
args = (5,)
# Compare results
sel_py = BackendSelector(prefer_backend=Backend.PYTHON)
sel_wasm = BackendSelector(prefer_backend=Backend.WASM)
result_py = sel_py.call_function(func_name, *args)
result_wasm = sel_wasm.call_function(func_name, *args)
print(f"Python: {result_py}")
print(f"WASM: {result_wasm}")
print(f"Match: {result_py == result_wasm}")
Solutions:
- Report bug
- File issue on GitHub Issues
-
Include: Python version, platform, input args, actual vs expected
-
Use Python fallback
-
Use Python directly
Issue 8: FileNotFoundError - WASM Binary Not Found¶
Symptom:
Cause: WASM binary missing or incorrect path
Diagnosis:
# Check installation
python -c "import multilingualprogramming; print(multilingualprogramming.__file__)"
# Navigate to directory, check for 'wasm' folder with .wasm files
# List WASM modules
find /path/to/multilingualprogramming -name "*.wasm" -type f
Solutions:
-
Reinstall
-
Verify installation
-
Use Python fallback
Debugging Techniques¶
Enable Verbose Logging¶
Or in code:
import os
os.environ['MULTILINGUAL_DEBUG'] = '1'
# Then run...
from multilingualprogramming.runtime.backend_selector import BackendSelector
selector = BackendSelector()
result = selector.call_function("fibonacci", 10)
# Will print debug info
Inspect Backend Selection¶
from multilingualprogramming.runtime.backend_selector import BackendSelector
selector = BackendSelector()
# Check availability
print(f"WASM available: {selector.is_wasm_available()}")
print(f"Selector: {selector}")
import sys
print(f"Python 3.12+: {sys.version_info >= (3, 12)}")
# Check module loading
try:
from multilingualprogramming.wasm.loader import WasmModule
module = WasmModule.load("matrix_operations.wasm")
print(f"Module loaded: {module is not None}")
except Exception as e:
print(f"Module load failed: {e}")
Manual Function Testing¶
from multilingualprogramming.runtime.python_fallbacks import (
NumericOperations,
MatrixOperations,
)
# Test fallbacks directly
fib = NumericOperations.fibonacci(10)
print(f"Fibonacci(10): {fib}")
a = [[1, 2], [3, 4]]
b = [[5, 6], [7, 8]]
result = MatrixOperations.multiply(a, b)
print(f"Matrix multiply: {result}")
Performance Profiling¶
import cProfile
import pstats
from multilingualprogramming.runtime.backend_selector import BackendSelector
selector = BackendSelector()
# Profile with cProfile
cProfile.run('selector.call_function("fibonacci", 30)', 'fibonacci.prof')
# Print stats
stats = pstats.Stats('fibonacci.prof')
stats.sort_stats('cumulative')
stats.print_stats(10)
Getting Help¶
Before Reporting an Issue¶
- Verify Python version:
python --version(should be 3.12+) - Check installation:
pip show multilingualprogramming - Test fallback: Force Python backend, see if it works
- Try diagnostics: Run scripts in Diagnostics
When Reporting¶
Include:
- Python version: python --version
- Platform: python -c "import platform; print(platform.platform())"
- WASM status: python -c "from multilingualprogramming.runtime.backend_selector import BackendSelector; print(BackendSelector().is_wasm_available())"
- Minimal reproducible example
- Full error traceback
Support Channels¶
- 🐛 GitHub Issues
- 💬 GitHub Discussions
- 📧 Email: johnsamuelwrites@gmail.com
FAQ Quick Links¶
See WASM_FAQ.md for answers to common questions
Version: Documentation Suite Final Last Updated: February 22, 2026 Status: ✅ Complete