Welvet examples
65. Cross-numeric train + down-the-dem
Part: IV · Runtime
Package: github.com/openfluke/welvet/runtime/training
Status: ok — ✅
When
Walking a Grid/Stack with the shared runtime/training path.
Where
import "github.com/openfluke/welvet/runtime/training"
cd 65-cross-numeric && source ../env.sh && go run .
Why
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.
What
W2A Step Cross-Numeric Train: polyops.AllKinds() × FormatNone weight dtype × Go Numeric act host (smoke ~735; full ~10.7k) via StepMesh, then assert no retained f32 master. Public Dense volumetric showcase: down-the-dem — dtype demotion ladder, packed quants, and the full 34×15×3 perm matrix with charts/PDF.
Sample output (captured)
1.5 <nil> false
Live capture from go run ./cmd/runall on local ../../welvet (exit 0).
Source
Copied from the Welvet feature book examples (openfluke.github.io/welvet/examples/65-cross-numeric).
main.go
Download source ↓package main
import (
"fmt"
"github.com/openfluke/welvet/architecture"
"github.com/openfluke/welvet/core"
"github.com/openfluke/welvet/layers/dense"
"github.com/openfluke/welvet/quant"
"github.com/openfluke/welvet/runtime/training"
)
func main() {
// Weight storage: int8 FormatNone. Activations/grads: Tensor[int8].
g := architecture.NewGrid(1, 1, 1, 1)
init := make([]float32, 4*4)
for i := range init {
init[i] = 0.1
}
l, err := dense.NewConfigured(4, 4, core.ActivationLinear, core.DTypeInt8, quant.FormatNone, init)
if err != nil {
panic(err)
}
if err := dense.Place(g, 0, 0, 0, 0, l); err != nil {
panic(err)
}
x := core.NewTensor[int8](1, 4)
y := core.NewTensor[int8](1, 4)
for i := 0; i < 4; i++ {
x.Data[i] = int8(i + 1)
y.Data[i] = int8(i)
}
loss, _, err := training.StepMesh(g, x, y, 1, 0.05)
fmt.Println(loss, err, l.Weights.RetainsF32Master())
}