refactor: prune public api
Collapse mvp-system's public surface to three binary entrypoints and make every domain module private, deleting dead provider/worker/membership implementations and inlining provider config.
- lib.rs: expose only run_chat_from_args/run_orchestrator_from_args/run_worker_node_from_env (plus a crate-private in-process helper) and the cached-model consts, and demote chat/node/observability/orchestration/prompt/staging/transport to private mods
- orchestration/mod.rs: make app private, gate engine_builder behind cfg(test), drop docker_cluster from provider_adapters, tighten vastai to pub(super), and replace pub re-exports with pub(super) run_from_args/run_in_process_from_args
- orchestration/config.rs: inline VastAiConfig/ResolvedVastAiConfig/looks_remote_image (removing provider_adapters/vastai/config.rs) and drop the DEFAULT_PIPELINE_CACHED_MODEL_* consts (hoisted to lib.rs)
- orchestration/provider_adapters/vastai: delete the ProviderPlugin impl VastAiProviderPlugin and all client/bootstrap/config accessors; repoint call sites to crate-level #[path] mods for provisioning/node_provisioning/node_actor/gguf_shard/run_fsm/run_plan
- delete orchestration/{membership_readiness,token_endpoint,resource_inventory}, node/{boot_lifecycle,data_plane_bridge(-74)}, and the worker crate-internal modules (control/device_bridge/process_adapter) along with their guarantees tests
- chat/node: narrow node_image and worker_node_runtime to private and expose only pub(super) run_from_args / run_worker_node_from_env
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-29 10:02:50 +00:00
|
|
|
#![allow(dead_code)]
|
|
|
|
|
|
2026-07-12 06:14:34 +00:00
|
|
|
pub const MO01_HEADER_BYTES: u64 = 40;
|
|
|
|
|
const TOKEN_ID_WIDTH_BYTES: u32 = 4;
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct RunId(pub u64);
|
|
|
|
|
|
|
|
|
|
impl From<u64> for RunId {
|
|
|
|
|
fn from(value: u64) -> Self {
|
|
|
|
|
Self(value)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct NodeId(pub u64);
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct EdgeId(pub u64);
|
|
|
|
|
|
2026-06-25 07:29:16 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct EdgeAllocator {
|
|
|
|
|
next: u64,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl EdgeAllocator {
|
|
|
|
|
pub fn new() -> Self {
|
|
|
|
|
Self { next: 1 }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn alloc(&mut self) -> EdgeId {
|
|
|
|
|
let edge_id = EdgeId(self.next);
|
|
|
|
|
self.next += 1;
|
|
|
|
|
edge_id
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for EdgeAllocator {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self::new()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum DTypeFamily {
|
|
|
|
|
BFloat,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct ModelFacts {
|
|
|
|
|
pub model_id: String,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub gguf_source: GgufSource,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
pub num_layers: u32,
|
|
|
|
|
pub hidden_dim: u64,
|
|
|
|
|
pub dtype_family: DTypeFamily,
|
|
|
|
|
pub dtype_width_bytes: u64,
|
|
|
|
|
pub max_seq_len: u64,
|
|
|
|
|
pub eos_token_id: u32,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub tokenizer: TokenizerSource,
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp-chat): local e2e chat on cuda gpu
Stand up an interactive end-to-end chat over a CUDA GPU, provisioning a Dockerized node that loads a GGUF model and serves prompts over TCP.
- prompt_rpc: add the newline-JSON prompt protocol (`SubmitPrompt` + `PromptEvent::{TextDelta,Done,Fault}`) carried over TCP
- mvp_chat: add an interactive REPL client connecting to the prompt RPC port (default 127.0.0.1:19777)
- mvp_orch_one_node / mvp_one_node_chat: add the single-node orchestrator that provisions a `LocalDockerPlugin` node, loads `bartowski/Llama-3.2-1B-Instruct-GGUF` (Q4_K_M), and exposes the prompt RPC listener with boot/route/weight timeouts
- mvp_node: add the GPU worker binary that spawns `tinygrad_worker.py` (default device CUDA) and ships runtime telemetry via a `ClusterFrameSink`
- vastai_provisioning / bootstrap_datastream: add the vast.ai provider adapter (`VastAiProvisioningConfig`, `VastAiLeaseClient`) wrapping `swactor_vastai`, plus a bridge that folds provision stdout onto a per-node datastream
- apps/mvp-node: add CUDA base/runtime Dockerfiles (nvidia/cuda 12.6.3, tinygrad 0.12.0, sshd), `mvp_entrypoint.sh` (sshd + mvp-node, held for postmortem), `local_docker_e2e.sh`, the GGUF tinygrad worker, and one-node-chat/bootstrap/vastai guarantee tests
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-01 08:44:25 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
2026-06-25 12:30:18 +00:00
|
|
|
pub enum GgufSource {
|
|
|
|
|
LocalPath(String),
|
|
|
|
|
HuggingFaceGguf {
|
|
|
|
|
repo: String,
|
|
|
|
|
file: String,
|
|
|
|
|
revision: Option<String>,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp-chat): local e2e chat on cuda gpu
Stand up an interactive end-to-end chat over a CUDA GPU, provisioning a Dockerized node that loads a GGUF model and serves prompts over TCP.
- prompt_rpc: add the newline-JSON prompt protocol (`SubmitPrompt` + `PromptEvent::{TextDelta,Done,Fault}`) carried over TCP
- mvp_chat: add an interactive REPL client connecting to the prompt RPC port (default 127.0.0.1:19777)
- mvp_orch_one_node / mvp_one_node_chat: add the single-node orchestrator that provisions a `LocalDockerPlugin` node, loads `bartowski/Llama-3.2-1B-Instruct-GGUF` (Q4_K_M), and exposes the prompt RPC listener with boot/route/weight timeouts
- mvp_node: add the GPU worker binary that spawns `tinygrad_worker.py` (default device CUDA) and ships runtime telemetry via a `ClusterFrameSink`
- vastai_provisioning / bootstrap_datastream: add the vast.ai provider adapter (`VastAiProvisioningConfig`, `VastAiLeaseClient`) wrapping `swactor_vastai`, plus a bridge that folds provision stdout onto a per-node datastream
- apps/mvp-node: add CUDA base/runtime Dockerfiles (nvidia/cuda 12.6.3, tinygrad 0.12.0, sshd), `mvp_entrypoint.sh` (sshd + mvp-node, held for postmortem), `local_docker_e2e.sh`, the GGUF tinygrad worker, and one-node-chat/bootstrap/vastai guarantee tests
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-01 08:44:25 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
2026-06-25 12:30:18 +00:00
|
|
|
pub enum TokenizerSource {
|
|
|
|
|
EmbeddedGguf,
|
|
|
|
|
LocalPath(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum PromptSource {
|
|
|
|
|
Inline(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct SamplingPolicy {
|
|
|
|
|
pub temperature_millis: u32,
|
|
|
|
|
pub top_k: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum TokenOutputPolicy {
|
|
|
|
|
EmitAll,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct RoleId(pub u64);
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub struct PortId(pub String);
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct GgufModelPlan {
|
|
|
|
|
pub model_id: String,
|
|
|
|
|
pub gguf_source: GgufSource,
|
|
|
|
|
pub num_layers: u32,
|
|
|
|
|
pub hidden_dim: u32,
|
|
|
|
|
pub dtype_family: DTypeFamily,
|
|
|
|
|
pub dtype_width_bytes: u32,
|
|
|
|
|
pub max_seq_len: u32,
|
|
|
|
|
pub eos_token_id: u32,
|
|
|
|
|
pub tokenizer: TokenizerSource,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct RuntimePlan {
|
|
|
|
|
pub prompt: PromptSource,
|
|
|
|
|
pub sampling: SamplingPolicy,
|
|
|
|
|
pub token_output_policy: TokenOutputPolicy,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct RuntimeConfig {
|
|
|
|
|
pub max_tokens: u32,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub prompt: PromptSource,
|
|
|
|
|
pub sampling: SamplingPolicy,
|
|
|
|
|
pub token_output_policy: TokenOutputPolicy,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RuntimeConfig {
|
|
|
|
|
pub fn test_default() -> Self {
|
2026-06-25 12:30:18 +00:00
|
|
|
Self {
|
|
|
|
|
max_tokens: 4,
|
|
|
|
|
prompt: PromptSource::Inline("test prompt".to_owned()),
|
|
|
|
|
sampling: SamplingPolicy {
|
|
|
|
|
temperature_millis: 0,
|
|
|
|
|
top_k: 1,
|
|
|
|
|
},
|
|
|
|
|
token_output_policy: TokenOutputPolicy::EmitAll,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn plan(&self) -> RuntimePlan {
|
|
|
|
|
RuntimePlan {
|
|
|
|
|
prompt: self.prompt.clone(),
|
|
|
|
|
sampling: self.sampling,
|
|
|
|
|
token_output_policy: self.token_output_policy,
|
|
|
|
|
}
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct StagePlacement {
|
|
|
|
|
pub stage_index: u32,
|
|
|
|
|
pub node_id: NodeId,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum PlacementInput {
|
|
|
|
|
FixedLinear(Vec<StagePlacement>),
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum RingDirection {
|
|
|
|
|
Ingress,
|
|
|
|
|
Egress,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum HostPinning {
|
|
|
|
|
Pageable,
|
|
|
|
|
PinnedRequired,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum WakeCoalescing {
|
|
|
|
|
PendingBit,
|
|
|
|
|
ReadySet,
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct RingSpec {
|
|
|
|
|
pub data_capacity: u64,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub alignment: u32,
|
|
|
|
|
pub direction: RingDirection,
|
|
|
|
|
pub host_pinning: HostPinning,
|
|
|
|
|
pub wake_coalescing: WakeCoalescing,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RingSpec {
|
|
|
|
|
pub fn test_default_activation() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
data_capacity: 1 << 20,
|
|
|
|
|
alignment: 64,
|
2026-06-25 12:30:18 +00:00
|
|
|
direction: RingDirection::Egress,
|
|
|
|
|
host_pinning: HostPinning::Pageable,
|
|
|
|
|
wake_coalescing: WakeCoalescing::PendingBit,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn test_default_token() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
data_capacity: 4096,
|
|
|
|
|
alignment: 8,
|
2026-06-25 12:30:18 +00:00
|
|
|
direction: RingDirection::Egress,
|
|
|
|
|
host_pinning: HostPinning::Pageable,
|
|
|
|
|
wake_coalescing: WakeCoalescing::PendingBit,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct PlannerInput {
|
|
|
|
|
pub run_id: RunId,
|
|
|
|
|
pub orchestrator_node_id: NodeId,
|
|
|
|
|
pub model: ModelFacts,
|
|
|
|
|
pub runtime: RuntimeConfig,
|
|
|
|
|
pub candidate_pool: Vec<NodeId>,
|
|
|
|
|
pub stage_count: u32,
|
|
|
|
|
pub placement: PlacementInput,
|
|
|
|
|
pub activation_ring: RingSpec,
|
|
|
|
|
pub token_ring: RingSpec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub enum EdgeKind {
|
|
|
|
|
TokenIn,
|
|
|
|
|
Activation,
|
|
|
|
|
TokenOut,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum ObjectKind {
|
|
|
|
|
Token,
|
|
|
|
|
Activation,
|
2026-06-25 12:30:18 +00:00
|
|
|
Weight,
|
|
|
|
|
ModelShard,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum ShapeRule {
|
|
|
|
|
TokenIds,
|
|
|
|
|
ActivationRows { max_seq_len: u32, hidden_dim: u32 },
|
|
|
|
|
WeightTensor,
|
|
|
|
|
ModelShardBytes,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum LayoutRule {
|
|
|
|
|
Contiguous,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum SequencePolicy {
|
|
|
|
|
Ordered,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct ObjectSpec {
|
|
|
|
|
pub kind: ObjectKind,
|
|
|
|
|
pub max_extent: u64,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub dtype_family: DTypeFamily,
|
|
|
|
|
pub dtype_width_bytes: u32,
|
|
|
|
|
pub shape: ShapeRule,
|
|
|
|
|
pub layout: LayoutRule,
|
|
|
|
|
pub alignment: u32,
|
|
|
|
|
pub sequence_policy: SequencePolicy,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
|
|
|
pub enum EdgeEndpoint {
|
|
|
|
|
Orchestrator { node_id: NodeId },
|
|
|
|
|
Stage { node_id: NodeId, stage_index: u32 },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct EdgePlan {
|
|
|
|
|
pub run_id: RunId,
|
|
|
|
|
pub edge_id: EdgeId,
|
|
|
|
|
pub kind: EdgeKind,
|
|
|
|
|
pub producer: EdgeEndpoint,
|
|
|
|
|
pub consumer: EdgeEndpoint,
|
|
|
|
|
pub object_spec: ObjectSpec,
|
|
|
|
|
pub ring_spec: RingSpec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct StagePlan {
|
|
|
|
|
pub run_id: RunId,
|
|
|
|
|
pub stage_index: u32,
|
|
|
|
|
pub stage_count: u32,
|
|
|
|
|
pub node_id: NodeId,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub gguf_source: GgufSource,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
pub layer_start: u32,
|
|
|
|
|
pub layer_end_exclusive: u32,
|
|
|
|
|
pub inbound_edge: EdgeId,
|
|
|
|
|
pub outbound_edge: EdgeId,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct RunPlan {
|
|
|
|
|
pub run_id: RunId,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub model: GgufModelPlan,
|
|
|
|
|
pub runtime: RuntimePlan,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
pub stages: Vec<StagePlan>,
|
|
|
|
|
pub edges: Vec<EdgePlan>,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub max_tokens: u32,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct InboundEdgeProvision {
|
|
|
|
|
pub edge_id: EdgeId,
|
|
|
|
|
pub kind: EdgeKind,
|
|
|
|
|
pub object_spec: ObjectSpec,
|
|
|
|
|
pub ring_spec: RingSpec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct OutboundEdgeProvision {
|
|
|
|
|
pub edge_id: EdgeId,
|
|
|
|
|
pub kind: EdgeKind,
|
|
|
|
|
pub consumer_node_id: NodeId,
|
|
|
|
|
pub object_spec: ObjectSpec,
|
|
|
|
|
pub ring_spec: RingSpec,
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct StageModelFacts {
|
|
|
|
|
pub model_id: String,
|
|
|
|
|
pub hidden_dim: u32,
|
|
|
|
|
pub dtype_family: DTypeFamily,
|
|
|
|
|
pub dtype_width_bytes: u32,
|
|
|
|
|
pub max_seq_len: u32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct StageRuntimeFacts {
|
|
|
|
|
pub role_id: RoleId,
|
|
|
|
|
pub input_port: PortId,
|
|
|
|
|
pub output_port: PortId,
|
|
|
|
|
pub sampling: Option<SamplingPolicy>,
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct ProvisionStage {
|
|
|
|
|
pub run_id: RunId,
|
|
|
|
|
pub node_id: NodeId,
|
|
|
|
|
pub stage_index: u32,
|
|
|
|
|
pub stage_count: u32,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub gguf_source: GgufSource,
|
feat(mvp-chat): local e2e chat on cuda gpu
Stand up an interactive end-to-end chat over a CUDA GPU, provisioning a Dockerized node that loads a GGUF model and serves prompts over TCP.
- prompt_rpc: add the newline-JSON prompt protocol (`SubmitPrompt` + `PromptEvent::{TextDelta,Done,Fault}`) carried over TCP
- mvp_chat: add an interactive REPL client connecting to the prompt RPC port (default 127.0.0.1:19777)
- mvp_orch_one_node / mvp_one_node_chat: add the single-node orchestrator that provisions a `LocalDockerPlugin` node, loads `bartowski/Llama-3.2-1B-Instruct-GGUF` (Q4_K_M), and exposes the prompt RPC listener with boot/route/weight timeouts
- mvp_node: add the GPU worker binary that spawns `tinygrad_worker.py` (default device CUDA) and ships runtime telemetry via a `ClusterFrameSink`
- vastai_provisioning / bootstrap_datastream: add the vast.ai provider adapter (`VastAiProvisioningConfig`, `VastAiLeaseClient`) wrapping `swactor_vastai`, plus a bridge that folds provision stdout onto a per-node datastream
- apps/mvp-node: add CUDA base/runtime Dockerfiles (nvidia/cuda 12.6.3, tinygrad 0.12.0, sshd), `mvp_entrypoint.sh` (sshd + mvp-node, held for postmortem), `local_docker_e2e.sh`, the GGUF tinygrad worker, and one-node-chat/bootstrap/vastai guarantee tests
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-01 08:44:25 +00:00
|
|
|
pub tokenizer: TokenizerSource,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
pub layer_start: u32,
|
|
|
|
|
pub layer_end_exclusive: u32,
|
|
|
|
|
pub inbound: InboundEdgeProvision,
|
|
|
|
|
pub outbound: OutboundEdgeProvision,
|
2026-06-25 12:30:18 +00:00
|
|
|
pub model: StageModelFacts,
|
|
|
|
|
pub runtime: StageRuntimeFacts,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum PlanRejectionKind {
|
|
|
|
|
UnknownNode,
|
|
|
|
|
DuplicateStageAssignment,
|
|
|
|
|
MissingStage,
|
|
|
|
|
InvalidStageCount,
|
|
|
|
|
EdgeEndpointMismatch,
|
|
|
|
|
ModelStageLayoutMismatch,
|
|
|
|
|
InvalidObjectSpec,
|
|
|
|
|
UnsupportedShapeOrLayout,
|
|
|
|
|
InvalidRingSpec,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
|
|
|
pub struct PlanRejection {
|
|
|
|
|
kind: PlanRejectionKind,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PlanRejection {
|
|
|
|
|
pub fn kind(&self) -> PlanRejectionKind {
|
|
|
|
|
self.kind
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
|
|
|
pub enum ProjectionRejection {
|
|
|
|
|
UnknownStage,
|
|
|
|
|
MissingEdge,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn plan_run(input: PlannerInput) -> Result<RunPlan, PlanRejection> {
|
|
|
|
|
validate_global_input(&input)?;
|
|
|
|
|
let placements = validated_placements(&input)?;
|
2026-06-25 12:30:18 +00:00
|
|
|
let model = model_plan(&input.model)?;
|
|
|
|
|
let runtime = input.runtime.plan();
|
|
|
|
|
let max_tokens = input.runtime.max_tokens;
|
|
|
|
|
let gguf_source = model.gguf_source.clone();
|
|
|
|
|
let hidden_dim = model.hidden_dim;
|
|
|
|
|
let dtype_width_bytes = model.dtype_width_bytes;
|
|
|
|
|
let max_seq_len = model.max_seq_len;
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
|
|
|
|
|
let activation_extent = input
|
|
|
|
|
.model
|
|
|
|
|
.max_seq_len
|
|
|
|
|
.checked_mul(input.model.hidden_dim)
|
|
|
|
|
.and_then(|value| value.checked_mul(input.model.dtype_width_bytes))
|
|
|
|
|
.ok_or_else(|| reject(PlanRejectionKind::InvalidObjectSpec))?;
|
|
|
|
|
if activation_extent == 0 {
|
|
|
|
|
return Err(reject(PlanRejectionKind::InvalidObjectSpec));
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-12 06:14:34 +00:00
|
|
|
let token_extent = input
|
|
|
|
|
.model
|
|
|
|
|
.max_seq_len
|
|
|
|
|
.checked_mul(u64::from(TOKEN_ID_WIDTH_BYTES))
|
|
|
|
|
.ok_or_else(|| reject(PlanRejectionKind::InvalidObjectSpec))?;
|
|
|
|
|
if token_extent == 0 {
|
|
|
|
|
return Err(reject(PlanRejectionKind::InvalidObjectSpec));
|
|
|
|
|
}
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
let token_spec = ObjectSpec {
|
|
|
|
|
kind: ObjectKind::Token,
|
2026-07-12 06:14:34 +00:00
|
|
|
max_extent: token_extent,
|
2026-06-25 12:30:18 +00:00
|
|
|
dtype_family: input.model.dtype_family,
|
2026-07-12 06:14:34 +00:00
|
|
|
dtype_width_bytes: TOKEN_ID_WIDTH_BYTES,
|
2026-06-25 12:30:18 +00:00
|
|
|
shape: ShapeRule::TokenIds,
|
|
|
|
|
layout: LayoutRule::Contiguous,
|
2026-07-12 06:14:34 +00:00
|
|
|
alignment: TOKEN_ID_WIDTH_BYTES,
|
2026-06-25 12:30:18 +00:00
|
|
|
sequence_policy: SequencePolicy::Ordered,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
};
|
|
|
|
|
let activation_spec = ObjectSpec {
|
|
|
|
|
kind: ObjectKind::Activation,
|
|
|
|
|
max_extent: activation_extent,
|
2026-06-25 12:30:18 +00:00
|
|
|
dtype_family: input.model.dtype_family,
|
|
|
|
|
dtype_width_bytes,
|
|
|
|
|
shape: ShapeRule::ActivationRows {
|
|
|
|
|
max_seq_len,
|
|
|
|
|
hidden_dim,
|
|
|
|
|
},
|
|
|
|
|
layout: LayoutRule::Contiguous,
|
2026-07-12 06:14:34 +00:00
|
|
|
alignment: dtype_width_bytes,
|
2026-06-25 12:30:18 +00:00
|
|
|
sequence_policy: SequencePolicy::Ordered,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
};
|
2026-07-12 06:14:34 +00:00
|
|
|
let token_data_capacity = MO01_HEADER_BYTES
|
|
|
|
|
.checked_add(token_extent)
|
|
|
|
|
.ok_or_else(|| reject(PlanRejectionKind::InvalidObjectSpec))?;
|
|
|
|
|
let mut token_ring = input.token_ring;
|
|
|
|
|
token_ring.data_capacity = token_ring.data_capacity.max(token_data_capacity);
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
|
2026-06-25 07:29:16 +00:00
|
|
|
let mut edge_allocator = EdgeAllocator::new();
|
|
|
|
|
let token_in_edge = edge_allocator.alloc();
|
|
|
|
|
let mut activation_edges = Vec::with_capacity(input.stage_count.saturating_sub(1) as usize);
|
|
|
|
|
for _ in 0..input.stage_count.saturating_sub(1) {
|
|
|
|
|
activation_edges.push(edge_allocator.alloc());
|
|
|
|
|
}
|
|
|
|
|
let token_out_edge = edge_allocator.alloc();
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
let mut edges = Vec::with_capacity(input.stage_count as usize + 1);
|
|
|
|
|
edges.push(EdgePlan {
|
|
|
|
|
run_id: input.run_id,
|
2026-06-25 07:29:16 +00:00
|
|
|
edge_id: token_in_edge,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
kind: EdgeKind::TokenIn,
|
|
|
|
|
producer: EdgeEndpoint::Orchestrator {
|
|
|
|
|
node_id: input.orchestrator_node_id,
|
|
|
|
|
},
|
|
|
|
|
consumer: EdgeEndpoint::Stage {
|
|
|
|
|
node_id: placements[0].node_id,
|
|
|
|
|
stage_index: 0,
|
|
|
|
|
},
|
|
|
|
|
object_spec: token_spec,
|
2026-07-12 06:14:34 +00:00
|
|
|
ring_spec: token_ring,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for stage_index in 0..input.stage_count.saturating_sub(1) {
|
|
|
|
|
edges.push(EdgePlan {
|
|
|
|
|
run_id: input.run_id,
|
2026-06-25 07:29:16 +00:00
|
|
|
edge_id: activation_edges[stage_index as usize],
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
kind: EdgeKind::Activation,
|
|
|
|
|
producer: EdgeEndpoint::Stage {
|
|
|
|
|
node_id: placements[stage_index as usize].node_id,
|
|
|
|
|
stage_index,
|
|
|
|
|
},
|
|
|
|
|
consumer: EdgeEndpoint::Stage {
|
|
|
|
|
node_id: placements[stage_index as usize + 1].node_id,
|
|
|
|
|
stage_index: stage_index + 1,
|
|
|
|
|
},
|
|
|
|
|
object_spec: activation_spec,
|
|
|
|
|
ring_spec: input.activation_ring,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
edges.push(EdgePlan {
|
|
|
|
|
run_id: input.run_id,
|
2026-06-25 07:29:16 +00:00
|
|
|
edge_id: token_out_edge,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
kind: EdgeKind::TokenOut,
|
|
|
|
|
producer: EdgeEndpoint::Stage {
|
|
|
|
|
node_id: placements[input.stage_count as usize - 1].node_id,
|
|
|
|
|
stage_index: input.stage_count - 1,
|
|
|
|
|
},
|
|
|
|
|
consumer: EdgeEndpoint::Orchestrator {
|
|
|
|
|
node_id: input.orchestrator_node_id,
|
|
|
|
|
},
|
|
|
|
|
object_spec: token_spec,
|
2026-07-12 06:14:34 +00:00
|
|
|
ring_spec: token_ring,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
let mut stages = Vec::with_capacity(input.stage_count as usize);
|
|
|
|
|
for placement in &placements {
|
|
|
|
|
let stage_index = placement.stage_index;
|
|
|
|
|
let (start, end) = layer_range(input.model.num_layers, input.stage_count, stage_index);
|
2026-06-25 07:29:16 +00:00
|
|
|
let inbound_edge = if stage_index == 0 {
|
|
|
|
|
token_in_edge
|
|
|
|
|
} else {
|
|
|
|
|
activation_edges[stage_index as usize - 1]
|
|
|
|
|
};
|
|
|
|
|
let outbound_edge = if stage_index + 1 == input.stage_count {
|
|
|
|
|
token_out_edge
|
|
|
|
|
} else {
|
|
|
|
|
activation_edges[stage_index as usize]
|
|
|
|
|
};
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
stages.push(StagePlan {
|
|
|
|
|
run_id: input.run_id,
|
|
|
|
|
stage_index,
|
|
|
|
|
stage_count: input.stage_count,
|
|
|
|
|
node_id: placement.node_id,
|
2026-06-25 12:30:18 +00:00
|
|
|
gguf_source: gguf_source.clone(),
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
layer_start: start,
|
|
|
|
|
layer_end_exclusive: end,
|
2026-06-25 07:29:16 +00:00
|
|
|
inbound_edge,
|
|
|
|
|
outbound_edge,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(RunPlan {
|
|
|
|
|
run_id: input.run_id,
|
2026-06-25 12:30:18 +00:00
|
|
|
model,
|
|
|
|
|
runtime,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
stages,
|
|
|
|
|
edges,
|
2026-06-25 12:30:18 +00:00
|
|
|
max_tokens,
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn derive_stage_provision(
|
|
|
|
|
plan: &RunPlan,
|
|
|
|
|
stage_index: u32,
|
|
|
|
|
) -> Result<ProvisionStage, ProjectionRejection> {
|
|
|
|
|
let stage = plan
|
|
|
|
|
.stages
|
|
|
|
|
.iter()
|
|
|
|
|
.find(|stage| stage.stage_index == stage_index)
|
|
|
|
|
.ok_or(ProjectionRejection::UnknownStage)?;
|
|
|
|
|
let inbound = plan
|
|
|
|
|
.edges
|
|
|
|
|
.iter()
|
|
|
|
|
.find(|edge| edge.edge_id == stage.inbound_edge)
|
|
|
|
|
.ok_or(ProjectionRejection::MissingEdge)?;
|
|
|
|
|
let outbound = plan
|
|
|
|
|
.edges
|
|
|
|
|
.iter()
|
|
|
|
|
.find(|edge| edge.edge_id == stage.outbound_edge)
|
|
|
|
|
.ok_or(ProjectionRejection::MissingEdge)?;
|
|
|
|
|
Ok(ProvisionStage {
|
|
|
|
|
run_id: plan.run_id,
|
|
|
|
|
node_id: stage.node_id,
|
|
|
|
|
stage_index,
|
|
|
|
|
stage_count: stage.stage_count,
|
2026-06-25 12:30:18 +00:00
|
|
|
gguf_source: stage.gguf_source.clone(),
|
feat(mvp-chat): local e2e chat on cuda gpu
Stand up an interactive end-to-end chat over a CUDA GPU, provisioning a Dockerized node that loads a GGUF model and serves prompts over TCP.
- prompt_rpc: add the newline-JSON prompt protocol (`SubmitPrompt` + `PromptEvent::{TextDelta,Done,Fault}`) carried over TCP
- mvp_chat: add an interactive REPL client connecting to the prompt RPC port (default 127.0.0.1:19777)
- mvp_orch_one_node / mvp_one_node_chat: add the single-node orchestrator that provisions a `LocalDockerPlugin` node, loads `bartowski/Llama-3.2-1B-Instruct-GGUF` (Q4_K_M), and exposes the prompt RPC listener with boot/route/weight timeouts
- mvp_node: add the GPU worker binary that spawns `tinygrad_worker.py` (default device CUDA) and ships runtime telemetry via a `ClusterFrameSink`
- vastai_provisioning / bootstrap_datastream: add the vast.ai provider adapter (`VastAiProvisioningConfig`, `VastAiLeaseClient`) wrapping `swactor_vastai`, plus a bridge that folds provision stdout onto a per-node datastream
- apps/mvp-node: add CUDA base/runtime Dockerfiles (nvidia/cuda 12.6.3, tinygrad 0.12.0, sshd), `mvp_entrypoint.sh` (sshd + mvp-node, held for postmortem), `local_docker_e2e.sh`, the GGUF tinygrad worker, and one-node-chat/bootstrap/vastai guarantee tests
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-01 08:44:25 +00:00
|
|
|
tokenizer: plan.model.tokenizer.clone(),
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
layer_start: stage.layer_start,
|
|
|
|
|
layer_end_exclusive: stage.layer_end_exclusive,
|
|
|
|
|
inbound: InboundEdgeProvision {
|
|
|
|
|
edge_id: inbound.edge_id,
|
|
|
|
|
kind: inbound.kind,
|
|
|
|
|
object_spec: inbound.object_spec,
|
2026-06-25 12:30:18 +00:00
|
|
|
ring_spec: ring_spec_for_direction(inbound.ring_spec, RingDirection::Ingress),
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
},
|
|
|
|
|
outbound: OutboundEdgeProvision {
|
|
|
|
|
edge_id: outbound.edge_id,
|
|
|
|
|
kind: outbound.kind,
|
|
|
|
|
consumer_node_id: endpoint_node_id(&outbound.consumer),
|
|
|
|
|
object_spec: outbound.object_spec,
|
2026-06-25 12:30:18 +00:00
|
|
|
ring_spec: ring_spec_for_direction(outbound.ring_spec, RingDirection::Egress),
|
|
|
|
|
},
|
|
|
|
|
model: StageModelFacts {
|
|
|
|
|
model_id: plan.model.model_id.clone(),
|
|
|
|
|
hidden_dim: plan.model.hidden_dim,
|
|
|
|
|
dtype_family: plan.model.dtype_family,
|
|
|
|
|
dtype_width_bytes: plan.model.dtype_width_bytes,
|
|
|
|
|
max_seq_len: plan.model.max_seq_len,
|
|
|
|
|
},
|
|
|
|
|
runtime: StageRuntimeFacts {
|
|
|
|
|
role_id: RoleId(u64::from(stage.stage_index)),
|
|
|
|
|
input_port: PortId("input".to_owned()),
|
|
|
|
|
output_port: PortId("output".to_owned()),
|
|
|
|
|
sampling: if stage.stage_index + 1 == stage.stage_count {
|
|
|
|
|
Some(plan.runtime.sampling)
|
|
|
|
|
} else {
|
|
|
|
|
None
|
|
|
|
|
},
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn validate_global_input(input: &PlannerInput) -> Result<(), PlanRejection> {
|
|
|
|
|
if input.stage_count == 0 {
|
|
|
|
|
return Err(reject(PlanRejectionKind::InvalidStageCount));
|
|
|
|
|
}
|
|
|
|
|
if input.model.num_layers < input.stage_count {
|
|
|
|
|
return Err(reject(PlanRejectionKind::ModelStageLayoutMismatch));
|
|
|
|
|
}
|
|
|
|
|
if input.model.max_seq_len == 0 || input.model.dtype_width_bytes == 0 {
|
|
|
|
|
return Err(reject(PlanRejectionKind::InvalidObjectSpec));
|
|
|
|
|
}
|
|
|
|
|
if input.model.hidden_dim == 0 {
|
|
|
|
|
return Err(reject(PlanRejectionKind::UnsupportedShapeOrLayout));
|
|
|
|
|
}
|
|
|
|
|
if !valid_ring(input.activation_ring) || !valid_ring(input.token_ring) {
|
|
|
|
|
return Err(reject(PlanRejectionKind::InvalidRingSpec));
|
|
|
|
|
}
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn validated_placements(input: &PlannerInput) -> Result<Vec<StagePlacement>, PlanRejection> {
|
refactor: prune public api
Collapse mvp-system's public surface to three binary entrypoints and make every domain module private, deleting dead provider/worker/membership implementations and inlining provider config.
- lib.rs: expose only run_chat_from_args/run_orchestrator_from_args/run_worker_node_from_env (plus a crate-private in-process helper) and the cached-model consts, and demote chat/node/observability/orchestration/prompt/staging/transport to private mods
- orchestration/mod.rs: make app private, gate engine_builder behind cfg(test), drop docker_cluster from provider_adapters, tighten vastai to pub(super), and replace pub re-exports with pub(super) run_from_args/run_in_process_from_args
- orchestration/config.rs: inline VastAiConfig/ResolvedVastAiConfig/looks_remote_image (removing provider_adapters/vastai/config.rs) and drop the DEFAULT_PIPELINE_CACHED_MODEL_* consts (hoisted to lib.rs)
- orchestration/provider_adapters/vastai: delete the ProviderPlugin impl VastAiProviderPlugin and all client/bootstrap/config accessors; repoint call sites to crate-level #[path] mods for provisioning/node_provisioning/node_actor/gguf_shard/run_fsm/run_plan
- delete orchestration/{membership_readiness,token_endpoint,resource_inventory}, node/{boot_lifecycle,data_plane_bridge(-74)}, and the worker crate-internal modules (control/device_bridge/process_adapter) along with their guarantees tests
- chat/node: narrow node_image and worker_node_runtime to private and expose only pub(super) run_from_args / run_worker_node_from_env
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-07-29 10:02:50 +00:00
|
|
|
let PlacementInput::FixedLinear(stages) = &input.placement;
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
|
|
|
|
|
let candidate_nodes = input
|
|
|
|
|
.candidate_pool
|
|
|
|
|
.iter()
|
|
|
|
|
.copied()
|
|
|
|
|
.collect::<std::collections::BTreeSet<_>>();
|
|
|
|
|
let mut by_stage = std::collections::BTreeMap::new();
|
|
|
|
|
for placement in stages {
|
|
|
|
|
if !candidate_nodes.contains(&placement.node_id) {
|
|
|
|
|
return Err(reject(PlanRejectionKind::UnknownNode));
|
|
|
|
|
}
|
|
|
|
|
if by_stage.insert(placement.stage_index, *placement).is_some() {
|
|
|
|
|
return Err(reject(PlanRejectionKind::DuplicateStageAssignment));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let mut dense = Vec::with_capacity(input.stage_count as usize);
|
|
|
|
|
for stage_index in 0..input.stage_count {
|
|
|
|
|
let placement = by_stage
|
|
|
|
|
.remove(&stage_index)
|
|
|
|
|
.ok_or_else(|| reject(PlanRejectionKind::MissingStage))?;
|
|
|
|
|
dense.push(placement);
|
|
|
|
|
}
|
|
|
|
|
Ok(dense)
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-25 12:30:18 +00:00
|
|
|
fn model_plan(model: &ModelFacts) -> Result<GgufModelPlan, PlanRejection> {
|
|
|
|
|
let hidden_dim = u32::try_from(model.hidden_dim)
|
|
|
|
|
.map_err(|_| reject(PlanRejectionKind::UnsupportedShapeOrLayout))?;
|
|
|
|
|
let dtype_width_bytes = u32::try_from(model.dtype_width_bytes)
|
|
|
|
|
.map_err(|_| reject(PlanRejectionKind::InvalidObjectSpec))?;
|
|
|
|
|
let max_seq_len = u32::try_from(model.max_seq_len)
|
|
|
|
|
.map_err(|_| reject(PlanRejectionKind::InvalidObjectSpec))?;
|
|
|
|
|
|
|
|
|
|
Ok(GgufModelPlan {
|
|
|
|
|
model_id: model.model_id.clone(),
|
|
|
|
|
gguf_source: model.gguf_source.clone(),
|
|
|
|
|
num_layers: model.num_layers,
|
|
|
|
|
hidden_dim,
|
|
|
|
|
dtype_family: model.dtype_family,
|
|
|
|
|
dtype_width_bytes,
|
|
|
|
|
max_seq_len,
|
|
|
|
|
eos_token_id: model.eos_token_id,
|
|
|
|
|
tokenizer: model.tokenizer.clone(),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn ring_spec_for_direction(mut spec: RingSpec, direction: RingDirection) -> RingSpec {
|
|
|
|
|
spec.direction = direction;
|
|
|
|
|
spec
|
|
|
|
|
}
|
|
|
|
|
|
feat(mvp): implement mvp-system modules and in-crate tests
Implement arena_manager, device_bridge, driver_pumps, edge_establisher, gpu_worker
ctl/egress/ingress/process-adapter, orchestrator run-fsm and token-endpoint, run_plan,
stage_controller, tx_rx_edge_actor, weight_lifecycle, and the remaining modules. Move
guarantee tests from tests/mvp_system into crates/mvp-system/src/tests; add the
tinygrad device-bridge backend helper.
Signed-off-by: Zachery Aaron Shores-Chmielewski <zacheryasc@gmail.com>
2026-06-23 13:51:34 +00:00
|
|
|
fn layer_range(num_layers: u32, stage_count: u32, stage_index: u32) -> (u32, u32) {
|
|
|
|
|
let start = (u64::from(num_layers) * u64::from(stage_index) / u64::from(stage_count)) as u32;
|
|
|
|
|
let end = (u64::from(num_layers) * u64::from(stage_index + 1) / u64::from(stage_count)) as u32;
|
|
|
|
|
(start, end)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn endpoint_node_id(endpoint: &EdgeEndpoint) -> NodeId {
|
|
|
|
|
match endpoint {
|
|
|
|
|
EdgeEndpoint::Orchestrator { node_id } | EdgeEndpoint::Stage { node_id, .. } => *node_id,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn valid_ring(spec: RingSpec) -> bool {
|
|
|
|
|
spec.data_capacity > 0 && spec.alignment > 0 && spec.alignment.is_power_of_two()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn reject(kind: PlanRejectionKind) -> PlanRejection {
|
|
|
|
|
PlanRejection { kind }
|
|
|
|
|
}
|