Skip to content

Repository files navigation

FastDL 0.1.0 [ALPHA-2026-08] β€” Deep Learning Engine, Tensor Computing & Neural Backprop for Java

Status License: MIT Java Platform JitPack


⚑ Lightweight Deep Learning, high-performance tensor operations, gradient descent optimizers, and neural layers for the FastJava ecosystem.

FastDL is the Deep Learning engine of the FastJava ecosystem. While FastML focuses on classical, deterministic pattern models with hand-crafted features (Centroids, KNN, SVM), FastDL provides the neural substrate: Multidimensional Tensors, Automatic Differentiation / Backpropagation, Neural Layers (Dense, ReLU, Conv), Optimizers (SGD, Momentum, Adam), and Loss surfaces.

// Quick Start β€” Example
import fastdl.FastDL;
import fastdl.FastDL.Sequential;
import fastdl.loss.MSELoss;
import fastdl.optim.SGD;
import fastdl.tensor.Tensor;

public class Demo {
    public static void main(String[] args) {
        // 1. Define Multi-Layer Perceptron (MLP)
        Sequential net = FastDL.sequential(
            FastDL.dense(2, 8),
            FastDL.relu(),
            FastDL.dense(8, 1)
        );

        // 2. Setup Optimizer and Loss
        SGD optimizer = FastDL.sgd(net.parameters(), 0.01f, 0.9f);
        MSELoss criterion = FastDL.mse();

        // 3. Forward Pass & Training Step
        Tensor x = FastDL.tensor(new float[]{0.5f, -0.2f}, 1, 2);
        Tensor target = FastDL.tensor(new float[]{1.0f}, 1, 1);

        optimizer.zeroGrad();
        Tensor pred = net.forward(x);
        float loss = criterion.forward(pred, target);
        
        net.backward(criterion.backward(pred, target));
        optimizer.step();

        System.out.printf("Loss: %.4f | Output: %s%n", loss, pred);
    }
}

Table of Contents


Why FastDL?

Standard Deep Learning frameworks in the Java ecosystem (like DL4J) suffer from bloated dependencies, complex native bridges, and heavy memory footprints.

FastDL delivers:

  • 100% Pure JVM Core with Optional Native SIMD/GPU Acceleration β€” Instant startup, zero setup friction.
  • Microsecond Tensor Operations β€” Cache-friendly flat arrays with stride-based multidimensional indexing.
  • Zero Framework Bloat β€” Minimalist, PyTorch-like layer and optimizer APIs designed specifically for FastJava.
  • Mini LLM / Transformer Foundations β€” including attention, feedforward blocks, embeddings, causal generation, and training loops.
  • TinyStories-Ready Workflow β€” local datasets, tokenizer pipelines, and model training code built for small-language-model experimentation.

Key Features

  • 🧱 Dense & Multidimensional Tensors β€” Zero-copy flat buffers, strides, automatic gradient tracking (grad).
  • 🧠 Neural Layers & Modular Sequentials β€” Dense, ReLU, LayerNorm, GELU, and composable model blocks.
  • ⚑ Optimizers with Momentum β€” Stochastic Gradient Descent and AdamW for transformer-style training.
  • πŸ“‰ Non-Convex Optimization & Loss Surfaces β€” Built-in loss metrics (MSELoss, CrossEntropyLoss) and minima exploration.
  • πŸ€– Mini Transformer / GPT-Style Stack β€” token embeddings, positional encoding, causal attention, feedforward blocks, and text generation.
  • πŸ“š TinyStories Demo Path β€” end-to-end local text-model demo workflow built around TinyStories-style corpora.

API Quick Reference

MLP / Core

Method Description
FastDL.tensor(shape...) Allocates a zero-initialized tensor.
FastDL.dense(in, out) Creates a fully-connected linear layer.
FastDL.relu() Rectified Linear Unit activation layer.
FastDL.gelu() GELU activation (used inside Transformer FFN blocks).
FastDL.layerNorm(dim) Pre-LayerNorm layer with learnable gamma/beta.
FastDL.sequential(layers...) Chains layers into an executable network container.
FastDL.sgd(params, lr, momentum) Creates an SGD optimizer with momentum.
FastDL.adamW(params, lr) Creates an AdamW optimizer (standard for Transformers).
FastDL.mse() Mean Squared Error loss.
FastDL.crossEntropy() Cross-entropy loss for language modelling.

Transformer / GPT

Method Description
FastDL.gptConfigSmall(vocabSize) GPT config: 128-dim, 4 heads, 4 layers, seqLen=128.
FastDL.gptConfigMedium(vocabSize) GPT config: 256-dim, 4 heads, 6 layers, seqLen=256.
FastDL.gpt(config) Creates a full causal GPT language model.
FastDL.charTokenizer(corpus) Builds a character-level tokenizer from a text corpus.
FastDL.trainerConfigDemo() Training config: 2 batch, 200 steps (runs in ~1 min on CPU).
FastDL.trainerConfigStandard() Training config: 4 batch, 2000 steps with checkpointing.

Installation

Option 1: Maven (Recommended)

Add the JitPack repository and dependency to your pom.xml:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.github.andrestubbe</groupId>
        <artifactId>FastDL</artifactId>
        <version>0.1.0</version>
    </dependency>
</dependencies>

Option 2: Gradle (via JitPack)

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:FastDL:0.1.0'
}

Technical Examples & Hero Demos

Case Java Example Launcher Description
TinyStories Quick Preview TinyStoriesMiniDemo.java run-tiny-quick.bat Fast smoke test for TinyStories-style local text training.
TinyStories Transformer Smoke TinyStoriesTransformerDemo.java run-tiny-transformer.bat GPT-style mini transformer training run for quick validation.
TinyStories Big-Data Run TinyStoriesTransformerDemo.java run-tiny-big.bat Longer dataset-driven run intended for realistic local TinyStories experiments.
Non-Convex Loss Surface LossSurfaceDemo.java run-demo.bat Gradient descent and minima exploration on a shaped loss surface.
MLP Boundary Visualization MLPBoundaryDemo.java run-demo-mlp.bat Decision boundary demo for a small classification-style MLP.
Autoencoder / Representation Learning AutoencoderDemo.java run-demo-autoencoder.bat Lower-dimensional feature-learning demo for reconstruction tasks.

Root launchers

The repo also includes simple Windows batch launchers for the demo flow:

  • run-demo.bat β€” generic project demo entrypoint
  • run-demo-autoencoder.bat β€” autoencoder demo
  • run-demo-mlp.bat β€” MLP demo
  • run-tiny-quick.bat β€” Stage 1: TinyStories quick preview / smoke run
  • run-tiny-transformer.bat β€” Stage 2: TinyStories transformer smoke run
  • run-tiny-big.bat β€” Stage 3: long TinyStories big-data run
  • legacy aliases: run-tiny.bat and run-tiny2.bat delegate to the new stage launchers

These launchers are designed to compile the root project, install the local artifact, and then execute the relevant example from the Java demo modules.


Platform Support

Platform Status
Windows 10/11 βœ… Fully Supported
Linux βœ… Fully Supported
macOS βœ… Fully Supported

License

MIT License β€” See LICENSE for details.


Related Projects

  • FastML β€” Classical Machine Learning and deterministic pattern recognition
  • FastAI β€” High-level unified AI and reasoning substrate
  • FastModel β€” Local GGUF/ONNX model runtimes
  • FastGPU β€” Vulkan and GPU compute acceleration

Part of the FastJava Ecosystem β€” Making the JVM faster. Small package. Maximum speed. Zero bloat. πŸš€

About

🧬 Lightweight Deep Learning Engine, Tensor Computing & Neural Backpropagation for Java β€” gradient descent optimizers, composable layers, and loss surface exploration.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages