add qwen3vl 4b, 8b, 32b
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ pub fn get_device(device: Option<&Device>) -> Device {
|
||||
None => {
|
||||
#[cfg(feature = "cuda")]
|
||||
{
|
||||
Device::new_cuda(0).unwrap_or(Device::Cpu)
|
||||
Device::new_cuda(6).unwrap_or(Device::Cpu)
|
||||
}
|
||||
#[cfg(not(feature = "cuda"))]
|
||||
{
|
||||
|
||||
@@ -8,10 +8,15 @@ pub fn prepare_causal_attention_mask(
|
||||
device: &Device,
|
||||
) -> Result<Tensor> {
|
||||
// Sliding window mask?
|
||||
let mask: Vec<_> = (0..tgt_len)
|
||||
.flat_map(|i| (0..tgt_len).map(move |j| if i < j { f32::NEG_INFINITY } else { 0. }))
|
||||
.collect();
|
||||
let mask = Tensor::from_slice(&mask, (tgt_len, tgt_len), device)?;
|
||||
// let mask: Vec<f32> = (0..tgt_len)
|
||||
// .flat_map(|i| (0..tgt_len).map(move |j| if i < j { f32::NEG_INFINITY } else { 0. }))
|
||||
// .collect();
|
||||
// let mask = Tensor::from_vec(mask, (tgt_len, tgt_len), device)?;
|
||||
let arange = Tensor::arange(0u32, tgt_len as u32, device)?;
|
||||
let arange = arange.unsqueeze(1)?.broadcast_as((tgt_len, tgt_len))?;
|
||||
let upper_triangle = arange.t()?.gt(&arange)?;
|
||||
let mask = upper_triangle.where_cond(&Tensor::new(f32::NEG_INFINITY, device)?.broadcast_as(arange.shape())?, &Tensor::new(0f32, device)?.broadcast_as(arange.shape())?)?;
|
||||
|
||||
let mask = if seqlen_offset > 0 {
|
||||
let mask0 = Tensor::zeros((tgt_len, seqlen_offset), DType::F32, device)?;
|
||||
Tensor::cat(&[&mask0, &mask], D::Minus1)?
|
||||
|
||||
Reference in New Issue
Block a user