Repository navigation
Commit 027d887
committed
fix!: retire the CLI flags llama.cpp's server parser rejects, and guard the contract
`LlamaModel.loadModel(parameters.toArray())` hands the ModelParameters map to
`common_params_parse(..., LLAMA_EXAMPLE_SERVER)` as argv, where an unregistered
option is a hard error rather than a warning. Seven flags the Java layer emitted
are no longer registered, so every caller of the matching builder method got
"Failed to parse model parameters" instead of a loaded model.
Two of them are fresh: b10878 deleted `--mlock` and `--no-mmap` (deprecated at
b10092 -- the whole deprecation window opened and closed inside eight tags).
Those have a faithful replacement, so nothing is lost: a new `args.LoadMode`
enum + `ModelParameters.setLoadMode(LoadMode)` expose upstream's `-lm`/
`--load-mode`, and `enableMlock()`/`disableMmap()` keep working, re-pointed to
`LoadMode.MLOCK` / `LoadMode.NONE` -- the exact mapping upstream's own
deprecation shim used. Both are now `@Deprecated`.
Five were already dead: `--dump-kv-cache`, `--hf-repo-v` and `--hf-file-v` are
gone from llama.cpp entirely; `--grp-attn-n` and `--grp-attn-w` are still in
`arg.cpp` but `set_examples()`-scoped to LLAMA_EXAMPLE_COMPLETION/PASSKEY, so
the server parser rejects them exactly like a deleted flag. Their setters are
now `@Deprecated` no-ops that write nothing, keeping call sites compiling *and*
loading. `ModelFlag.MLOCK`/`NO_MMAP`/`DUMP_KV_CACHE` are removed from the enum
so the broken argv is not reachable through `setFlag` either -- the same
reasoning that already excluded `FLASH_ATTN`.
No Java test could catch any of this: `ModelFlagTest` and
`ModelParametersExtendedTest` assert the string mapping (`hasKey("--mlock")`),
never that llama.cpp still accepts the string, so they stayed green while the
flags were dead. The guard closes that:
- `cmake/extract-java-cli-flags.cmake` extracts every `"--flag"` literal
`ModelFlag.java`/`ModelParameters.java` can emit into a generated header at
configure time, so the Java sources stay the single source of truth.
- `src/test/cpp/test_model_flags.cpp` asserts each one is registered in the
real `common_params_parser_init(params, LLAMA_EXAMPLE_SERVER).options`,
exempting only `--vocab-only` (a project pseudo-flag `strip_flag_from_argv`
removes before the parse). It also checks the oracle and the exemption list
themselves, so an empty option table or a stale exemption cannot make it
pass vacuously.
A grep over `arg.cpp` would not have worked -- it is structurally blind to
example scoping, which is exactly where `--grp-attn-n`/`-w` hid. Run against the
pre-fix sources the test named all seven; after the fix it is green.
Verified locally: ctest 531/531 (was 527), `mvn test` 1759 tests green,
PIT 320/320 killed with 0 NO_COVERAGE, spotbugs clean (`setLoadMode` added to
the design-intent OCP suppression list), spotless, clang-format and
`javadoc:jar` all clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AnNYn8W1xuVxVJtyL34GyH1 parent 3eff05d commit 027d887
13 files changed
Lines changed: 634 additions & 68 deletions
File tree
- docs/history
- llama
- cmake
- src
- main/java/net/ladenthin/llama
- args
- parameters
- test
- cpp
- java/net/ladenthin/llama
- args
- parameters
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1460 | 1460 | | |
1461 | 1461 | | |
1462 | 1462 | | |
| 1463 | + | |
1463 | 1464 | | |
1464 | | - | |
| 1465 | + | |
1465 | 1466 | | |
1466 | 1467 | | |
1467 | 1468 | | |
| |||
1722 | 1723 | | |
1723 | 1724 | | |
1724 | 1725 | | |
1725 | | - | |
| 1726 | + | |
1726 | 1727 | | |
1727 | 1728 | | |
1728 | 1729 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
372 | 373 | | |
373 | 374 | | |
374 | 375 | | |
| |||
0 commit comments