Verace LayerStream
A layer-streaming inference stack designed to run 70B transformer models on a 6 GB GPU.
- Layer streaming engine: Loads, applies and releases each layer in turn
- OpenAI-compatible API server: Serves chat completions backed by the engine
- PCIe streaming benchmark: Times a simulated layer copy to the GPU
- Ternary quantizer: Ternary weights with a low-rank SVD correction
Overview
Verace LayerStream is an inference stack for running 70B-parameter language models on a laptop GPU with 6 GB of memory. It asks whether a model far larger than device memory can run at full FP16 or BF16 precision if its weights are moved onto the GPU one transformer layer at a time. The core streaming engine is a wrapper around airllm, existing software by others, and the quantized path relies on llama.cpp, also built by others. The lab's additions are the engine configuration, a serving layer, a transfer benchmark, planning scripts and a ternary quantizer.
The technical reference sizes a 70B model at 80 layers of about 1.75 GB each. It caps GPU memory at 4.5 GB. Each forward pass loads the layers in order, computes on each one and releases it. Around this core sit several parts. An OpenAI-compatible HTTP server exposes the engine. A pinned-memory benchmark measures transfer speed. In a draft and verify scheme, a small resident model proposes K tokens and the streamed model checks them in one sweep. A GPU/CPU partition estimator plans layer placement. Two compression paths are prepared: llama.cpp commands for 4-bit GGUF files, printed but not run, and a 1.58-bit ternary quantizer with a low-rank residual correction.
The technical reference reports a host-to-GPU bandwidth of 7.99 GiB/s, or 219.10 ms per 1.75 GB layer, with 1.75 GB allocated and 1.75 GB at peak; 1.75 GiB is the size of the benchmark's one simulated layer, so these figures do not show how many layers are resident during generation. It also claims 100.00% FP16 invariance. That claim follows from the decision not to quantize; no accuracy comparison is recorded. The benchmark script prints its passing line whatever figure it measures. The speculative engine and the partition estimator compute their outputs from hardcoded timings and acceptance rates and run no model.
Implemented: the streaming engine as an airllm wrapper with a VRAM cap and generation telemetry, the FastAPI server, the bandwidth benchmark, and the ternary quantizer with its synthetic test on a random matrix. Present as calculation or printed instructions only: speculative decoding, the GPU/CPU partition optimiser, and the IQ4_XS quantization pipeline. The only recorded measurement is the transfer bandwidth. No 70B generation run is recorded, and so no generation speed, output-quality result or speculative acceptance rate. The technical reference rejects low-bit quantization, yet the system also prepares two quantized paths. That tension is unresolved.
Status
Prototype. The streaming engine, server and quantizer exist as code, but the only recorded measurement is a single transfer-bandwidth benchmark, and the speculative and partitioning components compute estimates from hardcoded numbers.
Simulator
An agent runs sixty tasks whose steps sometimes fail. Choose whether each step is checked, how often a step fails and how long the tasks are.
- pale: worked first time · colour: caught and repeated · white: failed unnoticed · crossed: given up
- Tasks finished correctly
- 60 of 60
- Finished with a hidden error
- 0
- Given up after three tries
- 0
- Extra work spent on retries
- 9%
Turn the check off: the same failures now finish unnoticed. Lengthen the tasks and see how fast unchecked errors add up.
This simulator is an illustration of the principle, with made-up numbers. It does not run the lab's code or show the lab's data, and nothing in it is a measurement.
Architecture
Layer streaming engine
VeraceToposInferenceEnginewraps the airllm AutoModel to run a 70B model layer by layer under a configurable VRAM cap. It loads the tokenizer and reports telemetry during generation.OpenAI-compatible API server
A FastAPI application in
app_server.pyserves/v1/chat/completionsand/healthon port 8999, backed by the streaming engine.PCIe streaming benchmark
benchmark_streaming.pymeasures the speed of copying a simulated 1.75 GiB layer from pinned host memory to the GPU.Speculative draft-verify engine
VeraceToposSpeculativeEnginedescribes a scheme in which a small GPU-resident draft model proposes K tokens and the streamed large model verifies them in one layer sweep. It currently computes theoretical speedup only.Hybrid partition estimator
VeraceToposHyperOptimizerprints a hardware topology and an estimated split of 70B Q4 layers between GPU and CPU, using hardcoded figures.Ternary quantizer
VeraceTopos158BitQuantizercompresses weights to ternary values and corrects part of the resulting error with a low-rank SVD term.llama.cpp quantization scripts
Shell scripts build llama.cpp with CUDA, write a calibration text file, and print the commands for producing and running a 70B IQ4_XS GGUF model, including in hybrid CPU+GPU mode.
Implementation
Mechanisms as they are implemented in the source code, with the constants the code uses.
- Sequential layer loading under VRAM cap
- For each forward pass, the engine loads the transformer layers one at a time into GPU memory, applies each, and releases it before loading the next. The cap is passed as a flag, set to 4.5 in the documented command line.
- Pinned-host to GPU bandwidth test
test_layer_shuttling_speed()allocates a 1.75 GiB tensor in pinned host memory and times its copy to the GPU. It reports bandwidth in GiB/s and the transfer time per layer. The script prints a PASSED line unconditionally rather than checking the result against a threshold.- Theoretical speculative speedup
- The speculative engine combines hardcoded per-layer timings and an assumed acceptance rate to estimate how much faster decoding becomes when one streamed sweep verifies K drafted tokens instead of one. No draft model or large model is loaded.
- GPU/CPU layer partition estimate
- The hyper orchestrator divides a 70B Q4 model's layers between GPU and CPU memory, using fixed hardware and size numbers written in the script. It prints the split and performs no search or optimisation.
- Ternary quantization with SVD residual
- Each weight matrix is mapped to ternary values, written , and the residual is approximated by a truncated SVD. The reconstruction is , where is the rank kept.
- Synthetic quantizer benchmark
test_1_58bit_quantizer()applies the ternary quantizer and its low-rank correction to a randomly generated matrix and reports the outcome. No real model weights are used.- Chat completion endpoint
chat_completions()accepts aChatCompletionRequestmade ofChatMessageitems, in the request schema used by OpenAI-compatible clients, and passes the conversation to the streaming engine.startup_event()initialises the engine when the server starts, andhealth()reports server status.- Importance-matrix IQ4_XS pipeline
quantize_lossless_70b.shwrites a small calibration text file and prints the llama.cpp imatrix, quantize and llama-cli commands for a 70B IQ4_XS GGUF model. It prints these commands without running them.- Hybrid CPU+GPU launch recipe
run_hybrid_fast.shechoes a recommended llama-cli command and memory targets for splitting 70B inference between CPU and GPU. It does not launch inference itself.
Results
From the lab's own experiments and records. They have not been independently replicated.
Host-to-GPU bandwidth of 7.99 GiB/s
The technical reference reports 7.99 GiB/s for pinned-memory copies, or 219.10 ms to transfer one 1.75 GB layer, on a 6 GB RTX 4050.
Reported allocated and peak memory
The technical reference records 1.75 GB allocated and 1.75 GB at peak under the 4.5 GB cap; 1.75 GiB is the size of the single simulated layer the benchmark copies, so these figures do not show how many layers are resident during generation. No generation run, generation speed or output-quality result is recorded.
Accuracy invariance is asserted, not measured
The technical reference claims 100.00% FP16 invariance on the grounds that weights are never quantized. No benchmark comparison of model outputs is recorded.
Benchmark pass line is unconditional
The streaming benchmark prints PASSED regardless of the bandwidth it measures. Its verdict therefore carries no information beyond the printed figures.
Speculative speedup is theoretical only
The speculative engine computes its speedup from hardcoded timings and an assumed acceptance rate. No draft-verify generation run is recorded.
Concepts
- Layer streaming
- Running a model whose weights exceed GPU memory by moving one transformer layer at a time from disk or host RAM onto the GPU, computing on it, and freeing it. The cost is that every forward pass must transfer every layer.
- VRAM cap
- An upper limit on GPU memory use. The technical reference sets it to 4.5 GB on a 6 GB laptop GPU.
- Pinned host memory
- Page-locked system RAM that the GPU can copy from directly. It is faster than ordinary pageable memory, which is why the benchmark uses it to estimate the best-case layer transfer time.
- PCIe transfer bottleneck
- With layer streaming, decode speed is limited by how fast weights cross the PCIe bus, not by GPU compute. The bandwidth figure therefore matters more than the size of the GPU.
- Speculative decoding
- A small draft model proposes several tokens and the large model checks them all in one forward pass, keeping the accepted ones. Applied to streaming, one costly layer sweep can then yield more than one token.
- Acceptance rate
- The fraction of drafted tokens that the large model accepts. It determines how much speedup speculative decoding gives; in this system it is a hardcoded assumption, not a measured value.
- Ternary 1.58-bit weights
- Weights restricted to three values, which carry bits of information each. The 1.58-bit ternary format follows the BitNet b1.58 paper by other researchers.
- Low-rank residual correction
- After quantizing, the error between original and quantized weights is approximated by a truncated singular value decomposition. Adding this low-rank term back recovers part of the accuracy lost to quantization.
- Importance-matrix calibration
- A llama.cpp procedure that runs calibration text through the model to estimate which weights matter most, so that quantization preserves them more carefully.
- IQ4_XS GGUF
- A roughly 4-bit quantized weight format from llama.cpp. The system's scripts prepare this format as an alternative to full-precision streaming.
- Hybrid CPU+GPU offload
- Keeping some layers resident on the GPU and running the rest on the CPU, instead of streaming all layers through the GPU.
- Zero-copy loading
- The engine's design describes it as a zero-copy layer-streaming engine that streams full, uncompressed FP16 or BF16 layers from disk or RAM into a 6 GB GPU while keeping memory use under 4.5 GB for 70B models.
About this page
Written from the lab's own documents and source code. Figures and results are the lab's measurements as it recorded them at the time, and have not been independently replicated.
Published under the PolyForm Noncommercial License 1.0.0: free for noncommercial use.