Blyx

BlyxTorch

CPU neural-network framework and CLI · 0.2.0

Train dense networks with SGD or Adam, inspect parameter gradients, and generate standalone Blyx models for regression or classification.

Install BlyxTorch in your editor

Extension RahulChaube.blyxtorch · 0.2.1

The extension includes the native CPU trainer for Windows x64, Linux x64 and Apple Silicon macOS, plus two editable training projects.

Create an empty .blyx file, type bt-sensor and accept the completion. Choose Blyx: Run File to run the example.

For an offline installation, choose Extensions: Install from VSIX for Blyx Language first, then for BlyxTorch.

Download the companion Blyx Language VSIX

Build a project with BlyxTorch

Calibrate a desk sensor

Fit a gain and an offset from five synthetic reference readings using BlyxTorch automatic differentiation. The model predicts 18.625 and 22.375 degrees for two readings held out of training.

Predict print-queue waits

Classify four new print jobs using a trained two-input network. The starter includes 16 synthetic training rows and six separate evaluation rows. With seed 7, the mean evaluation loss is about 0.00234.

The starter includes the editable programs, CSV data, saved weights and three editor tasks. Extract it, open BlyxTorch.code-workspace, then choose Terminal → Run Task → BlyxTorch: Evaluate print queue.

Download both projects

Run the command-line tool

Extract the archive for your machine and run the included CSV example. Use .\blyxtorch.exe in PowerShell. The input header is x0,x1,y0.

./blyxtorch train fixtures/xor.csv 250 0.03 4 adam 7

Training writes a checkpoint to standard output. The handbook shows how to save it, predict and inspect gradients on each platform.

brew install rahulchaube1/blyx/blyxtorch

On Windows x64, add the Blyx Scoop bucket once, then install the tool from PowerShell.

scoop bucket add blyx https://github.com/Rahulchaube1/scoop-blyx
scoop install blyx/blyxtorch
Scoop manifest

Install with Conda

Create an environment containing BlyxTorch 0.2.0, its Blyx source and a runnable example. Run the second command with Blyx 0.2.1, Rust and a host linker installed.

conda create -y --prefix ./blyx-env --override-channels -c https://rahulchaube1.github.io/blyx-packages blyxtorch=0.2.0=0
blyxc native-run ./blyx-env/share/blyx/blyxtorch/main.blyx

To use this package in your application, copy share/blyx/blyxtorch/vendor/blyxtorch from the environment into your project's vendor directory.

Install the full collection with Homebrew or Scoop

Import into a Blyx project

Install Blyx 0.2.1, Rust 1.85 or newer and a host linker. From the directory containing your entry file, clone this tagged release.

git clone --depth 1 --branch v0.2.0 https://github.com/Rahulchaube1/blyxtorch.git vendor/blyxtorch

Save this as main.blyx beside vendor and run blyxc native-run main.blyx.

use vendor::blyxtorch::blyxtorch;

fn main() {
    let weight = bt_dual(1.0, 1.0);
    let x = bt_dual(2.0, 0.0);
    let target = bt_dual(5.0, 0.0);
    let loss = bt_square(bt_sub(bt_mul(weight, x), target));
    println!(at(loss, 0));
    println!(at(loss, 1));
    let updated = bt_dual(at(weight, 0) - 0.125 * at(loss, 1), 0.0);
    println!(at(bt_square(bt_sub(bt_mul(updated, x), target)), 0));
}

Expected output

9
-12
0

API and input requirements

BlyxTorch 0.2.0 uses fixed-shape float64 networks on CPU. Each layer width is 1–64. A model supports up to eight affine layers and 1,024 trainable parameters. The prebuilt 2–4–1 classifier runs immediately. Generating a new executable requires Blyx 0.2.1, Rust and a host linker on the build machine.

APIUse
bt_dual(value, tangent), bt_square(v)Differentiate a scalar expression in the portable library. The result holds its value and directional derivative.
bt_add, bt_sub, bt_mul, bt_div, bt_relu, bt_tanh, bt_sigmoidCompose differentiable operations on dual numbers.
bt_init(seed), bt_predict(weights, features)Initialize and run a generated model module.
bt_sample_loss(weights, features, target), bt_loss_grad(weights, features, target)Return a loss or a loss followed by every parameter gradient.
blyxtorch emit WIDTHS OBJECTIVE ACTIVATIONGenerate a complete Blyx model and CLI. Use mse, binary or softmax with tanh, relu or sigmoid.
train-score TRAIN.csv LABELLED.csvTrain once and report row count and loss on a separate labelled CSV.
train-predict TRAIN.csv FEATURES.csvTrain once and write a probability for each new feature row.

Develop and contribute

Open the tagged source to read the implementation and examples. Include the smallest reproducible Blyx program, compiler version and expected result when reporting an issue.