Skip to content

Commit 56dd0a0

Browse files
committed
feat(trtllm): check existence of config files
When the required config files are not present, nlohmann/json throws parsing error, which does not help much for identifying what was wrong. Check the existence of these files early and return specific error messages.
1 parent 987337b commit 56dd0a0

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

backends/trtllm/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,8 @@ pub enum TensorRtLlmBackendError {
1919
WebServer(#[from] server::WebServerError),
2020
#[error("Tokio runtime failed to start: {0}")]
2121
Tokio(#[from] std::io::Error),
22+
#[error("config.json doesn't exist in engine folder {0}")]
23+
ConfigNotFound(PathBuf),
24+
#[error("generation_config.json doesn't exist in engine folder {0}")]
25+
GenerationConfigNotFound(PathBuf),
2226
}

backends/trtllm/src/looper.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use cxx::UniquePtr;
33
use hashbrown::HashMap;
44
use std::hint;
55
use std::ops::Deref;
6-
use std::path::Path;
6+
use std::path::{Path, PathBuf};
77
use tokenizers::Tokenizer;
88
use tokio::sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender};
99
use tokio::sync::TryAcquireError;
@@ -283,6 +283,26 @@ fn ensure_paths_exist<P: AsRef<Path>, PP: AsRef<Path>>(
283283
return Err(err);
284284
}
285285

286+
let mut config_path = PathBuf::from(engine_folder);
287+
config_path.push("config.json");
288+
289+
if !config_path.exists() {
290+
let err = TensorRtLlmBackendError::ConfigNotFound(engine_folder.to_path_buf());
291+
292+
error!("Path validation failed: {}", err,);
293+
return Err(err);
294+
}
295+
296+
let mut generation_config_path = PathBuf::from(engine_folder);
297+
generation_config_path.push("generation_config.json");
298+
299+
if !generation_config_path.exists() {
300+
let err = TensorRtLlmBackendError::GenerationConfigNotFound(engine_folder.to_path_buf());
301+
302+
error!("Path validation failed: {}", err,);
303+
return Err(err);
304+
}
305+
286306
// Ensure executor worker binary exists
287307
if !executor_worker_path.exists() {
288308
let err = TensorRtLlmBackendError::ExecutorWorkerNotFound(engine_folder.to_path_buf());

0 commit comments

Comments
 (0)