Skip to content

Commit

Permalink
Accommodate limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Oct 31, 2023
1 parent 7f0c225 commit 98592e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
17 changes: 11 additions & 6 deletions candle-lora-transformers/examples/llama.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,17 @@ fn main() -> Result<()> {
};

let device = candle_examples::device(args.cpu)?;
let dtype = match args.dtype.as_deref() {
Some("f16") => DType::F16,
Some("bf16") => DType::BF16,
Some("f32") => DType::F32,
Some(dtype) => bail!("Unsupported dtype {dtype}"),
None => DType::F16,
let dtype = if device.is_cpu() {
match args.dtype.as_deref() {
Some("f16") => DType::F16,
Some("bf16") => DType::BF16,
Some("f32") => DType::F32,
Some(dtype) => bail!("Unsupported dtype {dtype}"),
None => DType::F16,
}
} else {
//Limitation of `rand_normal`, see https://github.com/huggingface/candle/issues/1224
DType::F32
};

let (llama, tokenizer_filename, cache) = match args.npy {
Expand Down
2 changes: 1 addition & 1 deletion candle-lora-transformers/examples/mistral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ fn main() -> Result<()> {

let device = candle_examples::device(args.cpu)?;
let dtype = if device.is_cuda() {

Check failure on line 229 in candle-lora-transformers/examples/mistral.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` has identical blocks
DType::BF16
DType::F32 //DType::BF16 Limitation of `rand_normal`, see https://github.com/huggingface/candle/issues/1224
} else {
DType::F32
};
Expand Down
2 changes: 1 addition & 1 deletion candle-lora-transformers/examples/stable_lm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn main() -> Result<()> {

let device = candle_examples::device(args.cpu)?;
let dtype = if device.is_cuda() {

Check failure on line 226 in candle-lora-transformers/examples/stable_lm.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` has identical blocks
DType::BF16
DType::F32 //DType::BF16 Limitation of `rand_normal`, see https://github.com/huggingface/candle/issues/1224
} else {
DType::F32
};
Expand Down

0 comments on commit 98592e6

Please sign in to comment.