Dataset Viewer
Auto-converted to Parquet Duplicate
repo
stringclasses
20 values
path
stringlengths
6
94
lang
stringclasses
5 values
n_chars
int64
81
200k
sha256
stringlengths
64
64
content
stringlengths
81
200k
eren23/synapse
synapse/synapse-esp32/build.rs
rs
278
d8340add2983eab773e12a0ede217afe65aca9fb4ed257e925c55b923396eea3
fn main() { // Only emit ESP-IDF sysenv when cross-compiling for espidf targets. // Host builds (cargo test -p synapse-esp32) skip this entirely. if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("espidf") { embuild::espidf::sysenv::output(); } }
eren23/synapse
synapse/synapse-esp32/examples/lewm_rollout_bench.rs
rs
2,610
0f1c2d3103a49da78393e4c2cbae57dfd8d6dd349bc5a107d0a3dedd65029e5a
//! Benchmark: sequential vs fused rollout latency. use synapse_esp32::model::Esp32LeWM; fn det(len: usize, seed: u32) -> Vec<f32> { (0..len) .map(|i| { let m = seed.wrapping_mul(1_664_525).wrapping_add((i as u32).wrapping_mul(1_013_904_223)); let centered = (m % 2_001).wrapping_sub...
eren23/synapse
synapse/synapse-esp32/examples/lewm_probe.rs
rs
7,950
35af2e49b5d50efb9c1b31cf835a92e0e4c7a5644d6775d2c3c9b711e8052782
use std::path::PathBuf; use synapse_inference::ops::pure_rust_ops::{gelu, layernorm, matmul_t}; use synapse_inference::quantization::QuantizedQ4LeWM; fn main() { let mut model_path: Option<PathBuf> = None; let args: Vec<String> = std::env::args().collect(); let mut i = 1; while i < args.len() { ...
eren23/synapse
synapse/synapse-esp32/examples/lewm_golden.rs
rs
2,234
4b5e45df030c1ab8bb6fe2515b29de27b3d194485ee90caa57bf8bc90a87776a
use std::path::PathBuf; use synapse_esp32::model::Esp32LeWM; fn main() { let mut model_path: Option<PathBuf> = None; let mut steps: usize = 5; let args: Vec<String> = std::env::args().collect(); let mut i = 1; while i < args.len() { match args[i].as_str() { "--model" | "-m" =>...
eren23/synapse
synapse/synapse-esp32/examples/lewm_encode_probe.rs
rs
4,354
2c389456a0bfc5ad3246a4d8ab84af538c9fc2a939dcf21a56fb046d8daa0cc5
use std::path::PathBuf; use synapse_esp32::model::Esp32LeWM; use synapse_inference::ops::patch_embed::patch_embed; use synapse_inference::ops::pure_rust_ops::layernorm; use synapse_inference::quantization::FullyQuantizedLeWM; fn main() { let mut model_path: Option<PathBuf> = None; let args: Vec<String> = std...
eren23/synapse
synapse/synapse-esp32/src/lib.rs
rs
539
1d99d73f5951e8e4c2fa708ca2346ac09712065ab53e86caf57e765cd47a7091
//! Synapse ESP32-P4: multi-model inference on a $10 RISC-V microcontroller. //! //! Supported models: //! - LeWM (world model): encode, predict, rollout //! - Mamba Q4 (language model): text generation //! - RWKV-7 Q4 (language model): text generation //! //! Architecture: //! Phone camera / text -> WiFi HTTP ...
eren23/synapse
synapse/synapse-esp32/src/server.rs
rs
11,352
8ab471455ccdf45d4dc59017105781f93d827f5ed01e323872028852d5e5a71b
//! HTTP server for inference over WiFi. //! //! Endpoints: //! POST /encode -- image -> latent (LeWM only) //! POST /predict -- latent + action -> next latent (LeWM only) //! POST /rollout -- latent + actions -> trajectory (LeWM only) //! POST /llm/generate -- prompt tokens -> generated tokens (Mamba/R...
eren23/synapse
synapse/synapse-esp32/src/main.rs
rs
7,658
04f0632cdf7ab85519862b6c6d5626b09a309528b7b43ee36b040237a4776bbf
//! ESP32-P4 multi-model inference server. //! //! On real hardware (--features esp32): //! Connects to WiFi, starts HTTP server, serves inference endpoints. //! //! On host (default, --features host-test): //! Runs a quick smoke test of all model types and server handlers. #[cfg(all(feature = "host-test", feature...
eren23/synapse
synapse/synapse-esp32/src/model.rs
rs
30,094
9f80fb4e38ec612923b5d9ea7e8c87c5d06f8b5504f0a048ef4788e516ed465c
//! Model loading and inference for ESP32. //! //! Supports multiple model types: //! - LEWM world model (encode/predict/rollout) — f32 or Q4 quantized //! - Mamba Q4 language model (text generation) //! - RWKV-7 Q4 language model (text generation) use std::time::Instant; use synapse_inference::models::ssm::mamba::blo...
eren23/synapse
synapse/crates/synapse-train/src/checkpoint.rs
rs
5,829
9ee879152bb84cbcd45154f33aee04c3ddd2ecf29586662695b906198edd69ae
use std::collections::BTreeMap; use std::io::{self, Cursor, Read, Write}; const MAGIC: &[u8; 4] = b"SYNP"; const VERSION: u32 = 1; /// Model state dictionary: parameter name -> (shape, data). pub type StateDict = BTreeMap<String, (Vec<usize>, Vec<f32>)>; /// Serialize a state dict to a writer in a binary format. ///...
eren23/synapse
synapse/crates/synapse-train/src/lib.rs
rs
450
191bedb6a82d22c72757b28723a3b84ceaba3addb2d4d8c2394dd8ede9ac2a0a
pub mod callback; pub mod checkpoint; pub mod metrics; pub mod progress; pub mod trainer; pub use callback::{CallbackAction, EarlyStopping, ModelCheckpoint, TrainerCallback}; pub use checkpoint::{load_checkpoint, load_from_bytes, save_checkpoint, save_to_bytes, StateDict}; pub use metrics::{Accuracy, ConfusionMatrix, ...
eren23/synapse
synapse/crates/synapse-train/src/callback.rs
rs
5,718
a90880593b99e307723e2f2aa8eedf516b8dcacf54a98558e0a722611c55e0ec
use crate::trainer::{EpochResult, TrainHistory}; /// Action returned by callbacks to control the training loop. pub enum CallbackAction { Continue, Stop, } /// Trait for hooks into the training loop. pub trait TrainerCallback { fn on_epoch_start(&mut self, _epoch: usize) {} fn on_epoch_end(&mut self, ...
eren23/synapse
synapse/crates/synapse-train/src/metrics.rs
rs
6,906
425fb5254be83725f0770fa806eb96932417dfe10b3f418fa4aae5388494312d
/// Tracks a running mean of scalar values. pub struct RunningMean { sum: f64, count: usize, } impl RunningMean { pub fn new() -> Self { RunningMean { sum: 0.0, count: 0 } } pub fn update(&mut self, value: f32) { self.sum += value as f64; self.count += 1; } pub fn ...
eren23/synapse
synapse/crates/synapse-train/src/progress.rs
rs
3,411
5a4b91a51ccd13435e8db1b82fdca8aca10af5a2c15bd4dc395c04e00eecea83
use std::time::{Duration, Instant}; /// Tracks progress through epochs and batches, providing ETA estimates. pub struct ProgressTracker { total_epochs: usize, current_epoch: usize, total_batches: usize, current_batch: usize, start_time: Instant, epoch_start: Instant, } impl ProgressTracker { ...
eren23/synapse
synapse/crates/synapse-train/src/trainer.rs
rs
5,051
50a26206f49fbabd1d735d5fddfa31adca1190833af87465205acdf7b4fa2eb4
use std::time::Instant; use synapse_autograd::Tensor; use crate::callback::{CallbackAction, TrainerCallback}; use crate::metrics::RunningMean; use crate::progress::ProgressTracker; /// Configuration for the training loop. pub struct TrainerConfig { pub epochs: usize, } /// Result of a single training epoch. pub...
eren23/synapse
synapse/crates/synapse-data/src/text_dataset.rs
rs
6,656
72c2e5fd7c7620ea8b11843b7f34280cf101bf07a4813430ef513d5cd027cde7
use crate::collate::pad_sequences; use crate::dataset::Dataset; use crate::tokenizer::{WhitespaceTokenizer, PAD_ID}; use crate::Tensor; /// A text classification dataset that loads tab-separated `label\ttext` lines. /// /// Each sample is stored as `(token_ids, label)` and returned as /// `[token_ids_tensor, label_ten...
eren23/synapse
synapse/crates/synapse-data/src/collate.rs
rs
5,132
153fdfe5f7a194fe2b6a80cf028962dde6807ef733e4140e4b6ff40999001da4
use crate::Tensor; /// Default collate function: given a batch of samples (each a `Vec<Tensor>`), /// stack corresponding tensors along a new leading batch dimension. /// /// For N samples each containing K tensors, produces K tensors each with /// a new leading dimension of size N. /// /// Example: 4 samples of [feat...
eren23/synapse
synapse/crates/synapse-data/src/lib.rs
rs
5,660
10706b57178ed6f5aa4f0960111969369563c657d631877786bfef75380e0258
pub mod collate; pub mod dataloader; pub mod dataset; pub mod sampler; pub mod text_dataset; pub mod tokenizer; pub mod transform; use std::fmt; /// A simple N-dimensional tensor backed by contiguous f32 data in row-major order. #[derive(Clone)] pub struct Tensor { data: Vec<f32>, shape: Vec<usize>, } impl f...
eren23/synapse
synapse/crates/synapse-data/src/dataloader.rs
rs
13,867
862066b4523f9fc61074b0efd80fe701c19b4ed69016c7c31959523f5625200d
use std::sync::mpsc::{sync_channel, Receiver}; use std::sync::Arc; use std::thread::{self, JoinHandle}; use crate::collate::default_collate; use crate::dataset::Dataset; use crate::sampler::{RandomSampler, Sampler, SequentialSampler}; use crate::Tensor; /// A configurable data loader that batches dataset samples with...
eren23/synapse
synapse/crates/synapse-data/src/sampler.rs
rs
5,793
2343c247ae95734aaf2f52e3d4ee78303c50b054da3f03de9a72529c8b04c0fb
use rand::rngs::StdRng; use rand::seq::SliceRandom; use rand::{Rng, SeedableRng}; /// A sampler produces a sequence of dataset indices. pub trait Sampler: Send { /// Reset the sampler for a new epoch, returning an iterator over indices. fn indices(&mut self) -> Vec<usize>; fn len(&self) -> usize; } /// Yi...
eren23/synapse
synapse/crates/synapse-data/src/transform.rs
rs
4,863
e6c4fc5d2f69652d42bd657a6a4786b5852173b0b19ed3b4258a1e3a4422550f
use crate::Tensor; use rand::Rng; /// A transform modifies tensor data. pub trait Transform: Send + Sync { fn apply(&self, tensor: &Tensor) -> Tensor; } /// Normalize: `(x - mean) / std` element-wise. pub struct Normalize { pub mean: f32, pub std: f32, } impl Normalize { pub fn new(mean: f32, std: f3...
eren23/synapse
synapse/crates/synapse-data/src/tokenizer.rs
rs
10,711
b0fd225d387793da21b62164daf1a1cecbd2a0e442e8cfad498542a837cbfb7e
use std::collections::HashMap; /// Special token IDs reserved at the start of every vocabulary. pub const PAD_ID: usize = 0; pub const UNK_ID: usize = 1; pub const BOS_ID: usize = 2; pub const EOS_ID: usize = 3; const PAD_TOKEN: &str = "<PAD>"; const UNK_TOKEN: &str = "<UNK>"; const BOS_TOKEN: &str = "<BOS>"; const E...
eren23/synapse
synapse/crates/synapse-data/src/dataset.rs
rs
2,926
950bfc56071649f4c4908bbb11484fb41587a789dbea61e844a6e8b64b2e8731
use crate::Tensor; /// A dataset provides indexed access to samples. /// Each sample is a `Vec<Tensor>` (e.g., [features, labels]). pub trait Dataset: Send + Sync { fn len(&self) -> usize; fn get(&self, index: usize) -> Vec<Tensor>; fn is_empty(&self) -> bool { self.len() == 0 } } /// A datase...
eren23/synapse
synapse/crates/synapse-code-tokenizer/tests/cross_validation.rs
rs
3,730
6088795ba95615e756cfa033a387c5be37c8b2752f8bcdeeb8e970e2d2794b2f
//! Byte-for-byte validation against the Python FNV-1a reference //! (scripts/ast_tokenizer_fnv.py). If Python-produced tokens match exactly, //! the Rust port is drop-in equivalent. use synapse_code_tokenizer::tokenize; /// Each case: (rust_source, expected_tokens from Python ast_tokenizer_fnv.py) const CASES: &[(&s...
eren23/synapse
synapse/crates/synapse-code-tokenizer/src/lib.rs
rs
30,968
3879bd33c71a8f7a9a01bdd7d4f5c4644192c3ad0bc214dde374efd79a8b9d2d
//! Python AST tokenizer for Code WM — matches `ast_tokenizer.ast_tokenize()` //! from the training tap, implemented in Rust via rustpython-parser. //! //! This removes the Python runtime dependency from Code WM inference and //! enables tokenization on any target Rust compiles to (WASM, ESP32, native). //! //! ## Voca...
eren23/synapse
synapse/crates/synapse-inference/build.rs
rs
364
32f8e9ffe0c2d45a78de2f242bb4ca538df950123401deb8719ddb471b0b9dbb
fn main() { // Link Apple Accelerate framework for cblas_sgemm — only when targeting macOS. // Uses TARGET env var (not cfg!) because build.rs runs on the host. let target = std::env::var("TARGET").unwrap_or_default(); if target.contains("apple") && !target.contains("wasm") { println!("cargo:rus...
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
70