THE OPEN NOTEBOOK · v1.7.3
A book for the curious.
112 chapters inside the Welvet AI engine, including NativeCPU, Qualcomm Hexagon HTP, Apple Metal, Apple MLX, NVIDIA CUDA, AMD ROCm, Vulkan, and Python C-ABI. Start with why it exists, then follow the ideas into layers, learning, and the systems that connect them.
welvet.qnn path — see the Android QNN lab PDF and /welvet. Code examples and reported results below are preserved from the source edition. Read the complete book on one page →112 entries
I · Orientation
What Welvet is
Loom’s flat poly/ package hit import-cycle and honesty walls (QAT morph, silent fallbacks, god-layer). Welvet is the rewrite: one feature per folder, storage-truth dtypes/quants, Dense as th
Read moreI · Orientation
Repository map
Readers need a single map of what is engine vs harness vs app vs stub.
Read moreII · Foundation
core: types & backends
Every polymorphic path needs one place for DType, LayerType, Activation, Backend, Tensor[T], and slim Layer metadata: without QAT morph defaults.
Read moreII · Foundation
weights: FormatNone MatVec
Unquantized matrices still need a typed store that streams MatVec and SGD without forcing a float32 master or Morph-as-training.
Read moreII · Foundation
quant: 20 pack formats
Inference, storage, and train need classic Q-packs, k-quants, IQ, Ternary/Binary, and Affine without a separate QAT mode or retained f32 master. Format is storage truth.
Read moreII · Foundation
simd: Plan 9 kernels
CPU peak needs hand-written AVX2/NEON without a silent Go fallback that pretends SIMD ran.
Read moreII · Foundation
webgpu: device GEMV & shaders
GPU paths must bind a real adapter. Host “fake GPU” was banned so suites cannot stamp WebGPU done when ALU ran on CPU.
Read moreII · Foundation
tiling: SC/MC & workgroups
MatVec throughput depends on tile size and when to go multi-core vs GPU workgroups. Centralizing caps keeps Dense and friends consistent.
Read moreII · Foundation
architecture: volumetric grid
Networks are spatial (Depth×Rows×Cols×LayersPerCell), not only linear stacks. Topology lives here; compute lives in layer packages.
Read moreII · Foundation
fusedgpu: decoder on device
Token-by-token host round-trips kill decode. A fused engine keeps weights and scratch resident for Q4_0 and BinaryG128 hybrid paths.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: JSON backend placement
Choose which layers run on AMD GPU while retaining ordinary Go training entry points.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: mixed Go/C++/ROCm
Split a single model between the independent native engines and Go.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: results and suite pointers
Find the AMD sibling repo and live ROCm parity/timing matrices after the small usage chapters.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: mount and forward
Run a Go layer on a Vulkan GPU with an explicit lifetime via the independent welvet.vulkan library.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: Mamba parameter dtypes
Exercise native storage formats without changing the activation interface.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: training modes
Keep repeated training updates in the mounted Vulkan session.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: weight return and ENTITY save
Return trained weights to Go before executing or saving the Go model.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: JSON backend placement
Choose which layers run on Vulkan while retaining ordinary Go training entry points.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: mixed Go/C++/Vulkan
Split a single model between the independent native engines and Go.
Read moreXV · Vulkan acceleration (welvet.vulkan)
Vulkan: results and suite pointers
Find the Vulkan sibling repo and live go_v_vulkan matrices after the small usage chapters.
Read moreIII · Layers
layers/dense: MatVec microkernel
Most FLOPs are W@x. One Dense stack owns FormatNone×34 and all quants × three backends so every composite proj shares one correctness surface: including native in-dtype SGD.
Read moreXVI · Apple MLX acceleration (welvet.mlx)
Apple MLX: SyncToMLX and forward
Run a Go Dense layer on Apple MLX GPU with an explicit SyncToMLX lifetime: forward-only, no Mount/TrainMSE twin.
Read moreXVI · Apple MLX acceleration (welvet.mlx)
Apple MLX: caps and dtype rejects
Unsupported mounts must hard-fail before any GPU work: not soft-fallback to Go labeled as MLX.
Read moreXVI · Apple MLX acceleration (welvet.mlx)
Apple MLX: Dense prepare and Sequential
Show prepare-once Dense execute and a small Sequential tower on the same MLX session.
Read moreXVI · Apple MLX acceleration (welvet.mlx)
Apple MLX: go_v_mlx results pointers
Find the sibling harness and live MLX parity matrices after the small usage chapters.
Read moreXVII · Python C-ABI (welvet on PyPI)
Python C-ABI: install and Dense forward
Use the same Welvet engine from Python via ctypes over a prebuilt C ABI: no Go toolchain required for day-to-day scripts.
Read moreXVII · Python C-ABI (welvet on PyPI)
Python C-ABI: list backends and pick one
Accelerators are opt-in at runtime. Scripts should probe what this host can run instead of hard-coding CUDA or Metal.
Read moreXVII · Python C-ABI (welvet on PyPI)
Python C-ABI: train SGD and .entity round-trip
Training and checkpoints should match the Go ENTITY path so Python scripts can hand off to Go apps (and back).
Read moreXVII · Python C-ABI (welvet on PyPI)
Python C-ABI: MHA place and prepare_grid
Not every layer is Dense. Python place takes the same kind strings as Go; some accelerators need an explicit prepare/Sync before forward.
Read moreIII · Layers
layers/mha: attention
Transformers need multi-head attention with masks, RoPE/ALiBi, GQA/MQA, and cross-attn: without forking MatVec for every projection.
Read moreIII · Layers
layers/swiglu: gated FFN
Modern decoder FFNs are SiLU(gate)⊙up → down. Projections must share Dense’s quant/backend matrix.
Read moreIII · Layers
layers/rmsnorm
Llama-style blocks normalize by RMS, not mean+var. Needs native fwd/bwd and WebGPU shaders.
Read moreIII · Layers
layers/layernorm
Classic mean+var normalization with γ/β: still required for many HF architectures.
Read moreIII · Layers
layers/embedding
Token IDs must gather rows from a table: not a Dense MatVec: with scatter grads on backward.
Read moreIII · Layers
layers/softmax
Classification heads and attention need stable softmax variants, including sparse/Gumbel/Entmax for research paths.
Read moreIII · Layers
layers/sequential
Some cells need an ordered Dense chain without burning grid hops.
Read moreIII · Layers
layers/residual
Skip connections stabilize deep stacks: y = F(x) + x with correct skip grads.
Read moreIII · Layers
layers/cnn1 · cnn2 · cnn3
Conv nets must sit on the same dtype×quant×backend matrix as Dense. im2col → Dense GEMV is the intentional first cut.
Read moreIII · Layers
layers/rnn · lstm
Sequence models before transformers still need vanilla RNN and LSTM with BPTT on the shared MatVec stack.
Read moreIII · Layers
layers/seqmix: mixer contract
Attention, SSM, linear attn, and conv mixers must not be accidental forks of mha. Naming the contract keeps packages honest.
Read moreIII · Layers
layers/gdn: gated delta net
Linear attention / decode-first mixers (Gated DeltaNet) need a first-class package under KindLinearAttn.
Read moreIII · Layers
layers/mamba: selective SSM
SSM mixers (KindSSM) are not MHA clones: they need their own selective-scan path.
Read moreIII · Layers
layers/convt1 · convt2 · convt3
Generators and U-Nets need transposed convolution as a peer of CNN, on the same Dense proj surface.
Read moreIII · Layers
layers/kmeans
Soft clustering as a differentiable layer lets topology experiments sit inside the same train loop.
Read moreIII · Layers
layers/parallel: MoE + cameral
Mixture-of-experts and multi-path cells need concat/add/avg/filter combines. Cameral graphs need sibling hemispheres that share input, merge outputs, and optionally train under distinct mode
Read moreIII · Layers
layers/metacognition
Observed layers can apply heuristic stability rules (gate/scale/reset) without dtype morph/QAT.
Read moreIV · Runtime
runtime/forward
A grid of heterogeneous ops needs one walker that dispatches by concrete type and fails loudly on unknowns.
Read moreIV · Runtime
runtime/backward
Training needs a reverse tape over the same ops forward used: no separate graph framework.
Read moreIV · Runtime
runtime/training
Suites and small nets need MSE+SGD and tween hooks without inventing an external trainer or a retained float32 master beside storage.
Read moreIV · Runtime
runtime/step: step mesh
Spatial feedback (remote links) needs a discrete-time mesh where every cell updates from a double buffer: different from a decoder wavefront. Cross-numeric train also needs the same mesh wi
Read moreV · Systems
systems/dna
Quant and train must be measurable as topology/weight fingerprints: DNA detects logic shifts.
Read moreV · Systems
systems/evolution
Topology search and weight crossover need first-class splice + NEAT on CPU-resident grids.
Read moreV · Systems
systems/tween
Target propagation (chain-rule or Hebbian layerwise gaps) is an alternative credit-assignment path. Not the same package as TrainMode Tween / TweenChain on a Sandwich (those are layers/paral
Read moreV · Systems
systems/tanhi: TANHI · UDP HUD
Training visualization must never block the engine: best-effort UDP JSON-lines to a HUD.
Read moreV · Systems
systems/telemetry
Static structural blueprints (sizes, op kinds) differ from live TANHI events.
Read moreVI · Model IO
model/entity: .entity files
HF safetensors are awkward for native topology + packed weights. ENTITY is the Welvet checkpoint.
Read moreVI · Model IO
model/hf: snapshots
Import starts with probing HF/MLX layouts before packing ENTITY.
Read moreVI · Model IO
model/tokenizer
Generate needs encode/decode of HF tokenizer.json without pulling Python.
Read moreVI · Model IO
model/sampling
Logits → token ID needs ArgMax, TopK+temperature, penalties, and chat hygiene in one place.
Read moreVI · Model IO
model/transformer: generate
ENTITY packs must run as Llama-style decoders with KV cache, profiles (SIMD/WebGPU/fused), and chat templates.
Read moreVII · Apps
apps: octo · flux2 · mosstts
Products must not pollute engine packages. Octo is the model shell; flux2/mosstts are domain apps. Lucy races (AAI test41 / test48 / test50) are benches, not Welvet packages.
Read moreVII · Apps
Octo: model shell
A model is only useful with a shell around it: pull weights from Hugging Face, convert them to a Welvet .entity, then chat, serve, or benchmark. Octo is that shell, kept in its own module so
Read moreVIII · Stubs
stub/seed
Ship topology recipes (layer seeds → He-init) without weight blobs.
Read moreVIII · Stubs
stub/serialization
Volumetric grids need JSON/ENTITY persist beyond transformer packs.
Read moreVIII · Stubs
stub/memory
HF→ENTITY and GPU upload need footprint accounting and optional history charts.
Read moreVIII · Stubs
stub/donate
LAN donors should accept framed JSON jobs without embedding HTTP in the engine.
Read moreVIII · Stubs
stub/fountain
Recover specialist weight blobs over lossy links via LT fountain codes, then ensemble.
Read moreVIII · Stubs
stub/hardware
Dispatchers and UIs need a portable host audit (OS/CPU/RAM/GPU).
Read moreVIII · Stubs
stub/accel: NPU/Metal/QNN
Vendor accelerators plug beside WebGPU: not replace it. Qualcomm HTP is live via nativeqnn + sibling welvet.qnn (see book §79-81).
Read moreVIII · Stubs
stub/clustering
Offline clustering helpers on tensors without inventing a second math stack.
Read moreVIII · Stubs
stub/ensemble
Combine multiple model votes and find complementary specialists.
Read moreVIII · Stubs
stub/evaluation
Benchmark grids through runtime/forward with deviation metrics.
Read moreVIII · Stubs
stub/grafting
Merge grids into Parallel/Residual structures for topology experiments.
Read moreVIII · Stubs
stub/grouping
Detect layer archetypes from safetensor-style names before mounting.
Read moreVIII · Stubs
stub/introspection
UIs and FFI need to list Grid methods without hardcoding every export.
Read moreVIII · Stubs
stub/observer
Attach forward/backward observers for debugging without coupling to tanhi UDP.
Read moreVIII · Stubs
stub/pipeline
Decoder wavefront stats helpers: not a full Lucy-style pipeline runner yet.
Read moreVIII · Stubs
stub/templates
Chat prompts must match model families (ChatML, Llama3, BitNet) without app-specific string glue.
Read moreVIII · Stubs
stub/universal
Probe unknown safetensor geometry and mount placeholder grids until full weight import lands.
Read moreIX · Validate
w2a: validation harness
Engine packages must stay free of tests. w2a owns timed 34×20×3 matrices, gap census, honesty stamps, and the train-mode permutation smoke (Test49). See §63 for a live full-suite run.
Read moreIX · Validate
Validation report: full suite
Claims are cheap; a stamped matrix is not. This is the actual output of one full w2a [0] Run ALL so the book's ✅ marks are backed by numbers you can reproduce, not asserted.
Read moreIX · Validate
Scorecard → v1.0 / minors
Version is earned from a weighted board, not marketing. v1.0 is 100/100 on the engine board. Minor/patch tags (v1.1.0, v1.1.1, …) pack features without a new board. Apps, stubs, and NPU sit
Read moreIV · Runtime
Cross-numeric train + down-the-dem
Weight storage dtype and activation Tensor[T] are independent axes. Proving train without a retained float32 master means sweeping W×A: not only matched float32 acts.
Read moreV · Systems
lucy: SoftAcc / Score measuring
Adaptation benches (test41-w, tide, live_gpt) need one shared measuring math: SoftAcc, Availability, AdaptPct, Score: not three copies of the formulas.
Read moreIV · Runtime
TrainMode: 29 named updates
Backprop is one update, not the only one. Credit assignment (broadcast gap, head proxy, sparse duty clock) has to be a named axis you can race: not a comment in a notebook. Cameral Mix also
Read moreVII · Apps
Cameral sandwiches + AAI Lucy
A single Dense chain cannot host two independent weight copies that share an input, merge, and optionally train under different updates. That is the cameral graph: hemispheres, not screen-sp
Read moreV · Systems
Lucy density: synthetic organism
A new host (char LM, MNIST, a layer sprint) should not copy tide's goldilocks math. The question is always the same: can the net run and train at the same time in a small box, then how far t
Read moreVII · Apps
CamSync: inter-cameral / cross-mesh weight blend
Mix BranchModes and different inits let cams diverge on purpose. Sometimes you want them to share: gently (1% pull) or hard (full average): within a Parallel, across Stack children, or eve
Read moreX · NativeCPU (welvet.cpp)
NativeCPU: opt-in welvet.cpp C ABI
Go stays the default engine. When you want the C++ MatVec / NormalBP / TrainMSE path in-process, set BackendNativeCPU (never Prefer as default). Pending C++ weights stay off Go Stores until
Read moreX · NativeCPU (welvet.cpp)
NativeCPU: TrainNativeMSE per layer
Each signed layer has a packed C ABI NormalBP path. One smoke walks Dense → CNN/ConvT → norms → RNN/LSTM → Sequential/Residual → Parallel → Embedding → Softmax → KMeans → MHA/SwiGLU → Mamba/
Read moreX · NativeCPU (welvet.cpp)
NativeCPU: TrainMode stack / parallel / mesh / line
Leaf credit for every TrainMode family goes through one C dispatcher. Mesh clock and Line pipe have their own host-shape ABIs. Go intercepts TrainStackMSE/TrainMSE when BackendNativeCPU; cal
Read moreXI · Hexagon NPU (welvet.qnn)
QNN: opt-in Hexagon HTP (welvet.qnn)
Qualcomm Hexagon HTP is a sibling engine (welvet.qnn 1.0.0), not a silent fallback inside Go. Opt-in BackendQNN + explicit SyncToQNN keep CPU/SIMD/WebGPU as defaults. Caps reject unsupported
Read moreXI · Hexagon NPU (welvet.qnn)
QNN: HTP layer tour (session ABI)
w2a go_v_qnn exercises every shipped HTP forward. Book examples use the same session ABI with tiny shapes so a Snapdragon box can smoke-test without the full matrix.
Read moreXI · Hexagon NPU (welvet.qnn)
QNN: go_v_qnn RESULTS (large shapes)
Toy shapes lie. The w2a large matrix (dense 32×512×512, softmax 64×4096, …) is the honest Snapdragon X story: NPU DLL graphExecute vs Go/native f32 CPU, plus Go→NPU call overhead (cgo + pack
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: mount and forward
Mount an identity Dense layer, inspect the Metal version and device, and forward a Float32 tensor.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: Mamba parameter dtypes
Exercise native storage formats without changing the activation interface.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: training modes
Train two Dense layers using one of the 29 numbered modes, with persistent Step Line state and real Grid layouts for Mesh modes.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: weight return and ENTITY save
Return trained weights to Go before executing or saving the Go model.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: JSON backend placement
Choose which layers run on Apple GPU while retaining ordinary Go training entry points.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: mixed Go/C++/Metal
Split a single model between the independent native engines and Go.
Read moreXII · Apple acceleration (welvet.metal)
Apple Metal: Mamba results and stress runner
Measure real end-to-end Go bindings on sufficiently large models.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: mount and forward
Mount an identity Dense layer, inspect the CUDA version and device identity, and forward a Float32 tensor.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: Mamba parameter dtypes
Exercise native storage formats without changing the activation interface.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: training modes
Train two Dense layers using one of the 29 numbered modes, with persistent Step Line state and real Grid layouts for Mesh modes.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: weight return and ENTITY save
Return trained weights to Go before executing or saving the Go model.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: JSON backend placement
Choose which layers run on NVIDIA GPU while retaining ordinary Go training entry points.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: mixed Go/C++/CUDA
Split a single model between the independent native engines and Go.
Read moreXIII · NVIDIA acceleration (welvet.cuda)
NVIDIA CUDA: results and suite pointers
Find live CUDA parity/timing matrices after the small usage chapters.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: mount and forward
Run a Go layer on an AMD GPU with an explicit lifetime via the independent welvet.rocm library.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: Mamba parameter dtypes
Exercise native storage formats without changing the activation interface.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: training modes
Train two Dense layers using one of the 29 numbered modes, with persistent Step Line state and real Grid layouts for Mesh modes.
Read moreXIV · AMD acceleration (welvet.rocm)
AMD ROCm: weight return and ENTITY save
Return trained weights to Go before executing or saving the Go model.
Read more