Skip to content

Commit

Permalink
Fix warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Noeda committed Apr 5, 2023
1 parent e27e649 commit 88cb876
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 28 deletions.
14 changes: 7 additions & 7 deletions src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::unpickler::Value;
use ouroboros::self_referencing;
use std::io::{Read, Seek};
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use std::sync::{Arc};
use thiserror::Error;

#[derive(Error, Debug)]
Expand Down Expand Up @@ -58,12 +58,12 @@ impl Read for ZipFileSeekWrap {
impl Seek for ZipFileSeekWrap {
fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result<u64> {
self.with_mut(|mut s| {
let mut reader = &mut s.reader;
let reader = &mut s.reader;
match pos {
std::io::SeekFrom::Start(pos) => {
std::io::SeekFrom::Start(_pos) => {
unimplemented!();
}
std::io::SeekFrom::End(pos) => {
std::io::SeekFrom::End(_pos) => {
unimplemented!();
}
std::io::SeekFrom::Current(pos) => {
Expand Down Expand Up @@ -103,7 +103,7 @@ impl DataSource {
let name: &Path = name.as_ref();
match self {
DataSource::LLaMASource(path, _) => {
let mut base = PathBuf::from(format!("consolidated.{:02}", shard));
let base = PathBuf::from(format!("consolidated.{:02}", shard));
let path = path.join(base).join(name);
let reader = std::fs::File::open(path)?;
Ok(DataSourceFile {
Expand All @@ -127,7 +127,7 @@ impl DataSource {
let archive_len = archive.len();
let mut idx: usize = archive_len;
for i in 0..archive_len {
let mut file = archive.by_index(i)?;
let file = archive.by_index(i)?;
let file = huggingface_loader::remove_first_directory(file.name());
if file == name {
idx = i;
Expand All @@ -146,7 +146,7 @@ impl DataSource {
zipfile: zipfile_name.clone(),
name: name.to_str().unwrap().to_string(),
archive,
reader_builder: move |mut archive| {
reader_builder: move |archive| {
archive.by_index(idx).unwrap()
},
}
Expand Down
4 changes: 2 additions & 2 deletions src/embedding.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use crate::data_source::DataSource;
use crate::tensor::{FromPiecesDirection, Tensor, TensorBuilder};
use crate::unpickler;

use crate::unpickler::*;
use std::collections::BTreeMap;
use std::path::Path;


pub struct Embedding {
wgts: BTreeMap<usize, Tensor>,
Expand Down
3 changes: 2 additions & 1 deletion src/huggingface_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ pub enum HugginfaceModelError {
UnpicklingError(#[from] unpickler::UnpicklingError),
}

#[allow(dead_code)]
pub struct HugginfaceModel {
pub(crate) unpickles: Vec<(unpickler::Value, PathBuf)>,
// (path, files, tensors)
Expand Down Expand Up @@ -66,7 +67,7 @@ impl HugginfaceModel {
// Read config,json
let config_json_path: PathBuf = path.join("config.json");
let config_json = std::fs::read_to_string(config_json_path)?;
let config: HugginfaceConfig = serde_json::from_str(&config_json)?;
let _config: HugginfaceConfig = serde_json::from_str(&config_json)?;

let index_json_path: PathBuf = path.join("pytorch_model.bin.index.json");
let index_json = std::fs::read_to_string(index_json_path)?;
Expand Down
20 changes: 13 additions & 7 deletions src/rllama_main.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
use crate::data_source::DataSource;
use crate::embedding::Embedding;
use crate::model_params::ModelParams;
use crate::semaphore::Semaphore;

#[cfg(feature = "opencl")]
use crate::tensor_opencl_support::OpenCL;
use crate::token_sampler::TokenSampler;
use crate::tokenizer::{TokenId, Tokenizer};
use crate::transformer::{DataSettings, Transformer, TransformerCaches};
use crate::unpickler;
use crate::unpickler::Value;
use crate::transformer::{DataSettings, Transformer};

#[cfg(feature = "server")]
use crate::semaphore::Semaphore;
#[cfg(feature = "server")]
use crate::transformer::TransformerCaches;
use clap::Parser;
use colored::Colorize;
#[cfg(feature = "server")]
use rocket::{response::status, response::Stream, Data, State};
use serde::{Deserialize, Serialize};
#[cfg(feature = "server")]
use std::collections::BTreeMap;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::{Arc, RwLock};
use std::sync::Arc;
#[cfg(feature = "server")]
use std::sync::RwLock;

// Refer to README.md to see what all these options mean.
#[derive(Parser, Clone)]
Expand Down Expand Up @@ -334,6 +339,7 @@ fn server_inference(
panic!("Starting web server failed.");
}

#[cfg(feature = "server")]
fn is_false(b: &bool) -> bool {
!b
}
Expand Down Expand Up @@ -763,7 +769,7 @@ fn command_line_inference(
let _ = user_token.remove(0);
interactive = false;
}
let (mut highest_pred_idx, mut token_prob);
let (highest_pred_idx, token_prob);

if user_token.len() > 0 {
highest_pred_idx = user_token.remove(0);
Expand Down
8 changes: 4 additions & 4 deletions src/tensor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ use crate::data_source::DataSource;
use crate::simd_support::*;
#[cfg(feature = "opencl")]
use crate::tensor_opencl_support::{OpenCL, OpenCLError, OpenCLEvent, OpenCLTensor};
use crate::unpickler;

use crate::unpickler::UnpicklingError;
use half::f16;
use lazy_static::lazy_static;
use rand::Rng;
use rayon::prelude::*;
use std::alloc::Layout;
use std::io::{Read, Seek};
use std::path::{Path, PathBuf};
use std::path::{PathBuf};
#[cfg(feature = "opencl")]
use std::sync::{Arc, RwLock};
use thiserror::Error;
Expand Down Expand Up @@ -879,7 +879,7 @@ impl Tensor {

fn offset_to_cursors(
offset: usize,
d1: usize,
_d1: usize,
d2: usize,
d3: usize,
d4: usize,
Expand Down Expand Up @@ -2388,7 +2388,7 @@ impl TensorBuilder {
data_source: DataSource,
direction: FromPiecesDirection,
) -> Result<Tensor, TensorError> {
let name = name.as_ref();
let _name = name.as_ref();
if builders.is_empty() {
return Err(TensorError::TensorBuilderEmpty);
}
Expand Down
4 changes: 2 additions & 2 deletions src/transformer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::tensor::{FromPiecesDirection, Tensor, TensorDType};
#[cfg(feature = "opencl")]
use crate::tensor_opencl_support::OpenCL;
use crate::tokenizer::TokenId;
use crate::unpickler;

use crate::unpickler::UnpicklingError;
use indicatif::ProgressBar;
use num_complex::Complex;
use rayon::prelude::*;
use std::path::Path;

use std::sync::{Arc, RwLock};

type FreqsCis = Vec<Vec<Complex<f64>>>;
Expand Down
7 changes: 2 additions & 5 deletions src/weight_compression.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
use crate::tensor::Tensor;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, RwLock};
use rand::thread_rng;

pub fn quantize(tensor: &Tensor) -> Tensor {
/*
Expand Down Expand Up @@ -31,7 +28,7 @@ pub fn quantize(tensor: &Tensor) -> Tensor {
}
values.sort_unstable_by(|a, b| a.partial_cmp(b).unwrap());
let mut allowed_values: Vec<f32> = Vec::with_capacity(16);
let mut rng = thread_rng();
let _rng = thread_rng();
for i in 0..16 {
let start_idx = i * values.len() / 16;
let end_idx = (i + 1) * values.len() / 16;
Expand Down

0 comments on commit 88cb876

Please sign in to comment.