Skip to content

Commit

Permalink
More verbose logging during loading (#385)
Browse files Browse the repository at this point in the history
* More verbose logging when loading

* More logging
  • Loading branch information
EricLBuehler authored Jun 5, 2024
1 parent 9712da6 commit 798adb4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mistralrs-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ fn set_gemm_reduced_precision_f16() {
let a = Tensor::zeros((2, 2), DType::BF16, &Device::new_cuda(0).unwrap()).unwrap();
candle_core::cuda::set_gemm_reduced_precision_bf16(true);
match a.matmul(&a) {
Ok(_) => (),
Ok(_) => tracing::info!("Enabling GEMM reduced precision in BF16."),
Err(e) => {
if format!("{e:?}").contains("CUBLAS_STATUS_NOT_SUPPORTED") {
tracing::info!("GEMM reduced precision in BF16 not supported.");
Expand All @@ -167,7 +167,7 @@ fn set_gemm_reduced_precision_f16() {
let a = Tensor::zeros((2, 2), DType::F16, &Device::new_cuda(0).unwrap()).unwrap();
candle_core::cuda::set_gemm_reduced_precision_f16(true);
match a.matmul(&a) {
Ok(_) => (),
Ok(_) => tracing::info!("Enabling GEMM reduced precision in F16."),
Err(e) => {
if format!("{e:?}").contains("CUBLAS_STATUS_NOT_SUPPORTED") {
tracing::info!("GEMM reduced precision in F16 not supported.");
Expand Down
20 changes: 15 additions & 5 deletions mistralrs-core/src/pipeline/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ macro_rules! get_paths {
info!("Using tokenizer.json at `{p}`");
PathBuf::from_str(p)?
} else {
info!("Loading `tokenizer.json` at `{}`", $this.model_id);
$crate::api_get_file!(api, "tokenizer.json", model_id)
};

info!("Loading `config.json` at `{}`", $this.model_id);
let config_filename = $crate::api_get_file!(api, "config.json", model_id);

let filenames = get_model_paths(
Expand Down Expand Up @@ -125,6 +127,7 @@ macro_rules! get_paths {
.collect::<Vec<_>>()
.contains(&"generation_config.json".to_string())
{
info!("Loading `generation_config.json` at `{}`", $this.model_id);
Some($crate::api_get_file!(
api,
"generation_config.json",
Expand All @@ -138,6 +141,7 @@ macro_rules! get_paths {
.collect::<Vec<_>>()
.contains(&"preprocessor_config.json".to_string())
{
info!("Loading `preprocessor_config.json` at `{}`", $this.model_id);
Some($crate::api_get_file!(
api,
"preprocessor_config.json",
Expand All @@ -151,6 +155,7 @@ macro_rules! get_paths {
.collect::<Vec<_>>()
.contains(&"processor_config.json".to_string())
{
info!("Loading `processor_config.json` at `{}`", $this.model_id);
Some($crate::api_get_file!(
api,
"processor_config.json",
Expand All @@ -160,6 +165,7 @@ macro_rules! get_paths {
None
};

info!("Loading `tokenizer_config.json` at `{}`", $this.model_id);
let template_filename = $crate::api_get_file!(api, "tokenizer_config.json", model_id);

Ok(Box::new($path_name {
Expand Down Expand Up @@ -188,14 +194,13 @@ macro_rules! get_paths_gguf {
.with_token(get_token($token_source)?)
.build()?;
let revision = $revision.unwrap_or("main".to_string());
let model_id_this = $this.model_id.clone().unwrap_or($this.quantized_model_id.clone());
let model_id_copy = model_id_this.clone();
let this_model_id = $this.model_id.clone().unwrap_or($this.quantized_model_id.clone());
let api = api.repo(Repo::with_revision(
model_id_this.clone(),
this_model_id.clone(),
RepoType::Model,
revision.clone(),
));
let model_id = std::path::Path::new(&model_id_copy);
let model_id = std::path::Path::new(&this_model_id);

let chat_template = if let Some(ref p) = $this.chat_template {
if p.ends_with(".json") {
Expand All @@ -205,6 +210,7 @@ macro_rules! get_paths_gguf {
PathBuf::from_str("")?
}
} else {
info!("Loading `tokenizer_config.json` at `{}` because no chat template file was specified.", this_model_id);
$crate::api_get_file!(
api,
"tokenizer_config.json",
Expand All @@ -229,7 +235,7 @@ macro_rules! get_paths_gguf {
xlora_config,
lora_preload_adapter_info,
} = get_xlora_paths(
model_id_this,
this_model_id.clone(),
&$this.xlora_model_id,
&$token_source,
revision.clone(),
Expand All @@ -240,6 +246,7 @@ macro_rules! get_paths_gguf {
.collect::<Vec<_>>()
.contains(&"generation_config.json".to_string())
{
info!("Loading `generation_config.json` at `{}`", this_model_id);
Some($crate::api_get_file!(
api,
"generation_config.json",
Expand All @@ -253,6 +260,7 @@ macro_rules! get_paths_gguf {
.collect::<Vec<_>>()
.contains(&"preprocessor_config.json".to_string())
{
info!("Loading `preprocessor_config.json` at `{}`", this_model_id);
Some($crate::api_get_file!(
api,
"preprocessor_config.json",
Expand All @@ -266,6 +274,7 @@ macro_rules! get_paths_gguf {
.collect::<Vec<_>>()
.contains(&"processor_config.json".to_string())
{
info!("Loading `processor_config.json` at `{}`", this_model_id);
Some($crate::api_get_file!(
api,
"processor_config.json",
Expand All @@ -276,6 +285,7 @@ macro_rules! get_paths_gguf {
};

let tokenizer_filename = if $this.model_id.is_some() {
info!("Loading `tokenizer.json` at `{}`", this_model_id);
$crate::api_get_file!(api, "tokenizer.json", model_id)
} else {
PathBuf::from_str("")?
Expand Down

0 comments on commit 798adb4

Please sign in to comment.