Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions lib/llm/src/engines/sglang/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ use crate::protocols::TokenIdType;
const SGLANG_STOP_TIMEOUT: Duration = Duration::from_millis(1500);

/// Match sglang python log entries, e.g "[2025-01-30 11:23:16] Some text we want"
const SGLANG_LOG_RE: &str = r"(\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] )?(.*)";
const SGLANG_LOG_RE: &str =
r"(?<timestamp>\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] )?(?<message>.*)";

/// Identify sglang log entries with this prefix
const LOG_PREFIX: &str = "SGLANG";
Expand Down Expand Up @@ -506,18 +507,15 @@ async fn start_sglang(
let line_re = Regex::new(SGLANG_LOG_RE).unwrap();
let mut lines = stderr.lines();
while let Ok(Some(line)) = lines.next_line().await {
if let Some(cap) = line_re.captures(&line) {
match cap.len() {
2 => {
// No date/time, these are usually errors
tracing::warn!("{LOG_PREFIX}{tp_rank} {line}");
}
3 => {
// Normal log line. Skip Python's date/time
tracing::debug!("{LOG_PREFIX}{tp_rank} {}", &cap[2]);
if let Some(caps) = line_re.captures(&line) {
match caps.name("timestamp") {
Some(_) => {
// Skip Python's date/time. Should be normal log
tracing::debug!("{LOG_PREFIX}{tp_rank} {}", &caps["message"]);
}
x => {
unreachable!("sglang log re only has two capture groups, so {x} entries is impossible");
None => {
// No date/time. Usually errors
tracing::warn!("{LOG_PREFIX}{tp_rank} {line}");
}
}
}
Expand Down