Kaun.PtreeSourceHeterogeneous parameter tree structure.
Builders
Create a dict container from key-value pairs. Keys must be unique.
Extract tensor or raise. Optional context for error message.
Walking / zipping
Typed map over tensors. Result dtype must equal input dtype.
Typed zip-with over tensors. Structures must match; dtype per-pair must match.
Packed map over tensors (escape hatch if types are dynamic).
Flatten & rebuild
Flatten to tensors and a rebuilder function.
Path access
Typed path access for tensors
Get typed tensor at path, checking dtype.
Get typed tensor or raise.
Flatten with paths
Filter tensors by predicate on path and tensor.
Float dtype discovery
type float_dtype = | F : (float, 'l) Rune.dtype -> float_dtypeWitness that the dtype is a floating-point dtype. Encodes ('a = float) at the type level to avoid enumerating float constructors at call sites.
Find the first floating-point tensor in the tree and return a float dtype witness, if any. Floating-point dtypes include float32/float64/float16, bfloat16, and float8 variants.
Like first_float_dtype but raises if no floating-point tensors are present.
Convenience
Printing