summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/book-cd.yml2
-rw-r--r--candle-book/src/inference/hub.md4
-rw-r--r--candle-examples/src/lib.rs8
3 files changed, 6 insertions, 8 deletions
diff --git a/.github/workflows/book-cd.yml b/.github/workflows/book-cd.yml
index fc693a78..e8149e38 100644
--- a/.github/workflows/book-cd.yml
+++ b/.github/workflows/book-cd.yml
@@ -1,7 +1,5 @@
name: Deploy Rust book
on:
- # TODO put this back only when merging after this PR lands.
- pull_request:
push:
branches:
- main
diff --git a/candle-book/src/inference/hub.md b/candle-book/src/inference/hub.md
index a974a1fa..b924b76d 100644
--- a/candle-book/src/inference/hub.md
+++ b/candle-book/src/inference/hub.md
@@ -67,8 +67,8 @@ let bias = weights.get("bert.encoder.layer.0.attention.self.query.bias").unwrap(
let linear = Linear::new(weight.clone(), Some(bias.clone()));
-let input_ids = Tensor::zeros((3, 7680), DType::F32, &Device::Cpu).unwrap();
-let output = linear.forward(&input_ids);
+let input_ids = Tensor::zeros((3, 768), DType::F32, &Device::Cpu).unwrap();
+let output = linear.forward(&input_ids).unwrap();
```
For a full reference, you can check out the full [bert](https://github.com/LaurentMazare/candle/tree/main/candle-examples/examples/bert) example.
diff --git a/candle-examples/src/lib.rs b/candle-examples/src/lib.rs
index 3410026e..2b6009b4 100644
--- a/candle-examples/src/lib.rs
+++ b/candle-examples/src/lib.rs
@@ -73,8 +73,8 @@ let mmap = unsafe { Mmap::map(&file).unwrap() };
// Use safetensors directly
let tensors = SafeTensors::deserialize(&mmap[..]).unwrap();
let view = tensors
-.tensor("bert.encoder.layer.0.attention.self.query.weight")
-.unwrap();
+ .tensor("bert.encoder.layer.0.attention.self.query.weight")
+ .unwrap();
// We're going to load shard with rank 1, within a world_size of 4
// We're going to split along dimension 0 doing VIEW[start..stop, :]
@@ -86,7 +86,7 @@ let mut tp_shape = view.shape().to_vec();
let size = tp_shape[0];
if size % world_size != 0 {
-panic!("The dimension is not divisble by `world_size`");
+ panic!("The dimension is not divisble by `world_size`");
}
let block_size = size / world_size;
let start = rank * block_size;
@@ -102,7 +102,7 @@ tp_shape[dim] = block_size;
// Convert safetensors Dtype to candle DType
let dtype: DType = dtype.try_into().unwrap();
-// TODO: Implement from_buffer_iterator to we can skip the extra CPU alloc.
+// TODO: Implement from_buffer_iterator so we can skip the extra CPU alloc.
let raw: Vec<u8> = iterator.into_iter().flatten().cloned().collect();
let tp_tensor = Tensor::from_raw_buffer(&raw, dtype, &tp_shape, &Device::Cpu).unwrap();
// ANCHOR_END: book_hub_3