How fff-rs/juice works
Project Type and Purpose
• This is a Rust “workspace” monorepo containing multiple crates that together form a modular machine‐learning ecosystem:
• juice: the high‐level ML framework (layers, solvers, network serialization)
• coaster: low‐level tensor and device abstraction (CPU, CUDA, OpenCL)
• coaster-nn: neural‐network operations built on coaster
• coaster-blas: BLAS bindings (via native/OpenCL/CUDA) for linear algebra
• greenglas: data‐preprocessing utilities (image/word transformations)
• juice-examples: CLI and sample applications (MNIST, RNN regression)
• Purpose: Provide end‐to‐end ML tooling for Rust users, from data prep through model definition, optimization, and execution on multiple hardware backends.
File Structure Analysis
• Top‐level workspace with Cargo.toml that aggregates subcrates.
• Each crate has standard Rust layout: /src, /tests, /benches, plus README, LICENSE, CI configs.
• “juice” crate contains layer definitions, solvers, Cap’n’Proto schemas, documentation.
• “coaster” crates implement a plugin‐style framework abstraction: dispatcher → framework modules (native, cuda, opencl).
• “greenglas” provides a transformer API around image/word pipelines.
• “juice-examples” contains CLI front end and example projects that depend on “juice” and lower crates.
• Build/deploy scripts: build.rs for codegen, perf scripts, CI configs in .github.
Key README Insights
• juice uses Cap’n’Proto for network serialization.
• GPU support via CUDA/cuDNN and OpenCL; native BLAS fallback via pkg-config.
• Examples must be built with appropriate environment variables for external libs.
Main Components and Their Relationships
a. Frontend / User Interface
• juice-examples (CLI)
b. High‐Level Framework
• juice crate: layers, solvers, network I/O (Cap’n’Proto)
c. Data Preprocessing
• greenglas crate: image & word transformers
d. Neural‐Network Ops
• coaster-nn crate: NN-specific abstractions (activations, convolutions, RNNs)
e. Linear Algebra / Tensor Abstraction
• coaster-blas crate: BLAS-based ops
• coaster crate: unified tensor, device, plugin interface
f. Hardware Backends (plugins)
• native framework (CPU + BLAS)
• CUDA framework (calls cuBLAS, cuDNN via rcublas/rcudnn crates)
• OpenCL framework (calls OpenCL API)
g. External Services / Libraries
• BLAS/OpenBLAS or system BLAS
• CUDA driver & runtime, cuDNN
• OpenCL ICD & device libs
• Cap’n’Proto runtime
Architectural Patterns and Design Principles
• Plugin architecture in “coaster”: a trait‐based dispatcher delegates to one of multiple “frameworks.”
• Layer → Solver separation in “juice”: clear single‐responsibility for network structure vs. optimization.
• Data‐flow pipeline in “greenglas”: chaining transformers.
• Monorepo workspace: crates with explicit inter‐crate dependencies.
• A single canvas with six tiers listed above.
• Directional edges annotated with API or data‐flow descriptors.
• A sidebar listing major config points (env vars for CUDA, BLAS).
• Footnotes calling out build scripts (build.rs, capnp codegen).