Skip to content

build: add armv{6,7,8} support to cmake - #1251

Merged
prusnak merged 1 commit into
masterfrom
cmake-arm
Apr 30, 2023
Merged

prusnak merged 1 commit into
masterfrom
cmake-arm

Conversation

@prusnak

@prusnak prusnak commented Apr 30, 2023

Copy link
Copy Markdown
Contributor

flags copied from Makefile

fixes #1210

@prusnak

prusnak commented Apr 30, 2023

Copy link
Copy Markdown
Contributor Author

@jtang613 could you please test this PR if it fixes the issue for you using cmake?

@jtang613

Copy link
Copy Markdown

@prusnak This PR compiles successfully with cmake on raspian. Nice work.

@jtang613 jtang613 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Compiles successfully on raspian bullseye on Rpi 3B.

- flags copied from Makefile
- updated comments in both CMakeLists.txt and Makefile
  to match reality
@prusnak
prusnak merged commit 6f79699 into master Apr 30, 2023
@prusnak
prusnak deleted the cmake-arm branch April 30, 2023 18:48
Seunghhon pushed a commit to Seunghhon/llama.cpp that referenced this pull request Apr 26, 2026
- flags copied from Makefile
- updated comments in both CMakeLists.txt and Makefile to match reality
phuongncn pushed a commit to phuongncn/llama.cpp-gx10-dgx-sparks-deepseekv4 that referenced this pull request Apr 28, 2026
- flags copied from Makefile
- updated comments in both CMakeLists.txt and Makefile to match reality
ljubomirj pushed a commit to ljubomirj/llama.cpp that referenced this pull request May 6, 2026
- flags copied from Makefile
- updated comments in both CMakeLists.txt and Makefile to match reality
AlexiAlp pushed a commit to minghaop/llama.cpp that referenced this pull request Jun 2, 2026
- flags copied from Makefile
- updated comments in both CMakeLists.txt and Makefile to match reality
bong-water-water-bong added a commit to 1bit-MONSTER/llama.cpp that referenced this pull request Nov 7, 2026
…ublished before the graph returns

Three defects in one path, all measured on the Qwen3.8-Flash-Next (arch qwen4exp) sparse-attention
graph, where a device SET_ROWS unmasks the top-k cells of an f16 KQ mask:

1. `hip.set_rows` declared its destination binding pure `Write`. SET_ROWS is a read-modify-write
   (ggml-cpu's ggml_compute_forward_set_rows_impl leaves every row the indices do not name alone), and
   the declared access decides the host staging round trip in runtime/command-program-executor.cpp:
   with `write` only, the executor uploads nothing and downloads the whole slice afterwards, so a
   host-placed destination gets overwritten outside the named rows with the contents of a fresh staging
   buffer. Declared `read_write`, matching the Loom matchers (loom-libs manifest: read,read,read_write).

2. A staged download is only a queued memcpy until GraphReplayStreamState::mark_stream_synchronized()
   runs on a later backend synchronize. ggml's scheduler shares a *host* tensor between the HRX split
   and a CPU split without inserting a copy -- it is the same memory, so there is nothing to copy -- so
   a CPU node in the next split can read it before anything synchronizes HRX. GraphExecutor::execute
   now publishes pending host writebacks before it returns, i.e. the materialised host output is copied
   back after the dispatch that wrote it.

3. `kSetRowsMaxSlices` was 64, a dispatch-count bound (one dispatch per dim-2/3 slice) that only covered
   ubatches up to 64 tokens. The QSA mask is [1, n_kv, n_ubatch], so every larger prefill lost the claim
   and ran the node on the CPU backend. Raised to 8192 = 4x the default -b/-ub 2048 with the stream
   factor.

Measured (Qwen3.8-Flash-Next UD-IQ3_XXS, HRX0, -fa on, 160-token prompt, same llama-cli, library swapped
by LD_LIBRARY_PATH, md5 printed per arm):

| arm | before | after |
|---|---|---|
| sparse graph (LLAMA_QSA_DENSE=0), -ub 32 (claimed today) | all-NaN logits, 248320/248320 | completes, sane text |
| sparse graph, -ub 512 (was declined above 64 slices) | CPU fallback -> GGML_ASSERT(i1 >= 0 && i1 < ne1) at ggml-cpu/ops.cpp:5136 | completes |
| dense (reference) | completes | completes |

test-backend-ops: 63/63 SET_ROWS cases pass on HRX0, including four new rows that were previously
unsupported or quadratic in the model's shape (128-slice batches, and f32 rows -> f16 cache with i32
indices at 256 tokens / 32 slices).

Fixes ggml-org#1251
bong-water-water-bong added a commit to 1bit-MONSTER/llama.cpp that referenced this pull request Nov 7, 2026
…ublished before the graph returns (#227)

Three defects in one path, all measured on the Qwen3.8-Flash-Next (arch qwen4exp) sparse-attention
graph, where a device SET_ROWS unmasks the top-k cells of an f16 KQ mask:

1. `hip.set_rows` declared its destination binding pure `Write`. SET_ROWS is a read-modify-write
   (ggml-cpu's ggml_compute_forward_set_rows_impl leaves every row the indices do not name alone), and
   the declared access decides the host staging round trip in runtime/command-program-executor.cpp:
   with `write` only, the executor uploads nothing and downloads the whole slice afterwards, so a
   host-placed destination gets overwritten outside the named rows with the contents of a fresh staging
   buffer. Declared `read_write`, matching the Loom matchers (loom-libs manifest: read,read,read_write).

2. A staged download is only a queued memcpy until GraphReplayStreamState::mark_stream_synchronized()
   runs on a later backend synchronize. ggml's scheduler shares a *host* tensor between the HRX split
   and a CPU split without inserting a copy -- it is the same memory, so there is nothing to copy -- so
   a CPU node in the next split can read it before anything synchronizes HRX. GraphExecutor::execute
   now publishes pending host writebacks before it returns, i.e. the materialised host output is copied
   back after the dispatch that wrote it.

3. `kSetRowsMaxSlices` was 64, a dispatch-count bound (one dispatch per dim-2/3 slice) that only covered
   ubatches up to 64 tokens. The QSA mask is [1, n_kv, n_ubatch], so every larger prefill lost the claim
   and ran the node on the CPU backend. Raised to 8192 = 4x the default -b/-ub 2048 with the stream
   factor.

Measured (Qwen3.8-Flash-Next UD-IQ3_XXS, HRX0, -fa on, 160-token prompt, same llama-cli, library swapped
by LD_LIBRARY_PATH, md5 printed per arm):

| arm | before | after |
|---|---|---|
| sparse graph (LLAMA_QSA_DENSE=0), -ub 32 (claimed today) | all-NaN logits, 248320/248320 | completes, sane text |
| sparse graph, -ub 512 (was declined above 64 slices) | CPU fallback -> GGML_ASSERT(i1 >= 0 && i1 < ne1) at ggml-cpu/ops.cpp:5136 | completes |
| dense (reference) | completes | completes |

test-backend-ops: 63/63 SET_ROWS cases pass on HRX0, including four new rows that were previously
unsupported or quadratic in the model's shape (128-slice batches, and f32 rows -> f16 cache with i32
indices at 256 tokens / 32 slices).

Fixes ggml-org#1251

Co-authored-by: pi-hrx-compat <[email protected]>
bong-water-water-bong added a commit to 1bit-MONSTER/llama.cpp that referenced this pull request Nov 8, 2026
…-> mask scatter chain (#241)

`test-backend-ops` covered a large `k` only with `rows <= 2` (`{(1<<i),1,1,1}` and `{(1<<i)+11,1,2,1}`,
k up to 9999) and a large row count only with `k <= 32` (`{202048,{1,8,16},1,1}`, k in {4,8,16,32}; the
DFlash rows are k in {7,16}). The Qwen4-exp QSA indexer needs both at once — `indexer_top_k + r - 1` (2051)
cells selected per token out of the indexer's compressed cell space, one row per ubatch token — so no
known-answer case exercised the geometry the model actually runs (engine ggml-org#1346).

This adds:

- four `TOP_K` rows at the model's geometry: `{2560,64}`, `{2560,512}`, `{11520,64}`, `{11520,512}`, all at
  `k = 2051` (484 -> 488 cases);
- `test_top_k_set_rows`, the composite chain the model builds: scores -> `ggml_top_k` index list -> `ggml_set_rows`
  scatter into an f16 mask with f32 zero rows. No single-op case covers that handoff, and it is where the model
  failed. `run_whole_graph()` is required because TOP_K's index order is unspecified, so the intermediate
  tensors cannot be compared positionally; the scatter's result is a set operation, so the final mask is the
  order-independent check. The mask and the scattered rows are params rather than fills (FILL has no HRX claim,
  so a fill-backed mask makes the whole node set unplaceable — the structural fact engine ggml-org#1251 documented for
  the model's own mask), and the rows are constant because random rows would be permuted by index order.

Measured: builds clean, and on HRX0 the suite is green in most runs. It is **not** green in every run, and that
is the point of the gate — while writing it I found that `-b HRX0 -o TOP_K` intermittently reports wrong index
sets: 4/10 and 5/10 failing runs in two windows, including pre-existing rows such as `{1023,2,1,3},k=7`, against
0/10 and 0/20 in later windows. So a single green `-o TOP_K` here is a sample, not proof. The flake and the fix
are tracked in engine ggml-org#1346; this PR is the coverage that makes it observable.

Refs ggml-org#1346

Co-authored-by: pi-hrx-compat <[email protected]>
bong-water-water-bong pushed a commit to 1bit-MONSTER/llama.cpp that referenced this pull request Nov 13, 2026
… the device

Without them every op failed on the device at 2c178f4 (test-backend-ops -b HRX0: MUL_MAT 0/1717, ROPE 0/127; test-hrx-ops 2/177),
with 'command 0 kind=Kernel binding value=N ... is not bound' on plain native bindings. These are the files gated on
the device at e636e03 (MUL_MAT 1717/1717, MUL_MAT_ID 925/925, ROPE/FA/GET_ROWS all, shortlist 6/6, tok/s within ~1%):
- runtime: command-program-executor (our residency path and per-value layout access, AMD's main_write and demand
  API), graph-executor (AMD's shared prepared entry with our ggml-org#1251 publish, graph_input, pool budget), graph-program-
  cache, prepared-command-program-cache (ggml-org#841 bytes), host-memory (+ the device-source weight path); a resident
  binding records its layout (AMD's find matches value + layout + transformation)
- backend-buffer-binding: a packed layout is eligible exactly for a weights buffer
- dispatch: dispatch-mul-mat and dispatch-registry (ours + AMD's eligibility), rope (our kernel), moe-router
- corpus manifests: closure over func.decl -> func.def, redundant entries dropped, bindings matched to the merged
  launch(), qwen3_moe attention postprocess on AMD's side throughout
- src/models/zaya.cpp: hs_d expanded before the attention norm (hip.zaya_qkv matches again)
- tests: test-backend-ops (HRX in backend_lacks_skipped_ids), hrx-backend-test (ggml-org#841 counters from the shared cache)
The fork tip's ggml-org#2137 additions to host-memory.cpp are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cmake: Raspberry Pi 3 (raspian) compile fails

3 participants