Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
477403d
glm: a kept state that goes stale drops its cache entry at once
heitke Oct 14, 2026
8be4d32
glm: expire dead cache states at the host boundary, borrow safely
heitke Oct 14, 2026
027ddea
Merge remote-tracking branch 'origin/main' into glm-cache-slot-guard
heitke Oct 14, 2026
5a4987b
Living Weights: the learner, pocket and fits move to zig/src/living, …
ZackSample Oct 15, 2026
75978a1
Living Weights learns into any family described as data: the family's…
ZackSample Oct 15, 2026
c6418f3
Flash Next's embedding row matches the host dequant of the same MLX g…
AdrianBinDC Oct 7, 2026
1dca5c1
Layer 0's first hyper-connection matches its host check on one token,…
AdrianBinDC Oct 7, 2026
cd57bfc
Layer 0's linear-attention projection matches the host group-32 dot o…
AdrianBinDC Oct 7, 2026
37dec96
Layer 0's linear-attention convolution, recurrence and output multipl…
AdrianBinDC Oct 7, 2026
2590dfc
Layer 0's second hyper-connection matches its host check on one token…
AdrianBinDC Oct 7, 2026
58fed6c
Layer 0's experts match the host check on one token, the top 10 and t…
AdrianBinDC Oct 7, 2026
69c4888
Layer 3's full attention matches the host check on one decode token, …
AdrianBinDC Oct 7, 2026
8a4add2
Layer 7's full attention matches the host check on one decode token, …
AdrianBinDC Oct 7, 2026
40472fb
Layer 11's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
307312a
Layer 15's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
d91b049
Layer 19's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
fcd0c15
Layer 23's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
0b4eab2
Layer 27's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
fbb2776
Layer 31's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
43961f6
Layer 35's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
8949cd1
Layer 39's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
2bb8a78
Layer 43's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
8c50b42
Layer 47's full attention matches the host check on one decode token,…
AdrianBinDC Oct 7, 2026
1bbed57
Layer 2's n-gram table matches the host dequant on one decode token, …
AdrianBinDC Oct 7, 2026
994c2ff
The final mix and the word scores match the host check on one decode …
AdrianBinDC Oct 7, 2026
7f0794d
One drafts-off prompt matches the Python engine, eight greedy token i…
AdrianBinDC Oct 7, 2026
0d04c43
Keep the drafts-off prompt match after splitting the forward and pack…
AdrianBinDC Oct 7, 2026
785896e
Flash Next CUDA: prompt ids and positions upload on the compute strea…
ZackSample Oct 11, 2026
8391cac
native/cuda.zig takes each CUDA family's prompt-cache copies, cache r…
ZackSample Oct 15, 2026
bd35940
CUDA experts over a window's or a prompt chunk's rows, each row with …
ZackSample Oct 15, 2026
2484c93
triton_aot_pack.py: a constexpr Triton folded from None is left out, …
ZackSample Oct 15, 2026
5cf4291
Flash Next CUDA: prompts and decode rounds on one batched pass, with …
ZackSample Oct 15, 2026
035b7f9
Flash Next CUDA: the MTP head, its draft chains, verify windows and t…
ZackSample Oct 15, 2026
1ac9bd0
Flash Next CUDA serves several streams through the lane core: drafted…
ZackSample Oct 15, 2026
62865ab
Flash Next CUDA: buffers are zeroed on the compute stream, so a pass …
ZackSample Oct 15, 2026
8d32cd3
Docs: Flash Next on CUDA, its recipe, the CUDA and Flash Next pages, …
ZackSample Oct 15, 2026
b45e26a
Flash Next CUDA refuses the config.json settings its kernels fix: RMS…
ZackSample Oct 15, 2026
9fa628b
Flash Next CUDA: a failed zero fill frees the buffer it was filling
ZackSample Oct 15, 2026
475df92
Flash Next CUDA: a pass's uploads read pinned staging the scratch own…
ZackSample Oct 15, 2026
1e86036
Core: router logits and softmax top-k rows for every CUDA family (rou…
ZackSample Oct 15, 2026
794d273
Core: token rows in groups of 32 with a copy a stream, and RMS rows w…
ZackSample Oct 15, 2026
ea7d098
Flash Next CUDA: its own glue kernels, flashnext_hc.cu and flashnext_…
ZackSample Oct 15, 2026
38c9c63
Flash Next CUDA boots on its own glue; a captured set that holds ever…
ZackSample Oct 15, 2026
235ea01
Flash Next CUDA: TF_FLASHNEXT_OWNED runs named entry points on our gl…
ZackSample Oct 15, 2026
7746bb9
Docs: Flash Next on CUDA boots on its own kernels; a captured set is …
ZackSample Oct 15, 2026
e7163c5
Flash Next CUDA: each layer_types label must be the exact role the ke…
ZackSample Oct 15, 2026
4b46157
Flash Next CUDA: a failed upload or record drains the stream before t…
ZackSample Oct 15, 2026
354f60d
CUDA: a Gated DeltaNet layer's input-gradient backward, every gradien…
ZackSample Oct 15, 2026
c106f2e
CUDA: input gradients of 4-bit (group 32) products, routed SwiGLU exp…
ZackSample Oct 15, 2026
a41cc2c
CUDA: gated attention's input gradients over 4-bit projections (a hea…
ZackSample Oct 15, 2026
0211f4d
Flash Next CUDA: the hyper-connections' and the pocket's input gradie…
ZackSample Oct 15, 2026
8e234db
Merge lw-b-core (#878, Living Weights as a core module) onto lw-c-fnb…
ZackSample Oct 15, 2026
e2779f6
Flash Next CUDA: a taught folder's pocket in every pass, and the batc…
ZackSample Oct 15, 2026
41ad4d4
Flash Next CUDA: Living Weights' trainer over the batched pass, and f…
ZackSample Oct 15, 2026
f5d6a4c
Living Weights learns into Qwen3.8 Flash Next on CUDA (--slide, GB10)…
ZackSample Oct 15, 2026
bad3a2a
Docs: Living Weights on Qwen3.8 Flash Next (CUDA, GB10), as measured;…
ZackSample Oct 15, 2026
514e4ee
Flash Next's pocket leaves an untaught stream's rows: a lesson writer…
ZackSample Oct 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Living Weights: the learner, pocket and fits move to zig/src/living, …
…unchanged

The learner, its whole-lesson and routed paths, the pocket and its fits and helpers move from families/nemotron to a
`living` module that both builds import, as 19 renames with no change to their contents. The family-neutral half of
learn_shape.zig (block sizes, Adam settings, direction lengths) moves with them; Nemotron's learn_shape.zig keeps where
its blocks sit and names the shared constants from the module. Nemotron's files import the moved ones through the
module. The learner's tests now also run on Linux, as `zig build test-living` and under test-cuda-host. No behaviour
change.
  • Loading branch information
ZackSample committed Oct 15, 2026
commit 5a4987b7702255cd0e8cb21b50b06834fd4c076b
8 changes: 5 additions & 3 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ fn metalTargets(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.b
}

/// The server and distribution use the same embedded-source Metal engine.
fn metalEngineModules(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, draft_ids: *std.Build.Module) struct { metal: *std.Build.Module, lanes: *std.Build.Module, fabric: *std.Build.Module, sources: *std.Build.Module, engine: *std.Build.Module, qwen27: qwen27_build.Shared } {
fn metalEngineModules(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, draft_ids: *std.Build.Module) struct { metal: *std.Build.Module, lanes: *std.Build.Module, fabric: *std.Build.Module, sources: *std.Build.Module, engine: *std.Build.Module, qwen27: qwen27_build.Shared, living: *std.Build.Module } {
const metal = b.createModule(.{
.root_source_file = b.path("zig/src/metal/metal.zig"),
.target = target,
Expand All @@ -553,14 +553,16 @@ fn metalEngineModules(b: *std.Build, target: std.Build.ResolvedTarget, optimize:
const lanes = b.createModule(.{ .root_source_file = b.path("zig/src/core/lanes/lanes.zig"), .target = target, .optimize = optimize, .link_libc = true });
const fabric = b.createModule(.{ .root_source_file = b.path("zig/src/fabric/fabric.zig"), .target = target, .optimize = optimize, .link_libc = true });
const sources = b.createModule(.{ .root_source_file = b.path("zig/kernels/metal/sources.zig") });
// Living Weights' learner, pocket and fits, which Nemotron's lessons import
const living = b.createModule(.{ .root_source_file = b.path("zig/src/living/living.zig"), .target = target, .optimize = optimize, .link_libc = true });
const engine = b.createModule(.{
.root_source_file = b.path("zig/src/tensorfold.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "kernel_sources", .module = sources }, .{ .name = "nemotron_draft_ids", .module = draft_ids }, .{ .name = "lanes", .module = lanes }, .{ .name = "fabric", .module = fabric } },
.imports = &.{ .{ .name = "metal", .module = metal }, .{ .name = "kernel_sources", .module = sources }, .{ .name = "nemotron_draft_ids", .module = draft_ids }, .{ .name = "lanes", .module = lanes }, .{ .name = "fabric", .module = fabric }, .{ .name = "living", .module = living } },
});
return .{ .metal = metal, .lanes = lanes, .fabric = fabric, .sources = sources, .engine = engine, .qwen27 = qwen27_build.engineModules(b, target, metal, sources, engine) };
return .{ .metal = metal, .lanes = lanes, .fabric = fabric, .sources = sources, .engine = engine, .living = living, .qwen27 = qwen27_build.engineModules(b, target, metal, sources, engine) };
}

pub fn distMetalServer(b: *std.Build, target: std.Build.ResolvedTarget, draft_ids: *std.Build.Module, build_options: *std.Build.Step.Options, sdk: []const u8) *std.Build.Step.Compile {
Expand Down
11 changes: 9 additions & 2 deletions zig/build/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,22 @@ fn runtime(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builti
return cuda;
}

fn family(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module, draft_ids: *std.Build.Module) struct { core: *std.Build.Module, lanes: *std.Build.Module, nemotron: *std.Build.Module, tokenizer: *std.Build.Module, heat: *std.Build.Module } {
fn family(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode, cuda: *std.Build.Module, draft_ids: *std.Build.Module) struct { core: *std.Build.Module, lanes: *std.Build.Module, nemotron: *std.Build.Module, tokenizer: *std.Build.Module, heat: *std.Build.Module, living: *std.Build.Module } {
const tokenizer = b.createModule(.{ .root_source_file = b.path("zig/src/core/tokenizer/tokenizer.zig"), .target = target, .optimize = optimize, .link_libc = true });
const core = b.createModule(.{ .root_source_file = b.path("zig/src/core/root.zig"), .target = target, .optimize = optimize, .link_libc = true });
core.addImport("tokenizer", tokenizer);
const lanes = b.createModule(.{ .root_source_file = b.path("zig/src/core/lanes/lanes.zig"), .target = target, .optimize = optimize, .link_libc = true });
const heat = b.createModule(.{ .root_source_file = b.path("zig/src/core/heat.zig"), .target = target, .optimize = optimize, .link_libc = true });
// Living Weights' learner, pocket and fits, which a family's lessons import
const living = b.createModule(.{ .root_source_file = b.path("zig/src/living/living.zig"), .target = target, .optimize = optimize, .link_libc = true });
const nemotron = b.createModule(.{ .root_source_file = b.path("zig/src/families/nemotron/cuda.zig"), .target = target, .optimize = optimize, .link_libc = true });
nemotron.addImport("cuda", cuda);
nemotron.addImport("core", core);
nemotron.addImport("lanes", lanes);
nemotron.addImport("heat", heat);
nemotron.addImport("nemotron_draft_ids", draft_ids);
return .{ .core = core, .lanes = lanes, .nemotron = nemotron, .tokenizer = tokenizer, .heat = heat };
nemotron.addImport("living", living);
return .{ .core = core, .lanes = lanes, .nemotron = nemotron, .tokenizer = tokenizer, .heat = heat, .living = living };
}

/// Linux targets: fatbins (-Dnvcc builds them, -Dfatbins embeds prebuilt ones), `tensorfold` and `tf-cuda-test`.
Expand Down Expand Up @@ -211,6 +214,10 @@ pub fn hostTests(b: *std.Build, draft_ids: *std.Build.Module, build_options: *st
}
// the tokenizer's own tests (memo, steps, regex, unicode) run here: no other test binary reaches them
for ([_]*std.Build.Module{ cuda, mods.core, mods.lanes, mods.nemotron, mods.heat, mods.tokenizer, native, stagger(b, host, .debug) }) |m| step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = m })).step);
// Living Weights' learner on the host, beside the family that imports it
const living_run = b.addRunArtifact(b.addTest(.{ .root_module = mods.living }));
step.dependOn(&living_run.step);
b.step("test-living", "Living Weights' learner, pocket and fits, on the host").dependOn(&living_run.step);
const cli = b.createModule(.{ .root_source_file = b.path("zig/src/cli/cuda_main.zig"), .target = host, .optimize = .debug, .link_libc = true });
cli.addImport("cuda", cuda);
cli.addImport("core", mods.core);
Expand Down
4 changes: 2 additions & 2 deletions zig/src/families/nemotron/adapters.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const cfg = @import("config.zig");
const wts = @import("weights.zig");
const ops = @import("train_ops.zig");
const pl = @import("prefill_launch.zig");
const subspace = @import("subspace.zig");
const subspace = @import("living").subspace;

const Buffer = mtl.Buffer;
const At = pl.At;
const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked;

const shape = @import("learn_shape.zig");
const route = @import("lesson_route.zig");
const route = @import("living").lesson_route;

pub const block = shape.block;
pub const max_rank = shape.max_rank;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/backend.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const lanes = @import("lanes");
const Fence = @import("../../core/fence.zig").Fence;
const fwd = @import("forward.zig");
const st = @import("state.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const layers = @import("layers.zig");
const mtp = @import("mtp.zig");
const timing = @import("timing.zig");
Expand Down
2 changes: 0 additions & 2 deletions zig/src/families/nemotron/cuda.zig
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,5 @@ test {
_ = @import("cuda_prompt_cuts.zig");
_ = @import("cuda_profile_window.zig");
_ = reuse;
_ = @import("learner.zig");
_ = @import("subspace.zig");
_ = @import("cuda_train_back.zig");
}
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_engine.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const head_fields = @import("cuda_mtp.zig").seq_fields;
const sampler = @import("cuda_sampler.zig");
const segs = @import("cuda_segments.zig");
const train_ops = @import("cuda_train_ops.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const heat = @import("heat");
const seq_graphs = @import("cuda_seq_graphs.zig");
const prompt_rows = @import("cuda_prompt_rows.zig");
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_forward.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const weights = @import("cuda_weights.zig");
const state = @import("cuda_state.zig");
const Dump = @import("cuda_dump.zig").Dump;
const train_ops = @import("cuda_train_ops.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const kept = @import("cuda_marks.zig");

pub const Delta = enum { none, dense, moe };
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_lanes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const prompt_rows = @import("cuda_prompt_rows.zig");
const config = @import("config.zig");
const seq_graphs = @import("cuda_seq_graphs.zig");
const costs = @import("cuda_costs.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;

const be = lanes.backend;
const LogRow = lanes.LogprobRow;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_prompt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const marks = @import("cuda_marks.zig");
const cuts = @import("cuda_prompt_cuts.zig");
const prompt_rows = @import("cuda_prompt_rows.zig");
const reuse = @import("cuda_reuse.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const heat = @import("heat");
const pin_sampled = engine.pin_sampled;
const pin_prompt = engine.pin_prompt;
Expand Down
4 changes: 2 additions & 2 deletions zig/src/families/nemotron/cuda_sites.zig
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const cuda = @import("cuda");
const Config = @import("config.zig").Config;
const weights = @import("cuda_weights.zig");
const train_ops = @import("cuda_train_ops.zig");
const subspace = @import("subspace.zig");
const subspace = @import("living").subspace;
const shape = @import("learn_shape.zig");
const route = @import("lesson_route.zig");
const route = @import("living").lesson_route;

pub const block = shape.block;
pub const max_rank = shape.max_rank;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_slide.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Nemotron's Sliding Weights learner on CUDA: learner.zig's lessons over the CUDA trainer, the engine and its shards.
const std = @import("std");
const cuda = @import("cuda");
const lessons = @import("learner.zig");
const lessons = @import("living").learner;
const train = @import("cuda_train.zig");
const engine = @import("cuda_engine.zig");
const sites_mod = @import("cuda_sites.zig");
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_state.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Device buffers of one Nemotron sequence: its caches and recurrent state, and the scratch a window or chunk uses.

const std = @import("std");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const cuda = @import("cuda");
const Config = @import("config.zig").Config;
const kern = @import("cuda_kernels.zig");
Expand Down
6 changes: 3 additions & 3 deletions zig/src/families/nemotron/cuda_train.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Learning in the weights on CUDA (train.zig on Metal): sequences side by side forward, their losses, and back.
const std = @import("std");
const train_mode = @import("train_mode.zig");
const train_mode = @import("living").train_mode;
const cuda = @import("cuda");
const core = @import("core");
const Config = @import("config.zig").Config;
Expand All @@ -10,12 +10,12 @@ const fwd = @import("cuda_forward.zig");
const engine = @import("cuda_engine.zig");
const ops = @import("cuda_train_ops.zig");
const sites_mod = @import("cuda_sites.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const back = @import("cuda_train_back.zig");
const tfw = @import("cuda_train_fwd.zig");
const lay = @import("cuda_train_layout.zig");
const prefix = @import("cuda_train_prefix.zig");
const Count = @import("pocket_clock.zig").Count;
const Count = @import("living").pocket_clock.Count;
const Source = @import("cuda_source.zig").Source;

/// Rows a sequence learns from at most: a question and its answer (attention's backward reads at most 256).
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_train_fwd.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const state = @import("cuda_state.zig");
const weights = @import("cuda_weights.zig");
const fwd = @import("cuda_forward.zig");
const train_ops = @import("cuda_train_ops.zig");
const Span = @import("train_mode.zig").Span;
const Span = @import("living").train_mode.Span;
const Store = @import("cuda_train_prefix.zig").Store;

/// The open fact's pocket neurons scaled row by row: `rows` f32 [rows] on the device, at layer l from `from[l]` on.
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/cuda_train_ops.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! The training kernels (train.cu) as calls on one stream: the loss, the change, products and each layer's backward.
const std = @import("std");
const cuda = @import("cuda");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;

/// A Mamba layer's shape as the mixer kernels read it (train.cu's Shape).
pub const Shape = extern struct { rows: c_int, heads: c_int, dh: c_int, groups: c_int, n: c_int, inner: c_int, conv: c_int, proj: c_int };
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/forward.zig
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const fullVocabulary = @import("lanes").gpu_full.fullVocabulary;
const gpu_rule = @import("lanes").gpu_rule;
const row = @import("../../core/row_projection.zig");
const Masks = @import("../../core/grammar_mask.zig").Masks;
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;

const Buffer = mtl.Buffer;
pub const Enc = encoder.Enc;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/layers.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const st = @import("state.zig");
const fwd = @import("forward.zig");
const kern = @import("kernels.zig");
const tree = @import("tree.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const max_blocks = @import("learn_shape.zig").max_blocks;

const Buffer = mtl.Buffer;
Expand Down
39 changes: 14 additions & 25 deletions zig/src/families/nemotron/learn_shape.zig
Original file line number Diff line number Diff line change
@@ -1,30 +1,19 @@
//! The learned change's shape, shared by the Metal and CUDA learners: blocks of ranks, their scale and gates.
//! The learned change's shape on Nemotron: the shared constants (living/learn_shape.zig) and where its blocks sit.
const std = @import("std");
const Config = @import("config.zig").Config;

pub const block = 16; // ranks a lesson adds at each layer
pub const max_rank = 2048; // a hundred and twenty-eight lessons' blocks, each layer's buffers grown to it as lessons come
pub const max_blocks = max_rank / block;
pub const scale: f32 = 10;
pub const avoid_dims = 192; // directions sketched from the inputs a new block must leave alone
pub const candidates = 64; // directions sketched from the fact's inputs, which a new block's are chosen among

/// Adam's settings for a block's outputs (its gate keeps them off what must stay): rate, moments' decays, epsilon.
pub const hyper = [4]f32{ 3e-4, 0.9, 0.999, 1e-8 };

/// Adam's settings at step `step`: the rate halves every `settle` steps, three times at most, so later rounds refine.
pub fn hyperAt(step: u64) [4]f32 {
var h = hyper;
h[0] /= @as(f32, @floatFromInt(@as(u32, 1) << @intCast(@min(step / settle, 3))));
return h;
}
pub const settle = 60;

/// Each new input direction's length, as MLX's LoRA draws its down factor's columns (uniform within 1 / sqrt(in)).
pub const a_norm: f32 = 0.577;

/// A block's directions' squared length: a row's cosine with one is (x . a) / sqrt(unit |x|^2).
pub const unit = a_norm * a_norm;
const shape = @import("living").learn_shape;

pub const block = shape.block;
pub const max_rank = shape.max_rank;
pub const max_blocks = shape.max_blocks;
pub const scale = shape.scale;
pub const avoid_dims = shape.avoid_dims;
pub const candidates = shape.candidates;
pub const hyper = shape.hyper;
pub const hyperAt = shape.hyperAt;
pub const settle = shape.settle;
pub const a_norm = shape.a_norm;
pub const unit = shape.unit;

/// Layer i's output projection as the checkpoint names its module: the one a lesson's change sits after.
pub fn moduleName(buf: []u8, c: Config, i: usize) ![]const u8 {
Expand Down
4 changes: 2 additions & 2 deletions zig/src/families/nemotron/nemotron.zig
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub const learned = @import("learned.zig");
pub const train_ops = @import("train_ops.zig");
pub const train_back = @import("train_back.zig");
pub const train = @import("train.zig");
pub const pocket_fit = @import("pocket_fit.zig");
pub const lesson_route = @import("lesson_route.zig");
pub const pocket_fit = @import("living").pocket_fit;
pub const lesson_route = @import("living").lesson_route;
pub const snapshot = @import("snapshot.zig");
pub const learned_prompts = @import("learned_prompts.zig");

Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/prefill.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const pk = @import("prefill_kernels.zig");
const pl = @import("prefill_launch.zig");
const mixers = @import("prefill_mixers.zig");
const layers = @import("layers.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const Model = @import("model.zig").Model;

const Buffer = mtl.Buffer;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/slide.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Nemotron's Sliding Weights learner on Metal: learner.zig's lessons over the Metal trainer, its weights and shards.
const std = @import("std");
const lessons = @import("learner.zig");
const lessons = @import("living").learner;
const train = @import("train.zig");
const backend = @import("backend.zig");
const adapters = @import("adapters.zig");
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/state.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const std = @import("std");
const mtl = @import("metal");
const cfg = @import("config.zig");
const fwd = @import("forward.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;

const opts = mtl.ResourceOptions.shared | mtl.ResourceOptions.untracked;

Expand Down
6 changes: 3 additions & 3 deletions zig/src/families/nemotron/train.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Learning in the weights: sequences side by side forward through every layer, their losses, back to each change.
const std = @import("std");
const train_mode = @import("train_mode.zig");
const train_mode = @import("living").train_mode;
const mtl = @import("metal");
const cfg = @import("config.zig");
const st = @import("state.zig");
Expand All @@ -11,9 +11,9 @@ const back = @import("train_back.zig");
const job = @import("train_job.zig");
const adapters = @import("adapters.zig");
const backend = @import("backend.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const prefix = @import("train_prefix.zig");
const Count = @import("pocket_clock.zig").Count;
const Count = @import("living").pocket_clock.Count;

const Metal = backend.Metal;
const At = pl.At;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/train_back.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const pre = @import("prefill.zig");
const pl = @import("prefill_launch.zig");
const ops = @import("train_ops.zig");
const adapters = @import("adapters.zig");
const Span = @import("train_mode.zig").Span;
const Span = @import("living").train_mode.Span;
const Store = @import("train_prefix.zig").Store;

const Buffer = mtl.Buffer;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/train_forward.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const wts = @import("weights.zig");
const pre = @import("prefill.zig");
const pl = @import("prefill_launch.zig");
const layers = @import("layers.zig");
const Span = @import("train_mode.zig").Span;
const Span = @import("living").train_mode.Span;
const Store = @import("train_prefix.zig").Store;

const At = pl.At;
Expand Down
4 changes: 2 additions & 2 deletions zig/src/families/nemotron/train_job.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! A training pass as one command buffer: its sequences forward through every layer, their losses, back to each change.
const std = @import("std");
const train_mode = @import("train_mode.zig");
const train_mode = @import("living").train_mode;
const mtl = @import("metal");
const cfg = @import("config.zig");
const fwd = @import("forward.zig");
Expand All @@ -11,7 +11,7 @@ const back = @import("train_back.zig");
const tf = @import("train_forward.zig");
const adapters = @import("adapters.zig");
const backend = @import("backend.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;
const train = @import("train.zig");
const Trainer = train.Trainer;
const pack_rows = train.pack_rows;
Expand Down
2 changes: 1 addition & 1 deletion zig/src/families/nemotron/train_ops.zig
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const wts = @import("weights.zig");
const pl = @import("prefill_launch.zig");
const pk = @import("prefill_kernels.zig");
const layers = @import("layers.zig");
const lesson_route = @import("lesson_route.zig");
const lesson_route = @import("living").lesson_route;

const Buffer = mtl.Buffer;
const At = pl.At;
Expand Down
File renamed without changes.
File renamed without changes.
Loading