Skip to content

bench: llama-bench accepts -fcd, the flag it already advertises - #201

Merged
bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/bench-fcd
Nov 4, 2026
Merged

bong-water-water-bong merged 1 commit into
1bit/hrx-vulkan-patchedfrom
1bit/bench-fcd

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Root cause

-fcd/--fused-cross-device is registered in common/arg.cpp with
.set_examples({LLAMA_EXAMPLE_CLI, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_BENCH, LLAMA_EXAMPLE_PERPLEXITY}),
but llama-bench does not go through that table: parse_cmd_params() is a closed whitelist and
anything it does not know is invalid_param = true.

$ ./llama-bench -m model.gguf -fcd -p 512 -n 32
error: invalid parameter for argument: -fcd

So the flag is advertised as a bench option and is rejected by the bench tool — and llama-bench is exactly
the tool needed to measure what #194 changes (the placement of a fused op when its layer stays on the CPU at
partial offload). No workaround exists: the alternative is llama-cli timings, which are not the pp512/tg32
protocol the placement work is measured with.

Change

tools/llama-bench/llama-bench.cpp only, +24/-2, carrying the flag the way the neighbouring placement flags
are carried:

  • cmd_params::fused_cross_device with the library's own default (off), and the -fcd/--fused-cross-device
    / -no-fcd/--no-fused-cross-device switch pair in the whitelist;
  • cmd_params_instance::fused_cross_device, set in all three instance builders, applied as
    cparams.fused_cross_device in to_llama_cparams();
  • a fused_cross_device results column that is emitted only when it is not the default (same rule as
    no_host/no_op_offload), so existing CSV/JSON consumers see no schema change.

Flag semantics are unchanged (default false), so nothing that works today changes behaviour.

Measured (gfx1151, HRX0, Qwen3-0.6B-Q4_K_M, -ngl 99 -p 64 -n 8 -r 1)

result
before error: invalid parameter for argument: -fcd (and the run is a usage error, exit 1)
after pp64 7497.98 t/s, tg8 361.93 t/s, header carries fused_cross_device 1

-no-fcd and the default (flag omitted) parse and produce the column-free output as before.

Not covered

  • The flag is a single setting, not a swept axis: params.n_batch-style sweeps over fcd were not added,
    because the two values differ by a placement decision rather than by a work amount.
  • No V4.1 number is claimed here; the V4.1 arm this unblocks is -ngl 37 -fcd on DeepSeek-V4.1-Flash UD-IQ1_S,
    which needs ~110 GiB of MemAvailable and therefore its own box window (recorded in the lane's state file).

`-fcd/--fused-cross-device` (#194) is declared with `set_examples({..., LLAMA_EXAMPLE_BENCH, ...})`
in common/arg.cpp, but llama-bench parses its own closed argument set and rejects anything not in
its whitelist, so the flag is unreachable from the one tool that measures the placement it changes:

    $ llama-bench -m model.gguf -fcd -p 512 -n 32
    error: invalid parameter for argument: -fcd

That leaves the tool unable to reproduce the configuration #194 exists for (partial offload, where
the fused op's layer stays on the CPU). Carry the flag the way the neighbouring placement flags are
carried: a `cmd_params` field with the same default the library uses (off), the pair of switches, the
instance field, `cparams.fused_cross_device` in `to_llama_cparams()`, and a results column that only
appears when it is not the default.

Verified on gfx1151 (HRX0), Qwen3-0.6B-Q4_K_M, -ngl 99 -p 64 -n 8:
  before: "error: invalid parameter for argument: -fcd"
  after : pp64 7497.98 t/s, tg8 361.93 t/s, "fused_cross_device | 1" in the header

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

VERDICT: READY at 2f55ad863

Built and run, both arms.

$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build --target llama-bench -j4
  -> rc=0, bin/llama-bench, build 2f55ad863 (10734)

Flag present, column appears only when it is not the default:

$ ./bin/llama-bench -m Qwen3-0.6B-Q4_K_M.gguf -ngl 0 -fcd -p 8 -n 4 -r 1
| model | size | params | backend | threads | fused_cross_device | test | t/s |
  pp32 495.33 t/s, tg8 29.66 t/s (CPU, -ngl 0 — no device touched)

$ ./bin/llama-bench ... (flag omitted)      -> | ... | threads | test | t/s |          (no column)
$ ./bin/llama-bench ... -no-fcd ...         -> parses, no column

So the "before" is a parser refusal rather than a missing column: parse_cmd_params() is a closed whitelist that ends in invalid_param = true, which is why -fcd was rejected even though common/arg.cpp registers it for LLAMA_EXAMPLE_BENCH. That is now wired in all five places that matter and I checked each: cmd_params, cmd_params_instance (all three builders), to_llama_cparams() (cparams.fused_cross_device), test::fused_cross_device + the get_field_type/get_values pair (column name and value in the same position — I counted them against the neighbouring no_host/fit_target entries), and the markdown printer's "only when non-default" rule.

Semantics unchanged: the struct default is false and llama_context_params.fused_cross_device already defaults to false in llama-context.cpp:3548, so omitting the flag is byte-for-byte the old behaviour.

One nit: -fcd is not a swept axis, which you state; the usage text also does not say it is a single setting, so -fcd 0,1 will silently be an "invalid parameter for argument: 0,1". Either accept the <0|1> form like --no-host/-nopo, or add "(single setting: on/off)" where the neighbours say "<0|1>".

@bong-water-water-bong bong-water-water-bong added the tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied label Nov 4, 2026
@bong-water-water-bong
bong-water-water-bong merged commit 16a9bc8 into 1bit/hrx-vulkan-patched Nov 4, 2026
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/bench-fcd branch November 12, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tprs-ready TPRS: review verdict READY posted by the standing reviewer; merge gate satisfied

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant