Skip to content

Commit 96fed7c

Browse files
DanielBoigkclaude
andcommitted
v0.3.0: subflows in both generators (Moonkale ADR-0021 stage C)
Mistral's stage C work, finished by Claude while Mistral's tokens are out. ModelingToolkit flattens: a subsystem's components join the parent circuit under per-instance names (rc_filter_1_resistor_1 — `_`, since ModelingToolkit reads `₊` as its namespace separator at runtime), each boundary pin's inner net merges with the parent's, nested subsystems recurse (bounded depth), and the one-library rule covers the inside. A boundary end takes its pin from the pseudo-block's id and must be a declared pin; "both sides" counts inner and parent wires separately, so two inner wires on one pin are still one-sided. Lux splices: a subflow with exactly one input and one output is a sub-Chain — its layer path spliced in, nested subflows recursing, a pass-through splicing nothing. Pins ext-api-2026-10-13 (the subflow model); flow::BOUNDARY is still unreleased there, so the prefix is a local constant. 15 tests, clippy -D warnings clean; Moonkale's mtk.mjs simulates the flattened RC to 99.3 %. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y1i4K2wqeXyatSepWdxX4R
1 parent d5b8f65 commit 96fed7c

4 files changed

Lines changed: 1023 additions & 109 deletions

File tree

‎Cargo.toml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "moonkale-ext-lux"
3-
version = "0.2.0"
3+
version = "0.3.0"
44
edition = "2021"
55
license = "MIT"
66
description = "A Lux.jl block library for Moonkale's flow editor, with Julia codegen. An opt-in Moonkale extension (Milestone 6); its own repository since Milestone 18 phase 6.4."
@@ -10,4 +10,4 @@ repository = "https://github.com/MathStruct/moonkale-julia"
1010
dioxus = "0.7.10"
1111
# Moonkale's extension contract, by git tag (never a branch): `ext-api-YYYY-MM-DD` marks
1212
# a compatible state of moonkale-core / moonkale-ext-api / moonkale-graph-render.
13-
moonkale-ext-api = { git = "https://github.com/MathStruct/Moonkale", tag = "ext-api-2026-10-12" }
13+
moonkale-ext-api = { git = "https://github.com/MathStruct/Moonkale", tag = "ext-api-2026-10-13" }

‎README.md‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# moonkale-julia
22

3-
Julia for [Moonkale](https://github.com/MathStruct/Moonkale) — today one crate, **`moonkale-ext-lux`**: a [Lux.jl](https://lux.csail.mit.edu) block library for Moonkale's flow editor. Layers (`Dense`, `Conv`, `MaxPool`, `Flatten`, `Dropout`, `BatchNorm`), activations, an input, a loss and an optimiser, with tensor-shape ports (a shape mismatch is a red wire), and code generation to a Julia file (`Lux.Chain(…)` plus a training scaffold) that runs with `julia model.jl`.
3+
Julia for [Moonkale](https://github.com/MathStruct/Moonkale) — today one crate, **`moonkale-ext-lux`**, with two block libraries for Moonkale's flow editor:
4+
5+
- **Lux.jl** ([lux.csail.mit.edu](https://lux.csail.mit.edu)): layers (`Dense`, `Conv`, `MaxPool`, `Flatten`, `Dropout`, `BatchNorm`), activations, an input, a loss and an optimiser, with tensor-shape ports (a shape mismatch is a red wire), and code generation to a Julia file (`Lux.Chain(…)` plus a training scaffold) that runs with `julia model.jl`.
6+
- **ModelingToolkit** (since v0.2.0): acausal, domain-typed components — Resistor, Capacitor, Inductor, Voltage, Ground; Mass, Spring, Damper, Fixed — and code generation to `circuit.jl`: `@named` components, one `connect` per net, `structural_simplify` and a solved ODE problem.
7+
8+
Both generators understand **subflows** (since v0.3.0, Moonkale ADR-0021): an MTK subsystem flattens into the parent circuit, its components named per instance (`rc_filter_1_resistor_1`) and its boundary pins merging the inner and outer nets; a Lux subflow with one input and one output splices its layer path into the parent `Chain`.
49

510
It lived in the Moonkale repository as `packages/extensions/lux` until Milestone 18 (phase 6.4): it is what its author needs, and for everyone else an opt-in extension, so it is off by default and built only when asked for.
611

@@ -14,10 +19,10 @@ cd packages/desktop && dx serve --features julia # or: cargo build -p deskt
1419
cd packages/web && dx serve --features julia
1520
```
1621

17-
then switch it on in **Settings → Extensions → Lux.jl library**; the flow editor's palette gets the Lux blocks, and **Generate** writes the Julia file. The generated code needs `Lux`, `Optimisers`, `Zygote` and `Random` in your Julia environment; the extension itself has no Julia dependency.
22+
then switch it on in **Settings → Extensions → Lux.jl library**; the flow editor's palette gets the Lux blocks, and **Generate** writes the Julia file. The generated Lux code needs `Lux`, `Optimisers`, `Zygote` and `Random` in your Julia environment, the circuit `ModelingToolkit`, `ModelingToolkitStandardLibrary` and `OrdinaryDiffEq`; the extension itself has no Julia dependency.
1823

1924
## Developing it
2025

21-
It depends on Moonkale's extension contract by **git tag** (`lib-v1`; see Moonkale's `packages/ext-api/CHANGELOG.md`), so `cargo test` here builds against that tag. To work on both at once, point Moonkale's distribution at a local checkout (`[patch."https://github.com/MathStruct/moonkale-julia"]` in Moonkale's `Cargo.toml`).
26+
It depends on Moonkale's extension contract by **git tag** (`ext-api-YYYY-MM-DD`, today `ext-api-2026-10-13`; see Moonkale's `packages/ext-api/CHANGELOG.md`), so `cargo test` here builds against that tag. To work on both at once, point Moonkale's distribution at a local checkout (`[patch."https://github.com/MathStruct/moonkale-julia"]` in Moonkale's `Cargo.toml`).
2227

2328
Notes on the code: `lux.md`. License: MIT.

0 commit comments

Comments
 (0)