Implement, debug, and measure ruv-fann dense autograd/SGD/AdamW, Candle tensor interchange, napi-rs, prepared inference, model I/O, SIMD, RuVector or MetaHarness adapters, or native/browser WebGPU primitives. Use for root-crate training, numerical, allocation, input-validation, integration, or backend changes.
93%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Read root Cargo.toml, the relevant files under src/, and docs/review-core.md in the selected checkout. Use repo-map if the checkout or feature selection is uncertain. The core is a generic floating-point feedforward library; other workspaces expose different model types and weight layouts.
Use explicit weights before training or optimizing. The documented root-crate example includes a bias weight:
use ruv_fann::{ActivationFunction, NetworkBuilder};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut network = NetworkBuilder::<f32>::new()
.input_layer(2)
.output_layer_with_activation(1, ActivationFunction::Linear, 1.0)
.build();
network.set_weights(&[0.5, -0.25, 0.1])?;
let mut output = [0.0f32];
network.run_into(&[1.0, 2.0], &mut output)?;
assert!((output[0] - 0.1).abs() < 1e-6);
Ok(())
}For a consumer, use a local ruv-fann path dependency against the selected checkout. run() returns an owned output vector; run_into() writes a caller-owned output slice of exactly num_outputs() elements. It reuses the network's stored neuron values. Its repeated-call allocation guarantee is checked separately from latency.
Read src/prepared.rs and the public exports in src/lib.rs. Network::prepare()
creates an owned PreparedNetwork<T> snapshot; subsequent source edits or source
destruction cannot change it. Allocate an InferenceWorkspace<T> once for each
concurrent caller, then pass it to PreparedNetwork::run_into:
// Continue with the explicitly weighted network from the example above.
let prepared = network.prepare()?;
let mut workspace = prepared.workspace()?;
let mut packed_output = [0.0f32];
prepared.run_into(&[1.0, 2.0], &mut packed_output, &mut workspace)?;
assert!((packed_output[0] - 0.1).abs() < 1e-6);Share the immutable snapshot across threads when its scalar type permits; keep each mutable workspace and output exclusive to a call. A workspace can be reused for another snapshot if its buffers are wide enough. Repeated inference performs no heap allocations after preparation, workspace, and output allocation. The workspace may change on error, but the caller output is committed only on success; the snapshot remains unchanged.
For custom budgets, use PreparedNetwork::from_network_with_limits(&network, PreparationLimits { max_bytes, max_neurons, max_connections }). Validation runs
before packing. Bias neurons must be last, unconnected, and exactly one.
Regular transient neuron sums/values are ignored. Nonfinite parameters/inputs,
invalid indices, inadequate workspace, numeric overflow, and exceeded budgets
return PreparedError instead of unchecked inference.
Dense canonical rows use contiguous weights; sparse, shuffled and duplicate
connections preserve source accumulation order. Native f32/f64 callers can use
batch_workspace(capacity, byte_budget) and run_batch_into with row-major
input/output slices. Numeric buffers are reused; errors preserve caller output.
The byte budget here covers the workspace, not the shared immutable snapshot.
The generated WASM API uses Float64Arrays, prepared.create_batch(capacity)
and batch.run_into(inputs, outputs, rows). The SIMD build processes independent
samples with f64x2 multiply/add and scalar tails. It validates primitive row
counts, typed-array buffers, combined storage and conservative work limits.
Inspect ruv-swarm/npm/README.md for the exact limits and handle lifetime.
Small batches can be slower. Measure setup, reuse, public boundary copies and
warm inference separately; packing alone does not prove SIMD throughput.
Use AutogradNetwork<f32/f64> for actual dense reverse-mode MSE training.
Read src/autograd, tests/autograd.rs and tests/autograd_allocations.rs.
DenseLayer weights are row-major [outputs, inputs]; a present bias is added
last. This layout differs from the older WASM WasmNeuralNetwork constructor.
backward_mse replaces parameter/input gradients and averages squared error over
all rows and outputs. SGD and AdamW require a fresh backward pass for each step.
Workspaces bind to the exact model identity; gradients and optimizers also bind
to its parameter revision. Invalid numbers or staged update overflow cannot
partially change parameters or AdamW moments.
Use an explicit capacity/byte budget for the reusable tape and a separate budget
for AdamW. Supported derivative rules are Linear, Sigmoid, Tanh,
SigmoidSymmetric and ReLU; FANN chooses ReLU derivative zero at zero. Check
unsupported rules instead of silently substituting a different activation.
prepare() freezes an independent inference snapshot, which can feed the
existing RuVector and MetaHarness adapters. JSON checkpoints store topology and
weights, not optimizer moments.
For actual Candle CPU tensors, use integrations/candle and its pinned 0.11.1
adapter/oracles. Browser/Node WASM exposes WasmTrainableNetwork, and the
independent bindings/napi package exposes NativeTrainableNetwork. Both call
the same f64 core with bounded ordinary Float64Arrays. This does not add a
general tensor engine, transformer trainer or GPU backward implementation.
Follow the complete training and interoperability procedure.
Network::validate() after direct public-field mutation or generic Serde deserialization. Validated binary/model readers call structural checks, but the hot inference loop deliberately does not revalidate the entire topology.| Path | Supported contract and important limit |
|---|---|
CPU run/run_into | Generic scalar types and canonical activation behavior; benchmark the invoked path |
PreparedNetwork::run_into | Immutable owned scalar parameters and separate reusable workspace; checked finite inputs and canonical unit bias |
PreparedNetwork::run_batch_into | f32/f64 row-major batches with fixed-capacity scratch and atomic caller outputs; independent sample SIMD on wasm32+simd128 |
AutogradNetwork::backward_mse | Actual fixed dense reverse pass; reusable tape, parameter/input gradients, checked SGD/AdamW and independent prepare() |
| Candle / napi-rs | Optional independently locked CPU tensor adapter and native Node backend; exact dtype/layout and explicit toolchain requirements |
simd/parallel utilities | Optional optimization utilities; feature selection alone does not route every operation through them |
Native gpu | Real WGPU f32 matrix/batch/activation and managed buffers; f64 computation keeps CPU precision |
Browser webgpu/wasm-gpu | Async WasmGpuBridge for bounded f32 matrix multiplication and activations; separate from native gpu |
The no_std feature is a marker, not an implemented bare-metal build. The browser bridge does not implement canvas rendering, agent execution, persistent shared device storage, or an invented CPU fallback. Unavailable devices and unsupported storage APIs return errors.
For real neural outputs connected to RuVector search and MetaHarness tuning, use
the selected checkout's integrations/ruv-fann package and follow the
integration procedure. This adds application
adapters without changing the Rust core's dependencies.
Run from the checkout root with dependencies already available:
cargo test --locked --lib
cargo test --locked --test inference_allocations
cargo test --locked --test prepared_inference --test prepared_allocations
cargo test --locked --test prepared_batch_equivalence --test prepared_batch_work
cargo test --locked --test prepared_dense --test prepared_dense_kernel --test autograd --test autograd_allocations
cargo test --locked --lib --no-default-features --features simd
cargo test --locked --release --lib tests::core_regressions
cargo test --locked --docFor a broader planned profile:
python3 "${CLAUDE_PLUGIN_ROOT}/scripts/repoctl.py" plan --repo "/path/to/ruv-FANN" --profile coreGPU work needs actual runtime gates, not only all-feature compilation. With the documented toolchain/browser prerequisites installed:
node scripts/verify-webgpu.cjs
node scripts/verify-rust-browser-gpu.cjs --buildThe direct WGSL harness and Rust-to-WASM bridge harness cover different paths. A software Vulkan/SwiftShader pass establishes numerical behavior on that adapter. Report physical-device throughput only after measuring it on physical hardware.
Accept a change when the explicit-weight reference, boundary regressions and relevant feature/runtime gates pass with stated tolerances. For optimization, include before/after allocations and measured latency on identical workloads; use security-performance for the comparison protocol.
If inference diverges, check activation steepness, bias order, sparse connections and scalar precision. If a GPU check fails before dispatch, inspect adapter/driver limits and feature selection. If an untrusted load fails, retain its error and declared resource counts without dumping sensitive training data.
Read boundary and GPU details for resource caps and device-lifecycle checks.
ruvnet/ruv-FANN
02431fd
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.