Align DeepSeek and GLM execution with DS4

This commit is contained in:
Georg Bauer
2026-09-11 17:18:45 +02:00
parent 02db0968ae
commit 48c2f751b4
27 changed files with 4517 additions and 400 deletions
+58 -6
View File
@@ -59,6 +59,8 @@ mod supervisor {
value["event"].as_str(),
Some(
"gpu_canary_sample"
| "gpu_canary_ready"
| "gpu_canary_stall"
| "gpu_canary_summary"
| "reference_canary_summary"
| "test_resource_sample"
@@ -80,6 +82,31 @@ mod supervisor {
progressed
}
// Keep complete records together when the watchdog writes resource samples
// to the same stream. Pipe reads can split a single worker JSON record.
fn forward_records(
output: &mut impl Write,
pending: &mut Vec<u8>,
bytes: &[u8],
eof: bool,
) -> io::Result<()> {
pending.extend_from_slice(bytes);
let end = if eof || pending.len() > 64 * 1024 {
pending.len()
} else {
pending
.iter()
.rposition(|&b| b == b'\n')
.map_or(0, |i| i + 1)
};
if end > 0 {
output.write_all(&pending[..end])?;
output.flush()?;
pending.drain(..end);
}
Ok(())
}
fn forward(
mut input: impl Read + Send + 'static,
mut output: impl Write + Send + 'static,
@@ -88,15 +115,17 @@ mod supervisor {
thread::spawn(move || {
let mut bytes = [0; 4096];
let mut pending = Vec::new();
let mut records = Vec::new();
loop {
match input.read(&mut bytes) {
Ok(0) => return,
Ok(0) => {
if forward_records(&mut output, &mut records, &[], true).is_err() {
progress.lock().unwrap().failed = true;
}
return;
}
Ok(n) => {
if output
.write_all(&bytes[..n])
.and_then(|()| output.flush())
.is_err()
{
if forward_records(&mut output, &mut records, &bytes[..n], false).is_err() {
progress.lock().unwrap().failed = true;
return;
}
@@ -257,6 +286,29 @@ mod supervisor {
mod tests {
use super::*;
#[test]
fn split_records_cannot_be_interleaved_with_watchdog_samples() {
let mut output = Vec::new();
let mut pending = Vec::new();
forward_records(
&mut output,
&mut pending,
b"{\"event\":\"gpu_canary_",
false,
)
.unwrap();
assert!(output.is_empty());
output.extend_from_slice(b"{\"event\":\"test_resource_sample\"}\n");
forward_records(&mut output, &mut pending, b"sample\"}\npartial", false).unwrap();
for line in output.split(|&b| b == b'\n').filter(|l| !l.is_empty()) {
serde_json::from_slice::<serde_json::Value>(line).unwrap();
}
assert_eq!(pending, b"partial");
forward_records(&mut output, &mut pending, &[], true).unwrap();
assert!(output.ends_with(b"partial"));
assert!(pending.is_empty());
}
#[test]
fn direct_worker_arguments_are_not_rust_test_arguments() {
let args = |a: &[&str]| a.iter().map(std::ffi::OsString::from).collect::<Vec<_>>();