huggingface/candle · error
Mismatch between DeepStack visual embeds ({}) and mask posit
Error message
Mismatch between DeepStack visual embeds ({}) and mask positions ({}) What it means
Thrown when the number of DeepStack visual embeddings does not match the number of positions flagged in the attention mask for insertion.
Source
Thrown at candle-transformers/src/models/qwen3_vl/text.rs:367
let mask = visual_pos_masks.to_device(device)?.to_dtype(DType::F32)?;
let mask_flat = mask.flatten_all()?;
let masked_count = mask_flat.sum_all()?.to_scalar::<f32>()? as usize;
let visual_embeds = visual_embeds.to_device(device)?.to_dtype(dtype)?;
if masked_count == 0 {
if visual_embeds.dim(0)? != 0 {
candle::bail!(
"DeepStack visual embeds ({}) provided but mask is empty",
visual_embeds.dim(0)?
);
}
return Ok(hidden_states);
}
if visual_embeds.dim(0)? != masked_count {
candle::bail!(
"Mismatch between DeepStack visual embeds ({}) and mask positions ({})",
visual_embeds.dim(0)?,
masked_count
);
}
let (batch, seq, hidden) = hidden_states.dims3()?;
let total_positions = batch * seq;
let mut hidden_flat = hidden_states.reshape((total_positions, hidden))?;
let prefix = mask_flat.cumsum(0)?;
let rank = (prefix - &mask_flat)?.mul(&mask_flat)?;
let rank_u32 = rank.to_dtype(DType::U32)?;
let positions = Tensor::arange(0u32, total_positions as u32, device)?;
let positions_f32 = positions.to_dtype(DType::F32)?;
let masked_positions = positions_f32.mul(&mask_flat)?;
View on GitHub (pinned to d5fee525bf)
When it happens
Trigger: Thrown at candle-transformers/src/models/qwen3_vl/text.rs:367 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of huggingface/candle@d5fee525bf (2026-09-02).
Data as JSON: /api/errors/9ff16fb1465b14d2.
Report an issue: GitHub.