Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Repository files navigation

WayInfer

Run large language models that don't fit in RAM. No GPU required.

WayInfer is a native GGUF inference engine that streams model weights from SSD on demand using memory-mapped I/O. An 80GB model loads in under 1 second and runs on a machine with 48GB of RAM — or less.

How It Works

┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SSD/NVMe │────>│ RAM │────>│ Compute │
│ (model.gguf)│ mmap│ (OS paging) │ │ (AVX2 SIMD)│
│ 80GB+ │ │ on-demand │ │ 8 threads │
└─────────────┘ └─────────────┘ └─────────────┘

Traditional inference engines load the entire model into memory before running. WayInfer uses mmap to let the OS page model weights from SSD into RAM as needed. Only the active layers occupy physical memory at any time.

Architecture

WayInfer's design is derived from the tiered memory manager in WayOS, an AI-first operating system that treats storage as a unified memory hierarchy (SSD ↔ RAM ↔ VRAM). The core insight: for Mixture of Experts (MoE) models, only 2 of 8+ experts are active per token — the rest can stay on disk until needed.

Key components:

ComponentFilePurpose
GGUF Parsersrc/gguf.cParses GGUF headers in <1s, supports N-file splits
Tensor Enginesrc/tensor_engine.cQuantized dot products (AVX2 SIMD, 8-thread parallel)
Inference Enginesrc/gguf_chat.cFull transformer forward pass — attention, MoE routing, FFN
Tier Managersrc/memory/tier_manager.cSSD streaming memory manager (WayOS architecture)
Platformsrc/platform/Cross-platform mmap, threading (Windows + Linux)

Validated Results

Mixtral 8x22B Instruct — 141B parameters, 80GB quantized, split across 2 GGUF files:

Model: Mixtral-8x22B-Instruct-v0.1.Q4_K_M (80 GB)
RAM: 48 GB (model is 1.7x available memory)
Load: 0.3 seconds
Prompt: "What is 2+2?"
Output: "The sum of 2 and 2 is 4."
Speed: ~0.08 tok/s (scalar+threading, no GPU)

The engine produces correct, coherent English from an 80GB MoE model on a machine that cannot hold the model in memory.

Supported Model Formats

WayInfer works with GGUF files using K-quant quantization — the most common format on HuggingFace.

Quant TypeBits/WeightStatusNotes
Q4_K_M4.5SupportedMost common, recommended
Q5_K_M5.5SupportedHigher quality
Q6_K6.5SupportedNear-lossless
Q8_08.0SupportedUsed for K/V projections
F3232SupportedNorm weights, metadata
F1616SupportedRouter weights
MXFP4, IQ*variesNot supportedNiche formats

Split GGUF files are fully supported — models split across any number of files (2, 4, 8, etc.) are loaded and merged automatically.

Tested architectures:

  • Mixtral / Mistral (MoE, GQA)
  • Llama 3.x (dense, GQA)

Build

Requirements: Visual Studio 2022 Build Tools, Windows 10/11 SDK, CPU with AVX2 support.

build.cmd

Output: build\wayinfer.exe

Usage

Quick Test

python validate.py --model path\to\model.gguf --prompt "Your question here" --max-tokens 30

Requires pip install llama-cpp-python for tokenization only (loads vocab in 0.2s, does NOT load model weights).

Direct Engine

build\wayinfer.exe --model path\to\model.gguf --greedy --max-tokens 20

Flags:

  • --model <path> — GGUF model file (first split if multi-file)
  • --ids-file <path> — Pre-tokenized input (binary format)
  • --greedy — Deterministic output (argmax sampling)
  • --temp <T> — Sampling temperature (default 0.7)
  • --max-tokens <N> — Maximum tokens to generate
  • --debug — Enable diagnostic output

Custom Tensor Engine

WayInfer does not depend on ggml, llama.cpp, or any external compute library. It implements its own quantized dot product kernels that match the numerical behavior of ggml's scalar path.

This matters because GGUF quantization is calibrated for a specific dot product computation order. Using a different method (e.g., dequant-to-float32 then dot product) produces numerically different results that compound across layers and destroy output quality. WayInfer's tensor engine replicates the exact computation:

  1. Input quantization — float32 input is quantized to Q8_K (256-element blocks with per-group sums)
  2. Block-level integer accumulation — weight and input quants are multiplied in int8/int16, accumulated in int32 across 8 parallel lanes
  3. Scale application — float conversion happens once per super-block, not per element
  4. AVX2 SIMD — 32-byte vector operations for the inner dot products
  5. 8-thread parallelism — output rows split across CPU cores

Limitations

  • Speed: ~0.08 tok/s on Mixtral 80GB with CPU-only scalar+AVX2. This is limited by SSD bandwidth and single-core throughput. AVX-512 VNNI and GPU offload would improve this significantly.
  • Tokenization: Relies on llama-cpp-python for correct BPE tokenization. The built-in greedy tokenizer is inaccurate for production use.
  • Chat interface: No interactive chat loop yet. Use validate.py for prompt-response testing.
  • Model support: Only K-quant GGUF formats (Q4_K, Q5_K, Q6_K, Q8_0). Models using MXFP4, IQ-quants, or GPTQ are not supported.
  • Platform: Windows only (Linux mmap/threading stubs exist but are untested).

Roadmap

  • AVX-512 / VNNI tensor engine kernels (~10x speedup)
  • GPU offload for attention and FFN (CUDA/Vulkan)
  • Interactive chat with streaming output
  • Built-in BPE tokenizer (remove llama-cpp-python dependency)
  • Linux build and testing
  • SSD-aware expert prefetch (predict next experts, pre-page from SSD)
  • KV cache compression for longer context

Project Structure

src/
├── gguf_chat.c # Inference engine (forward pass, attention, MoE)
├── gguf.c / gguf.h # GGUF file parser (instant load, N-file splits)
├── tensor_engine.c / .h # Quantized compute kernels (AVX2, threaded)
├── memory/
│ ├── tier_manager.c # WayOS-derived tiered memory manager
│ ├── expert_cache.c # MoE expert caching
│ ├── prefetch.c # Predictive expert prefetch
│ └── coherency.c # Memory coherency
├── platform/
│ ├── io_win.c # Windows mmap (CreateFileMapping)
│ ├── io_linux.c # Linux mmap (mmap/madvise)
│ ├── threadpool_win.c # Windows threading
│ └── threadpool_posix.c # POSIX threading
├── fmoe_main.c # Reference: llama.dll wrapper
├── model_loader.c # Model loading utilities
├── router.c # MoE expert router
├── pipeline.c # Inference pipeline
└── backend/ # GPU backend stubs (future)
validate.py # End-to-end validation tool
tokenizer.py # Fast GGUF tokenizer (reads vocab in 0.2s)
build.cmd # Windows build script

License

MIT

Acknowledgments

  • Architecture derived from WayOS tiered memory manager
  • Quantization format compatible with GGUF specification
  • Tensor engine dot products match ggml scalar computation path

About

Run LLMs larger than your RAM — native GGUF inference engine with SSD streaming, no GPU required

Topics

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages