Skip to content

Latest commit

 

History

History
246 lines (198 loc) · 11.6 KB

ROADMAP.md

File metadata and controls

246 lines (198 loc) · 11.6 KB

VTL Neural Network Roadmap

Goal: Production-grade Neural Network support in VTL with CUDA/GPU acceleration, DataLoader, CIFAR-10 example, and model serialization.

Reposity: vlang/vtl · VSL Backend: vlang/vsl


✅ Completed

Phase 0 — Foundation

  • Tensor core (vtl.Tensor), creation, slicing, broadcasting, map/reduce
  • Autograd engine (Variable, Context, reverse-mode backprop)
  • Linear Algebra via VSL (matmul, solve, lstsq, qr, lu, cholesky, pinv)
  • NN layers: Linear, Conv2D, MaxPool, Flatten, LSTM, LayerNorm, Attention
  • Losses: MSE, BCE, CrossEntropy, Huber
  • Optimizers: Adam, AdamW, RMSProp, AdaGrad, SGD + schedulers

Phase 1 — Vulkan Compute Foundation

  • vtl/examples/vtl_vandermont/README.md — VTL/Compute integration
  • vtl/examples/vtl_opencl_vcl_support/README.md — VCL/OpenCL support
  • Issue #58 — Phase 1: Vulkan Compute Foundation

Phase 2 — Neural Network Forward Pass on GPU

  • Issue #59 — Phase 2: Forward Pass on Vulkan GPU

Phase 3 — VSL Integration + CUDA Backend

  • Issue #60 — Phase 3: VSL + CUDA Backend
  • VTL imports from VSL: import vtl.la (LA operations), import vtl.storage (persistence)
  • CIFAR-10 dataset loader (datasets/cifar10.v)
  • nn_cifar10 example with CUDA-aware config

Phase 4 — GPU Autograd (partial; issue closed on GitHub)

  • Issue #61 — Phase 4: GPU Autograd
  • Vulkan f32 Linear backward uses GPU GEMM
  • Vulkan f32 Conv2D weight gradients use GPU GEMM; input and bias gradients retain the CPU path
  • Vulkan f32 Adam updates use the fused VSL optimizer shader
  • GPU backward coverage for LSTM, attention, norms, embeddings, and pooling
  • Full device-resident backward and optimizer updates across the supported model stack

Phase 5 — OpenCL Backend

  • Issue #162 — runnable OpenCL/VCL transfer and add_scalar smoke example
  • Issue #62 — full VTL OpenCL compute integration (closed on GitHub; implementation remains incomplete)
    • VTL tensor transfer to and from VCL storage
    • VCL broadcast view metadata
    • OpenCL/VCL smoke for tensor round-trip and add_scalar
    • VTL matmul/GEMM and GEMV dispatch on VCL tensors
    • VTL elementwise, reduction, softmax, LayerNorm, and Conv2D kernels
    • Device-resident VCL tensor operations and NN-layer dispatch
    • VCL parity and correctness tests across VTL tensor, LA, and NN APIs

Phase 6 — ARM GPU Support

  • Issue #63 — Phase 6: ARM GPU Support (Android, iOS, Embedded)

Phase 7+ — Performance Engineering

  • Issue #64 — Phase 7+: Kernel Fusion, Mixed Precision, Computation Graph Optimization (closed on GitHub; scope remains incomplete)
    • Fused Vulkan Adam update kernel
    • General operator fusion and computation graph optimization
    • FP16/BF16 storage and automatic mixed-precision training
    • Reusable GPU memory pools and asynchronous Vulkan execution
    • Backend profiling and gradient checkpointing
    • Quantization and multi-GPU training

🎯 Active Development

Phase A — CIFAR-10 End-to-End

  • CIFAR-10 path bug fixed (datasets/cifar10.v)
  • Configurable subset loading (Cifar10Config.train_count, test_count)
  • nn_cifar10_safe variant — safe defaults for dev/CI
  • nn_cifar10_tiny variant — real data subset (64 train, 16 test)
  • nn_cifar10_tiny_synth variant — synthetic data, no I/O (pipeline validation)
  • CI: scoped bin/test on PRs; full tree + nn_cifar10/main.v via label full-ml (#109)
  • Full nn_cifar10 training remains local/high-RAM (~9 GB compile peak on small hosts)

Phase B — DataLoader Infrastructure

  • datasets/dataloader.v — DataLoader[T] with batching, shuffle, labels (issue #86 closed)
  • Used in nn_cifar10_* examples

Phase C — Model Serialization Polish — closed #87

  • serialization_test.v round-trip at 1e-9
  • nn_cifar10/main.v checkpoints + --resume (PR #95)

Phase C2 — VTL ↔ VSL GPU Integration — closed #89–#91 (PR #93)

  • CUDA Linear, Conv2D, DeviceSession (opt-in VTL_USE_CUDA=1, -d cuda)

Phase D — Numpy Benchmark Suite — closed #88 (PR #94)

  • benchmarks/vs_numpy/ matmul + conv2d + bench_util
  • autograd_bench.v + pytorch_baseline.py
  • PR comment workflow (benchmark-pr-comment.yml, PR #96)

Phase E — Example Consolidation

  • nn_cifar10_cuda — opt-in CUDA smoke (VTL_USE_CUDA=1, -d cuda)
  • nn_cifar10_vulkan — f32 smoke with Vulkan Linear, Conv2D, ReLU/Sigmoid, Adam
  • Root README.md passes v check-md -hide-warnings
  • All example READMEs pass v check-md -hide-warnings

Phase F — GPU training loop (follow-up to #91)

  • Phase 1: DeviceSession buffer reuse; CUDA forward for Linear/Conv2D
  • Phase 2: GPU-resident Variable (forward tensors, #101/#104)
  • Phase 3: CUDA backward for Linear + Conv2D (opt-in VTL_CUDA_BACKWARD, #107)
  • Phase 4: Adam on GPU with persistent optimizer slots (VTL_CUDA_OPTIMIZER, #106)

See docs/DEVICE_MEMORY.md.


🔜 Next priorities

Priority Work item
P1 Implement CUDA backward coverage for the remaining neural-network layers (#161)
P1 Close the remaining correctness, API, and performance gaps in NumPy and Arraymancer parity
P2 Improve CPU kernel performance and revisit alias/compiler optimizations when V provides a safe contract (#3)
P2 Add ARM GPU support (#63)
P2 Expand measured YOLO gate/layer fusion beyond binary multiply/divide backward kernels (#40)

🧩 Open issues (VTL)

# Title Priority Notes
#3 V aliasing (restrict) 🟡 Perf Open; await safe compiler support; see note below
#40 YOLO for autograd gates 🟡 Performance Open; requires end-to-end benchmark evidence
#63 ARM GPU support 🟡 P2 Open; requires ARM GPU hardware for device validation
#161 CUDA backward gaps 🔴 ML Open; LSTM, attention, norms, embeddings, and pooling remain

Issue #3 compiler status: V 0.5.2 does not emit a restrict alias contract. The upstream V issue #1839 is closed, but the current C generator source still does not emit a non-aliasing qualifier for tensor kernel pointers. @[direct_array_access] removes bounds checks but does not establish non-aliasing. Keep #3 open; benchmark safe kernel changes and revisit when upstream compiler support is available.

The complete NumPy and Arraymancer comparison is tracked in docs/NUMPY_PARITY.md. The GitHub project board is not used as a source for this roadmap.

Closed ML epics: #58–#64, #86–#91 — see ML_ROADMAP.md.


🔗 Cross-Repository Dependencies

Dependency Repo Status
VSL LA ops (matmul, conv2d, solve, etc.) vlang/vsl ✅ Done
VSL CUDA (vsl/cuda, cuBLAS/cuDNN) vlang/vsl ✅ #280
VSL Vulkan compute vlang/vsl ✅ #283–#284
VSL OpenCL (VCL) vlang/vsl ✅ VSL transport/kernels exist; ❌ VTL compute and NN dispatch are incomplete (see #62)
vs NumPy / PR benchmarks vlang/vtl ✅ #88, workflow

Benchmark Strategy

NumPy Baseline

All benchmarks compare VTL against NumPy using equivalent operations:

# NumPy reference
import numpy as np
a = np.random.rand(1024, 1024)
b = np.random.rand(1024, 1024)
%timeit np.dot(a, b)

VTL Implementation

import vtl
import vtl.la

a := vtl.random[f64](0.0, 1.0, [1024, 1024], vtl.TensorData{})
b := vtl.random[f64](0.0, 1.0, [1024, 1024], vtl.TensorData{})
_ = la.matmul(a, b)!

CI Integration

  • The path-filtered .github/workflows/benchmark-pr-comment.yml workflow compiles its V benchmarks with -prod, runs them separately from compilation, and posts a report with VTL and NumPy timings.
  • The report currently includes CPU matmul, Conv2D, reduced SVD, statistics, and linear bias-gradient reduction. These results are diagnostic except for the optimized CPU GEMM budget below.
  • CI fails when either f32 or f64 optimized CBLAS GEMM at 512×512 is more than 3× slower than NumPy. The report is posted before this gate runs. A performance-exempt label bypasses the threshold while leaving the measured ratios visible.
  • The gate does not establish pure-V, CUDA, Conv2D, autograd, or end-to-end training performance parity. Add explicit, equivalent baselines and budgets before treating those workloads as CI performance requirements.

Planned Benchmark Coverage

  1. Matmul — add larger shapes and CUDA comparisons with matching backends.
  2. Conv2D — add an optimized backend comparison for f64[64, 3, 32, 32] and kernel f64[3, 3, 3, 64].
  3. Autograd backprop — three-layer MLP with 256 hidden units.
  4. Training step — full forward, loss, backpropagation, and optimizer update.

📁 File Inventory

VTL Examples

vtl/examples/
├── nn_cifar10/           # Full CIFAR-10 CNN (local machine recommended)
├── nn_cifar10_safe/      # Safe defaults, CI-friendly
├── nn_cifar10_tiny/      # Real data subset (64 train, 16 test)
├── nn_cifar10_tiny_synth/# Synthetic data, no I/O
├── nn_cifar10_cuda/      # CUDA smoke (opt-in)
├── nn_cifar10_vulkan/    # Vulkan GEMM smoke (opt-in)
├── nn_mnist/             # MNIST example
├── nn_xor/               # XOR training example
├── nn_regression_sine/   # Sine regression
├── nn_multiclass_iris/   # Iris multi-class
├── nn_simple_two_layer/  # Two-layer MLP
├── nn_autoencoder_simple/# Autoencoder
├── autograd_backprop/    # Backprop demonstration
├── vtl_basic_usage/      # Basic tensor operations
├── vtl_vandermont/       # Vandermonde matrix example
└── vtl_opencl_vcl_support/ # OpenCL/VCL support demo

VTL Core

vtl/
├── nn/
│   ├── layers/           # Linear, Conv2D, MaxPool, LSTM, LayerNorm, Attention
│   ├── models/           # Sequential, Serialization
│   ├── optimizers/       # Adam, AdamW, RMSProp, AdaGrad, SGD
│   └── losses/           # MSE, BCE, CrossEntropy, Huber
├── datasets/
│   └── cifar10.v         # CIFAR-10 loader with subset support
├── autograd/
│   └── gates/            # Autograd gate implementations
├── benchmarks/vs_numpy/  # matmul, conv2d, autograd_bench
└── docs/                 # Tutorials + ML_ROADMAP

Last updated: 2026-10-05