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 api_response_cache;
33pub mod autotune;
34pub mod circuit_breaker;
35pub mod cluster;
36pub mod dashboard;
37pub mod discovery;
38pub mod health;
39pub mod host;
40pub mod kv_cache;
41pub mod load_balance;
42pub mod mdns;
43pub mod models;
44pub mod planning;
45pub mod protocol;
46pub mod ring;
47pub mod runtime;
48pub mod system_profile;
49pub mod watcher;
50#[doc(hidden)]
51pub mod xdp;
52
53// Re-export common types for convenience
54pub use accelerator::ExecutionBackend;
55pub use api_response_cache::{ApiResponseCache, CacheStats};
56pub use autotune::AutoTuner;
57pub use circuit_breaker::{CircuitBreaker, CircuitBreakerConfig, CircuitState, JitteredBackoff};
58pub use cluster::{ClusterState, NodeMetrics, NodeStatus};
59pub use discovery::{broadcast_and_collect, UdpDiscoveryConfig, DEFAULT_DISCOVERY_PORT};
60pub use host::{
61    detect_local_node_resources, detect_runtime_profile, detect_runtime_profile_full,
62    detect_runtime_profile_with_mode, infer_compute_capability_from_name, is_apple_silicon,
63    AccelerationMode, GpuBackend, ProbeMode, RuntimeProfile,
64};
65pub use kv_cache::{KVCacheConfig, KVCacheEntry, LayerKvCache};
66pub use planning::{
67    assign_layers_sequentially, assign_layers_with_fault_tolerance_and_runtime,
68    assign_layers_with_runtime_profile, chunk_assignments_for_workers, select_quantization_mode,
69    LayerAssignment, LayerSpec, PlacementPlan, PlanningTuning, QuantizationMode,
70};
71pub use protocol::NodeResources;
72pub use ring::{RingConfig, SpscRingBuffer};
73pub use runtime::{
74    build_token_schedule, execute_pipeline, execute_pipeline_tcp_loopback,
75    execute_pipeline_tcp_loopback_with_config, BridgeAddr, BridgeListener, BridgeStream,
76    DeviceKind, ExecutionResult, PipelinePlan, StageExecutionStats, StagePlacement,
77    TcpTransportConfig, TokenStep, TransportKind,
78};
79pub use system_profile::{
80    CpuFeatures, CpuInfo, GpuInfo, MemoryInfo, NetworkInfo, NpuInfo, SystemProfile,
81};
82pub use watcher::{ProfileChange, SystemProfileWatcher};