How sadadhaidari/zybo-weight-memory works
This repository demonstrates lossless BF16 weight compression for language-model inference: Python packs weights, C++ restores them on the PC, and a Zybo FPGA stores and restores packed groups over JTAG. The main user-to-result path is loading model embeddings, optionally round-tripping them through the board, then comparing CPU inference outputs and measurements. Hardware RTL and some experiment modules are described by the README or tree but are not present in the supplied excerpts; arrows are limited to documented or excerpt-supported relationships.
Main entry points: board.py FPGA block store · native_model.py Native model runner · stress_qwen.py Qwen stress runs · live_inference.py Live board inference
Components 19
Software compression and inference
- BF16 exponent codec
software/exponent_codec.py - Exponent archive prep
software/prepare_exponent_archive.py - GGUF tensor reader
software/gguf_blocks.py - Native model runner
software/native_model.py - C++ weight restore
software/rqc.cpp - Memory budgeting
software/memory_budget.py - Stock model runner
software/stock_native.py
FPGA board access
- FPGA block store
hardware/board.py - JTAG cable transport
hardware/cable.py - FPGA bitstream loader
hardware/program.py
Physical inference experiments
- Experiment paths
experiments/paths.py - Physical weight sampling
experiments/physical.py - Embedding inference
experiments/inference.py - Qwen stress runs
experiments/stress_qwen.py - Live board inference
experiments/live_inference.py
Measurement and validation
- Board readback checks
hardware/verify_board.py - Baseline model benchmark
software/early/bench_model.py - Board measurement summaries
experiments/summarize_board.py
Other components
- Engineer
Connections 23
- Engineer → Physical weight sampling: samples weights
README.md - Engineer → Qwen stress runs: runs inference
README.md - BF16 exponent codec → C++ weight restore: packs for
README.md - C++ weight restore → Native model runner: restores weights
- GGUF tensor reader → Embedding inference: reads model tensors
experiments/inference.py - Native model runner → Embedding inference: runs CPU forward
experiments/inference.py - FPGA block store → Embedding inference: supplies embeddings
experiments/inference.py - GGUF tensor reader → Qwen stress runs: reads model tensors
experiments/stress_qwen.py - Native model runner → Qwen stress runs: runs CPU inference
experiments/stress_qwen.py - FPGA block store → Qwen stress runs: reads embeddings
experiments/stress_qwen.py - Physical weight sampling → FPGA block store: uses board access
experiments/physical.py - Physical weight sampling → Board readback checks: uses readback checks
experiments/physical.py - Live board inference → Physical weight sampling: checks and saves
experiments/live_inference.py - Live board inference → GGUF tensor reader: reads model tensors
experiments/live_inference.py - Live board inference → Native model runner: runs CPU inference
experiments/live_inference.py - Live board inference → Qwen stress runs: reuses test cases
experiments/live_inference.py - FPGA block store → JTAG cable transport: sends JTAG commands
hardware/board.py - FPGA block store → FPGA bitstream loader: checks FPGA identity
hardware/board.py - FPGA bitstream loader → JTAG cable transport: loads bitstream over
hardware/program.py - Board readback checks → FPGA block store: checks readback
hardware/verify_board.py - Baseline model benchmark → Stock model runner: benchmarks runner
software/early/bench_model.py - Memory budgeting → Native model runner: budgets runtime
- Board measurement summaries → Experiment paths: uses locations
experiments/summarize_board.py