Skip to main content

ghostlink_core/
lib.rs

1//! Ghost-Link Core Library
2//!
3//! A zero-config LAN fabric that turns spare local GPUs into a shared execution surface
4//! for large-model inference and training.
5//!
6//! # Features
7//! - Zero-copy SPSC ring buffers for DMA-style hand-off
8//! - Binary protocol with CRC32 checksums for frame integrity
9//! - Thread-safe cluster state with metrics collection
10//! - Greedy layer assignment with fault tolerance
11//! - Experimental XDP scaffolding (currently unavailable in this build)
12//! - Network health monitoring
13//! - Load balancing and tensor distribution
14//!
15//! # Architecture
16//! ```text
17//! crates/
18//! ├── ghostlink-core/  # Shared runtime primitives
19//! │   ├── ring.rs          # Zero-copy SPSC ring buffer
20//! │   ├── protocol.rs      # Binary protocol with CRC32
21//! │   ├── cluster.rs       # Thread-safe node state
22//! │   ├── planning.rs      # Layer assignment + fault tolerance
23//! │   ├── health.rs        # Network health monitoring
24//! │   ├── load_balance.rs  # Tensor distribution
25//! │   ├── kv_cache.rs      # KV cache primitive (no current caller — see module docs)
26//! │   ├── xdp.rs           # Experimental XDP scaffolding (stubbed)
27//! │   └── dashboard.rs     # Terminal UI with ratatui
28//! └── ghost-link/          # CLI demo entrypoint
29//! ```
30
31pub mod accelerator;
32pub mod autotune;
33pub mod cluster;
34pub mod dashboard;
35pub mod discovery;
36pub mod health;
37pub mod host;
38pub mod kv_cache;
39pub mod load_balance;
40pub mod mdns;
41pub mod models;
42pub mod planning;
43pub mod protocol;
44pub mod ring;
45pub mod runtime;
46pub mod system_profile;
47pub mod watcher;
48#[doc(hidden)]
49pub mod xdp;
50
51// Re-export common types for convenience
52pub use accelerator::ExecutionBackend;
53pub use autotune::AutoTuner;
54pub use cluster::{ClusterState, NodeMetrics, NodeStatus};
55pub use discovery::{broadcast_and_collect, UdpDiscoveryConfig, DEFAULT_DISCOVERY_PORT};
56pub use host::{
57    detect_local_node_resources, detect_runtime_profile, detect_runtime_profile_full,
58    detect_runtime_profile_with_mode, infer_compute_capability_from_name, is_apple_silicon,
59    AccelerationMode, GpuBackend, ProbeMode, RuntimeProfile,
60};
61pub use kv_cache::{KVCacheConfig, KVCacheEntry, LayerKvCache};
62pub use planning::{
63    assign_layers_sequentially, assign_layers_with_fault_tolerance_and_runtime,
64    assign_layers_with_runtime_profile, chunk_assignments_for_workers, select_quantization_mode,
65    LayerAssignment, LayerSpec, PlacementPlan, PlanningTuning, QuantizationMode,
66};
67pub use protocol::NodeResources;
68pub use ring::{RingConfig, SpscRingBuffer};
69pub use runtime::{
70    build_token_schedule, execute_pipeline, execute_pipeline_tcp_loopback,
71    execute_pipeline_tcp_loopback_with_config, BridgeAddr, BridgeListener, BridgeStream,
72    DeviceKind, ExecutionResult, PipelinePlan, StageExecutionStats, StagePlacement,
73    TcpTransportConfig, TokenStep, TransportKind,
74};
75pub use system_profile::{
76    CpuFeatures, CpuInfo, GpuInfo, MemoryInfo, NetworkInfo, NpuInfo, SystemProfile,
77};
78pub use watcher::{ProfileChange, SystemProfileWatcher};