Repository navigation
bench: llama-bench accepts -fcd, the flag it already advertises - #201
Conversation
`-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
left a comment
There was a problem hiding this comment.
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>".
Root cause
-fcd/--fused-cross-deviceis registered incommon/arg.cppwith.set_examples({LLAMA_EXAMPLE_CLI, LLAMA_EXAMPLE_SERVER, LLAMA_EXAMPLE_BENCH, LLAMA_EXAMPLE_PERPLEXITY}),but
llama-benchdoes not go through that table:parse_cmd_params()is a closed whitelist andanything it does not know is
invalid_param = true.So the flag is advertised as a bench option and is rejected by the bench tool — and
llama-benchis exactlythe 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.cpponly, +24/-2, carrying the flag the way the neighbouring placement flagsare carried:
cmd_params::fused_cross_devicewith the library's own default (off), and the-fcd/--fused-cross-device/
-no-fcd/--no-fused-cross-deviceswitch pair in the whitelist;cmd_params_instance::fused_cross_device, set in all three instance builders, applied ascparams.fused_cross_deviceinto_llama_cparams();fused_cross_deviceresults column that is emitted only when it is not the default (same rule asno_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)error: invalid parameter for argument: -fcd(and the run is a usage error,exit 1)pp64 7497.98 t/s,tg8 361.93 t/s, header carriesfused_cross_device 1-no-fcdand the default (flag omitted) parse and produce the column-free output as before.Not covered
params.n_batch-style sweeps overfcdwere not added,because the two values differ by a placement decision rather than by a work amount.
-ngl 37 -fcdon 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).