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
|
|
|
use std::io::{BufRead, BufReader, Read};
|
|
|
|
|
use std::thread::{self, JoinHandle};
|
|
|
|
|
|
|
|
|
|
use datastream::{ChannelId, DatastreamProducer, Lifetime, NodeId, StreamId};
|
2026-07-05 09:59:51 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
use serde_json::Value;
|
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
|
|
|
|
|
|
|
|
use crate::provisioning::{
|
|
|
|
|
NodeProvisionSpec, PluginObservation, PluginSink, ProvisionLogLine, ProvisionLogStream,
|
|
|
|
|
};
|
|
|
|
|
use crate::telemetry::{MvpProvisionLogRecord, mvp_provision_log_channel};
|
|
|
|
|
|
|
|
|
|
pub fn node_datastream_id(node_id: u64) -> String {
|
|
|
|
|
node_id.to_string()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn node_stream_id(run_id: u64, node_id: u64) -> StreamId {
|
|
|
|
|
StreamId::new(NodeId::new(&node_datastream_id(node_id)), Lifetime(run_id))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct BootstrapDatastreamBridge {
|
|
|
|
|
spec: NodeProvisionSpec,
|
|
|
|
|
sink: PluginSink,
|
|
|
|
|
producer: Option<DatastreamProducer>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl BootstrapDatastreamBridge {
|
|
|
|
|
pub fn new(
|
|
|
|
|
spec: NodeProvisionSpec,
|
|
|
|
|
sink: PluginSink,
|
|
|
|
|
producer: Option<DatastreamProducer>,
|
|
|
|
|
) -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
spec,
|
|
|
|
|
sink,
|
|
|
|
|
producer,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn spec(&self) -> &NodeProvisionSpec {
|
|
|
|
|
&self.spec
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn stream_id(&self) -> StreamId {
|
|
|
|
|
node_stream_id(self.spec.run_id, self.spec.node_id)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn observe_stdout_line(&self, line: impl Into<String>) {
|
|
|
|
|
let line = line.into();
|
2026-07-05 09:59:51 +00:00
|
|
|
if let Some(frame) = parse_stdio_datastream_frame(&self.spec, &line) {
|
|
|
|
|
self.sink.observe(frame);
|
|
|
|
|
return;
|
|
|
|
|
}
|
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
|
|
|
self.submit_log(ProvisionLogStream::Stdout, &line);
|
|
|
|
|
self.sink.observe(PluginObservation::StdoutLine {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
line: line.clone(),
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn observe_stderr_line(&self, line: impl Into<String>) {
|
|
|
|
|
let line = line.into();
|
|
|
|
|
self.submit_log(ProvisionLogStream::Stderr, &line);
|
|
|
|
|
self.sink.observe(PluginObservation::StderrLine {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
line,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn observe_provider_line(&self, line: impl Into<String>) {
|
|
|
|
|
let line = line.into();
|
|
|
|
|
self.submit_log(ProvisionLogStream::Provider, &line);
|
|
|
|
|
self.sink.observe(PluginObservation::ProviderLine {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
line,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn spawn_stdout_reader<R>(&self, stdout: R) -> JoinHandle<()>
|
|
|
|
|
where
|
|
|
|
|
R: Read + Send + 'static,
|
|
|
|
|
{
|
|
|
|
|
let bridge = self.clone();
|
|
|
|
|
thread::spawn(move || bridge.read_stdout(stdout))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn spawn_stderr_reader<R>(&self, stderr: R) -> JoinHandle<()>
|
|
|
|
|
where
|
|
|
|
|
R: Read + Send + 'static,
|
|
|
|
|
{
|
|
|
|
|
let bridge = self.clone();
|
|
|
|
|
thread::spawn(move || bridge.read_stderr(stderr))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn read_stdout<R>(&self, stdout: R)
|
|
|
|
|
where
|
|
|
|
|
R: Read,
|
|
|
|
|
{
|
|
|
|
|
let reader = BufReader::new(stdout);
|
|
|
|
|
for next in reader.lines() {
|
|
|
|
|
match next {
|
|
|
|
|
Ok(line) => self.observe_stdout_line(line),
|
|
|
|
|
Err(error) => {
|
|
|
|
|
self.sink.observe(PluginObservation::Failed {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
reason: format!("read stdout: {error}"),
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn read_stderr<R>(&self, stderr: R)
|
|
|
|
|
where
|
|
|
|
|
R: Read,
|
|
|
|
|
{
|
|
|
|
|
let reader = BufReader::new(stderr);
|
|
|
|
|
for next in reader.lines() {
|
|
|
|
|
match next {
|
|
|
|
|
Ok(line) => self.observe_stderr_line(line),
|
|
|
|
|
Err(error) => {
|
|
|
|
|
self.sink.observe(PluginObservation::Failed {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
reason: format!("read stderr: {error}"),
|
|
|
|
|
});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn submit_log(&self, stream: ProvisionLogStream, line: &str) {
|
|
|
|
|
let Some(producer) = &self.producer else {
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
let record = MvpProvisionLogRecord::new(ProvisionLogLine {
|
|
|
|
|
run_id: self.spec.run_id,
|
|
|
|
|
node_id: self.spec.node_id,
|
|
|
|
|
stream,
|
|
|
|
|
line: line.to_owned(),
|
|
|
|
|
});
|
|
|
|
|
let payload = serde_json::to_vec(&record).expect("serialize bootstrap log record");
|
|
|
|
|
producer.submit_bytes(
|
|
|
|
|
mvp_provision_log_channel(self.spec.node_id, stream),
|
|
|
|
|
payload,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 09:59:51 +00:00
|
|
|
#[derive(Deserialize, Serialize)]
|
|
|
|
|
struct StdioDatastreamFrame {
|
|
|
|
|
mvp_stdio_event: u32,
|
|
|
|
|
kind: String,
|
|
|
|
|
channel: String,
|
|
|
|
|
payload: Value,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn parse_stdio_datastream_frame(
|
|
|
|
|
spec: &NodeProvisionSpec,
|
|
|
|
|
line: &str,
|
|
|
|
|
) -> Option<PluginObservation> {
|
|
|
|
|
let frame = serde_json::from_str::<StdioDatastreamFrame>(line).ok()?;
|
|
|
|
|
if frame.mvp_stdio_event != 1 || frame.kind != "datastream_frame" {
|
|
|
|
|
return None;
|
|
|
|
|
}
|
|
|
|
|
Some(PluginObservation::DatastreamFrame {
|
|
|
|
|
run_id: spec.run_id,
|
|
|
|
|
node_id: spec.node_id,
|
|
|
|
|
channel: frame.channel,
|
|
|
|
|
payload: frame.payload.to_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
|
|
|
pub fn bootstrap_log_channel(node_id: u64, stream: ProvisionLogStream) -> ChannelId {
|
|
|
|
|
mvp_provision_log_channel(node_id, stream)
|
|
|
|
|
}
|