forge-ml 0.1.0

A WebGPU-native machine learning runtime in Rust: train and run GPT-2 on any GPU wgpu reaches, with no CUDA and no Python
Documentation
[package]
# `forge` was taken on crates.io in 2017, so the crate publishes as `forge-ml`.
# `[lib] name` below keeps the import path `use forge::...` for dependents.
name = "forge-ml"
version = "0.1.0"
edition = "2024"
# 1.85 for edition 2024, but src/tensor.rs uses integer `is_multiple_of`, which
# landed in 1.87 — clippy's incompatible_msrv lint holds this honest.
rust-version = "1.87"
license = "AGPL-3.0-only"
description = "A WebGPU-native machine learning runtime in Rust: train and run GPT-2 on any GPU wgpu reaches, with no CUDA and no Python"
repository = "https://github.com/Aisuko/forge"
homepage = "https://aisuko.github.io/forge/"
documentation = "https://docs.rs/forge-ml"
readme = "README.md"
keywords = ["machine-learning", "webgpu", "wgpu", "gpt2", "transformer"]
categories = ["science", "wasm", "graphics"]
# Everything else in the repo — the 43 MB char checkpoint, the website, the
# scripts — is repo furniture, not crate content. Without this the tarball is
# 38.8 MiB and crates.io rejects it at 10 MiB; with it, 439 KiB. The WGSL is
# not optional: src/backend/wgpu/mod.rs pulls every shader in via include_str!.
include = [
    "src/**/*.rs",
    "shaders/*.wgsl",
    "examples/*.rs",
    "tests/**/*",
    "README.md",
    "LICENSE",
]

[lib]
name = "forge"
crate-type = ["rlib", "cdylib"]

[features]
# The `forge-top` TUI. Kept behind a feature so its deps never reach the wasm
# build or the library's dependents — verify with
# `cargo tree -e normal | grep -c ratatui` -> 0.
tui = [
    "dep:ratatui",
    "dep:crossterm",
    "dep:sysinfo",
    "dep:nvml-wrapper",
    "dep:memmap2",
]

[[bin]]
name = "forge-top"
path = "src/bin/forge-top/main.rs"
required-features = ["tui"]

[dependencies]
bytemuck = "1"
fancy-regex = "0.14"
rand = "0.9"
safetensors = "0.5"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
wgpu = "26"

# Native only: sync facades (pollster / poll-wait readback) and rayon.
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
pollster = "0.4"
rayon = "1"
# `tui` feature only (see [features]); all optional so a default build and the
# wasm build pull none of them.
ratatui = { version = "0.30", optional = true }
crossterm = { version = "0.29", optional = true }
sysinfo = { version = "0.39", optional = true }
nvml-wrapper = { version = "0.12", optional = true }
memmap2 = { version = "0.9", optional = true }

# Native only: the integration tests exercise the async inference API — the
# path the browser actually takes — so they need a blocking executor.
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
pollster = "0.4"

# Browser (wasm32): async-only device APIs + JS bindings.
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen = "0.2"
# No source-level `use`, but required: the #[wasm_bindgen] attribute macro
# expands the `async fn` exports in src/wasm.rs into code that names
# `wasm_bindgen_futures`. Removing it fails the wasm32 build with E0433.
wasm-bindgen-futures = "0.4"
js-sys = "0.3"
console_error_panic_hook = "0.1"
getrandom = { version = "0.3", features = ["wasm_js"] }

[profile.dev]
opt-level = 2

[profile.dev.package."*"]
opt-level = 3

[profile.release]
# Smaller wasm binaries; negligible effect on native perf here.
lto = "thin"