Skip to content

deepseek-ocr SAM ggml_conv_2d with the im2col kept in F32 - #26727

Open
sfallah wants to merge 1 commit into
ggml-org:masterfrom
sfallah:sf/dsocr-conv-f32
Open

deepseek-ocr SAM ggml_conv_2d with the im2col kept in F32#26727
sfallah wants to merge 1 commit into
ggml-org:masterfrom
sfallah:sf/dsocr-conv-f32

Conversation

@sfallah

@sfallah sfallah commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

Since #23660, ggml_conv_2d emits an F16 im2col for all non-F16 conv kernels. The SAM convs in DeepSeek-OCR run F32 weights, and the F16 im2col measurably degrades their OCR quality on CUDA. This PR keeps the im2col of these convs in F32, in the model code. On Metal the output is unchanged.

DeepSeek-OCR eval on CUDA (DGX Spark), single-view scan, this branch vs master:

branch model CER chrF
this PR v1 0.2955 66.72
this PR v2 0.7475 25.09
master v1 0.3249 63.14
master v2 0.8737 8.64

Requirements

  • I have read and agree with the contributing guidelines
  • AI usage disclosure: YES - I used AI assistance for code review, debugging, implementation checks, and testing. I have reviewed the submitted changes and take responsibility for the full contents of this PR.

@sfallah
sfallah requested a review from a team as a code owner August 7, 2026 14:41
@github-actions github-actions Bot added the mtmd Related to multimodal functionality (video/image/audio) label Aug 7, 2026
}

// ggml_conv_2d with the im2col kept in F32: the F16 im2col it emits since #23660 degrades OCR
static ggml_tensor * conv_2d_f32(ggml_context * ctx0, ggml_tensor * a, ggml_tensor * b,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we simply cast the kernel to F32 and run ggml_conv_2d, does it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mtmd Related to multimodal functionality (video/image/audio)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants