use anyhow::{Context, Result};
use mlx_native::gguf::GgufFile;
use crate::serve::gpu::GpuContext;
use crate::serve::header::LoadProgress;
use super::{Qwen3VlTextConfig, Qwen3VlTextWeights};
pub struct Qwen3VlTextModel {
pub cfg: Qwen3VlTextConfig,
pub weights: Qwen3VlTextWeights,
pub ctx: GpuContext,
}
impl Qwen3VlTextModel {
pub fn load_from_gguf(gguf: &GgufFile, progress: &mut LoadProgress) -> Result<Self> {
let cfg = Qwen3VlTextConfig::from_gguf(gguf).context("Qwen3VlTextConfig::from_gguf")?;
let ctx = GpuContext::new().map_err(|e| anyhow::anyhow!("mlx-native init failed: {e}"))?;
let weights = Qwen3VlTextWeights::load_from_gguf(gguf, &cfg, ctx.device(), progress)
.context("Qwen3VlTextWeights::load_from_gguf")?;
Ok(Self { cfg, weights, ctx })
}
pub fn load_config_only(gguf: &GgufFile) -> Result<Qwen3VlTextConfig> {
Qwen3VlTextConfig::from_gguf(gguf)
}
}