Files
Eric BuehlerandGitHub a562fd0707 Implement DeepSeekV2 (#1010)
* Initial steps toward supporting deepseekv2

* Implement the attention forward

* Add the mlp

* Implement the moe gate and forward

* Fixes

* Forward pass runs

* Clippy

* Update

* It works

* Use faster rope

* Use normal cache

* Add framework for paged attn

* Fixes

* Support isq

* Add moqe support, residual tensors

* Add examples, python API, docs

* Fix tests

* Update deps
2025-01-04 19:35:24 -05:00

35 lines
1006 B
Rust

use anyhow::Result;
use mistralrs::{
IsqType, PagedAttentionMetaBuilder, TextMessageRole, TextMessages, TextModelBuilder,
};
#[tokio::main]
async fn main() -> Result<()> {
let model = TextModelBuilder::new("deepseek-ai/DeepSeek-V2-Lite")
.with_isq(IsqType::Q4K)
.with_logging()
.with_paged_attn(|| PagedAttentionMetaBuilder::default().build())?
.build()
.await?;
let messages = TextMessages::new()
.add_message(
TextMessageRole::System,
"You are an AI agent with a specialty in programming.",
)
.add_message(
TextMessageRole::User,
"Hello! How are you? Please write generic binary search function in Rust.",
);
let response = model.send_chat_request(messages).await?;
println!("{}", response.choices[0].message.content.as_ref().unwrap());
dbg!(
response.usage.avg_prompt_tok_per_sec,
response.usage.avg_compl_tok_per_sec
);
Ok(())
}