Skip to content

Conversation

danbev
Copy link
Member

@danbev danbev commented Sep 15, 2025

This commit introduces a CPU reference implementation for GGML,
designed primarily for testing and validation purposes.

The motivation for this addition is to have a pure C CPU backend
implementation that does not use any hardware-specific optimizations
or intrinsics. This will allow for testing the CPU backend variants
against the reference implementation to ensure correctness


Building

$ cmake -B build \
    -DGGML_CPU_REF_BACKEND=ON
    -DGGML_BACKEND_DL=ON \
    -DGGML_CPU_ALL_VARIANTS=ON

Listing variants

$ ./build/bin/test-backend-ops cpu-variants --list
CPU variants:
  CPU-alderlake   - 12th Gen Intel(R) Core(TM) i7-1260P

Testing a variant

$ ./build/bin/test-backend-ops cpu-variants --variant CPU-alderlake -o ADD
Testing CPU variant 'CPU-alderlake' against cpu-ref backend...

  ADD(type=f16,ne=[1,1,8,1],nr=[1,1,1,1],nf=1): OK
  ADD(type=f16,ne=[1,1,1,1],nr=[32,1,1,1],nf=1): OK
  ADD(type=f16,ne=[1,1,320,320],nr=[1,1,1,1],nf=1): OK
  ...
  14471/14471 tests passed

@slaren
Copy link
Member

slaren commented Sep 15, 2025

There is no need to duplicate the CPU backend to do this - that would be a maintenance nightmare. You can add variant that is built in similar way that all the other CPU backend variants when using GGML_CPU_ALL_VARIANTS, just with all the instruction sets disabled so that only the C implementation is used.

@github-actions github-actions bot added testing Everything test related ggml changes relating to the ggml tensor library for machine learning labels Sep 15, 2025
@danbev
Copy link
Member Author

danbev commented Sep 15, 2025

@slaren Ah right, that does sound much better and simpler than this. I'll make the changes. Thanks!

@danbev danbev force-pushed the test-backend-ops-all-cpu-variants branch from 6ec8679 to c9806e0 Compare September 15, 2025 10:14
This commit introduces a CPU reference implementation for GGML,
designed primarily for testing and validation purposes.

The motivation for this addition is to have a pure C CPU backend
implementation that does not use any hardware-specific optimizations
or intrinsics. This will allow for testing the CPU backend variants
against the reference implementation to ensure correctness
@danbev danbev force-pushed the test-backend-ops-all-cpu-variants branch from c9806e0 to a509662 Compare September 16, 2025 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ggml changes relating to the ggml tensor library for machine learning testing Everything test related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants