Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --cpu flag to mistralrs-server #997

Merged
merged 6 commits into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions mistralrs-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl MistralRsBuilder {
self.disable_eos_stop = Some(disable_eos_stop);
self
}
/// This setting is only applicable on CUDA. If set to false or not specified, this setting enables f16/bf16 reduced precision matmul for GPUs which support it. If set to true, this setting has no effect.
pub fn with_gemm_full_precision_f16(mut self, gemm_full_precision: bool) -> Self {
self.gemm_full_precision_f16 = Some(gemm_full_precision);
self
Expand Down
11 changes: 10 additions & 1 deletion mistralrs-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ struct Args {
/// Number of tokens to batch the prompt step into. This can help with OOM errors when in the prompt step, but reduces performance.
#[arg(long = "prompt-batchsize")]
prompt_batchsize: Option<usize>,

/// Use CPU only
#[arg(long)]
cpu: bool,
}

#[utoipa::path(
Expand Down Expand Up @@ -314,7 +318,12 @@ async fn main() -> Result<()> {
#[cfg(feature = "metal")]
let device = Device::new_metal(0)?;
#[cfg(not(feature = "metal"))]
let device = Device::cuda_if_available(0)?;
let device = if args.cpu {
args.no_paged_attn = true;
Device::Cpu
} else {
Device::cuda_if_available(0)?
};

if let Some(seed) = args.seed {
device.set_seed(seed)?;
Expand Down
Loading