Skip to content

Commit

Permalink
Change default precision to BF16; fix the bug when input is batched (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: kaixuanliu <[email protected]>
  • Loading branch information
kaixuanliu authored Apr 18, 2024
1 parent b5fc2bc commit 54bb856
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def embed(self, batch: PaddedBatch) -> List[Embedding]:

output = self.model(**kwargs)
embedding = output[0][:, 0]
cpu_results = embedding.view(-1).tolist()
cpu_results = embedding.reshape(-1).tolist()

return [
Embedding(
Expand Down
2 changes: 2 additions & 0 deletions backends/src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub enum DType {
all(feature = "candle", not(feature = "accelerate"))
))]
Float16,
BFloat16,
// Float32 is not available on candle cuda
#[cfg(any(feature = "python", feature = "candle"))]
Float32,
Expand All @@ -28,6 +29,7 @@ impl fmt::Display for DType {
all(feature = "candle", not(feature = "accelerate"))
))]
DType::Float16 => write!(f, "float16"),
DType::BFloat16 => write!(f, "bfloat16"),
// Float32 is not available on candle cuda
#[cfg(any(feature = "python", feature = "candle"))]
DType::Float32 => write!(f, "float32"),
Expand Down
2 changes: 1 addition & 1 deletion router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub async fn run(
}
#[cfg(not(any(feature = "accelerate", feature = "mkl", feature = "mkl-dynamic")))]
{
DType::Float16
DType::BFloat16
}
});

Expand Down

0 comments on commit 54bb856

Please sign in to comment.