model : add LiquidAI/LFM3-1.7B and LiquidAI/LFM3-VL-2B (#31252)
* model : add LiquidAI/LFM3-1.7B and LiquidAI/LFM3-VL-2B Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co> Co-authored-by: Xuan-Son Nguyen <son@huggingface.co> Assisted-by: Claude Opus 5.5 * tests : set the SWA rope base of the LFM3 test model Assisted-by: Claude Opus 5.5 * llama : enable recurrent state rollback for LFM3 Assisted-by: Claude Opus 5.5 * Apply batched suggestions from code review Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co> Co-authored-by: Tarek Dakhran <github@dakhran.com> * gguf-py : align the lfm3vl mapping comments Assisted-by: Claude Opus 5.5 * llama : fix CRLF line endings from the review suggestions Assisted-by: Claude Opus 5.5 * tests : add the LFM3 Metal fusion baseline Assisted-by: Claude Opus 5.5 * llama : keep the LFM3-VL depthwise conv kernels in F32 when quantizing Assisted-by: Claude Opus 5.5 --------- Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@huggingface.co> Co-authored-by: Xuan-Son Nguyen <son@huggingface.co>
This commit is contained in:
23 files changed
+1070
-5
No files matched your search
@@ -809,8 +809,7 @@ clip_image_size mtmd_image_preprocessor_dyn_size::get_target_size(const clip_hpa
|
||||
|
||||
mtmd_image_preproc_out mtmd_image_preprocessor_dyn_size::preprocess(const clip_image_u8 & img) const {
|
||||
clip_image_u8 resized_image;
|
||||
const clip_image_size target_size = get_target_size(hparams, img.get_size());
|
||||
img_tool::resize(img, resized_image, target_size,
|
||||
img_tool::resize(img, resized_image, target_size(img.get_size()),
|
||||
hparams.image_resize_algo,
|
||||
hparams.image_resize_pad,
|
||||
hparams.image_pad_color);
|
||||
@@ -819,6 +818,34 @@ mtmd_image_preproc_out mtmd_image_preprocessor_dyn_size::preprocess(const clip_i
|
||||
return output;
|
||||
}
|
||||
|
||||
//
|
||||
// mtmd_image_preprocessor_lfm3vl
|
||||
//
|
||||
|
||||
// rounds before the pixel checks (an edge may round to 0) and computes in double, as transformers does
|
||||
clip_image_size mtmd_image_preprocessor_lfm3vl::smart_resize(int width, int height, int factor, int64_t min_pixels, int64_t max_pixels) {
|
||||
const double h = height;
|
||||
const double w = width;
|
||||
int h_bar = static_cast<int>(std::nearbyint(h / factor)) * factor;
|
||||
int w_bar = static_cast<int>(std::nearbyint(w / factor)) * factor;
|
||||
if (static_cast<int64_t>(h_bar) * w_bar > max_pixels) {
|
||||
const double beta = std::sqrt(h * w / max_pixels);
|
||||
h_bar = static_cast<int>(std::floor(h / beta / factor)) * factor;
|
||||
w_bar = static_cast<int>(std::floor(w / beta / factor)) * factor;
|
||||
} else if (static_cast<int64_t>(h_bar) * w_bar < min_pixels) {
|
||||
const double beta = std::sqrt(min_pixels / (h * w));
|
||||
h_bar = static_cast<int>(std::ceil(h * beta / factor)) * factor;
|
||||
w_bar = static_cast<int>(std::ceil(w * beta / factor)) * factor;
|
||||
}
|
||||
|
||||
return {std::max(factor, w_bar), std::max(factor, h_bar)};
|
||||
}
|
||||
|
||||
clip_image_size mtmd_image_preprocessor_lfm3vl::target_size(const clip_image_size & original_size) const {
|
||||
return smart_resize(original_size.width, original_size.height, hparams.patch_size * hparams.n_merge,
|
||||
hparams.image_min_pixels, hparams.image_max_pixels);
|
||||
}
|
||||
|
||||
//
|
||||
// mtmd_image_preprocessor_glm5v
|
||||
//
|
||||
|
||||
Reference in new issue
Block a user