Skip to content

Commit 9cced37

Browse files
committed
Remove Setting.
1 parent aa876ce commit 9cced37

File tree

4 files changed

+13
-32
lines changed

4 files changed

+13
-32
lines changed

assets/configs/Config.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ max_runtime_batch = 8 # The maximum ba
99
max_batch = 16 # The maximum batches that are cached on GPU.
1010
embed_layer = 2 # The (reversed) layer number whose output is used as embedding.
1111
embed_device = "Cpu" # Device to put the embed tensor ("Cpu" or "Gpu").
12+
stop = ["\n\n"] # Additional stop words in generation.
1213

1314
[tokenizer]
1415
path = "assets/tokenizer/rwkv_vocab_v20230424.json" # Path to the tokenizer.
1516

1617
[adapter]
1718
Auto = {}
18-
19-
[setting]
20-
stop = ["\n\n"] # Additional stop words in generation.

src/config.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ pub struct Config {
1212
pub lora: Vec<Lora>,
1313
pub tokenizer: Tokenizer,
1414
pub adapter: AdapterOption,
15-
pub setting: Setting,
1615
}
1716

1817
impl From<Config> for ReloadRequest {
@@ -129,10 +128,3 @@ pub enum AdapterOption {
129128
Economical,
130129
Manual(usize),
131130
}
132-
133-
/// More inference configurations.
134-
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
135-
pub struct Setting {
136-
/// Additional stop words.
137-
pub stop: Vec<String>,
138-
}

src/main.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use axum::{
1414
Router,
1515
};
1616
use clap::Parser;
17-
use config::{AdapterOption, Config, Setting};
17+
use config::{AdapterOption, Config};
1818
use flume::{Receiver, Sender};
1919
use itertools::Itertools;
2020
use memmap2::Mmap;
@@ -324,14 +324,14 @@ fn load_config(path: impl AsRef<Path>) -> Result<Config> {
324324
}
325325

326326
#[tokio::main]
327-
async fn model_route(receiver: Receiver<ThreadRequest>, setting: Setting) -> Result<()> {
327+
async fn model_route(receiver: Receiver<ThreadRequest>) -> Result<()> {
328328
let env: Arc<RwLock<Environment>> = Default::default();
329329
let queue: Arc<Mutex<Vec<GenerateContext>>> = Default::default();
330330

331331
let sender = {
332332
let (sender, receiver) = flume::unbounded();
333333
let env = env.clone();
334-
tokio::task::spawn_blocking(move || run::run(receiver, env, setting));
334+
tokio::task::spawn_blocking(move || run::run(receiver, env));
335335
sender
336336
};
337337

@@ -575,20 +575,16 @@ async fn main() {
575575
let args = Args::parse();
576576
let (sender, receiver) = flume::unbounded::<ThreadRequest>();
577577

578-
let (setting, request) = {
578+
let request = {
579579
let path = args
580580
.config
581581
.clone()
582582
.unwrap_or("assets/configs/Config.toml".into());
583583
log::info!("reading config {}...", path.to_string_lossy());
584-
let config = load_config(path).expect("load config failed");
585-
586-
let setting = config.setting.clone();
587-
let request = config.into();
588-
(setting, request)
584+
load_config(path).expect("load config failed").into()
589585
};
590586

591-
tokio::task::spawn_blocking(move || model_route(receiver, setting));
587+
tokio::task::spawn_blocking(move || model_route(receiver));
592588
let _ = sender.send(ThreadRequest::Reload {
593589
request,
594590
sender: None,

src/run.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ use web_rwkv::{
2323
tokenizer::Tokenizer,
2424
};
2525

26-
use crate::{
27-
config::Setting, Environment, FinishReason, GenerateRequest, Token, TokenCounter,
28-
STATE_CHUNK_SIZE,
29-
};
26+
use crate::{Environment, FinishReason, GenerateRequest, Token, TokenCounter, STATE_CHUNK_SIZE};
3027

3128
const PENALTY_FREE_LIST: [&str; 5] = ["\n", ",", ".", "\u{002c}", "\u{002f}"];
3229

@@ -343,7 +340,6 @@ where
343340
let context = self.model.context();
344341
let info = self.model.info();
345342
StateBuilder::new(context, info)
346-
.with_num_batch(1)
347343
.with_chunk_size(STATE_CHUNK_SIZE)
348344
.build_backed()
349345
});
@@ -430,7 +426,7 @@ where
430426
}
431427
}
432428

433-
pub async fn process(&self, payloads: &mut [Payload], setting: &Setting) -> Result<()> {
429+
pub async fn process(&self, payloads: &mut [Payload]) -> Result<()> {
434430
{
435431
let mut slots = self.slots.lock().await;
436432
let mut cache = self.backed.lock().await;
@@ -636,7 +632,6 @@ where
636632
.request
637633
.stop
638634
.iter()
639-
.chain(setting.stop.iter())
640635
.map(|stop| {
641636
let stop = stop.as_bytes();
642637
let mut ptr_safe = 0;
@@ -729,9 +724,9 @@ macro_rules! impl_runtime_untyped {
729724
}
730725

731726
#[inline]
732-
pub async fn process(&self, payloads: &mut [Payload], setting: &Setting) -> Result<()> {
727+
pub async fn process(&self, payloads: &mut [Payload]) -> Result<()> {
733728
match self {
734-
$(RuntimeUntyped::$variant(runtime) => runtime.process(payloads, setting).await,)*
729+
$(RuntimeUntyped::$variant(runtime) => runtime.process(payloads).await,)*
735730
}
736731
}
737732
}
@@ -741,12 +736,12 @@ macro_rules! impl_runtime_untyped {
741736
impl_runtime_untyped!(V4, V5, V6);
742737

743738
#[tokio::main]
744-
pub async fn run(receiver: Receiver<()>, env: Arc<RwLock<Environment<'_>>>, setting: Setting) {
739+
pub async fn run(receiver: Receiver<()>, env: Arc<RwLock<Environment<'_>>>) {
745740
while let Ok(()) = receiver.recv_async().await {
746741
if let Environment::Loaded { runtime, .. } = &*env.read().await {
747742
let mut payloads = vec![Payload::default(); runtime.num_batch()];
748743
'run: loop {
749-
if let Err(err) = runtime.process(&mut payloads, &setting).await {
744+
if let Err(err) = runtime.process(&mut payloads).await {
750745
log::error!("{}", err);
751746
break 'run;
752747
}

0 commit comments

Comments
 (0)