Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ hs_err_pid*
replay_pid*

models/*.gguf
src/main/cpp/de_kherud_llama_*.h
src/main/cpp/net_ladenthin_llama_*.h
src/main/resources_cuda_linux/
src/main/resources/**/*.so
src/main/resources/**/*.dylib
Expand Down
8 changes: 7 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

Java bindings for [llama.cpp](https://github.com/ggerganov/llama.cpp) via JNI, providing a high-level API for LLM inference in Java. The Java layer communicates with a native C++ library through JNI.

Current llama.cpp pinned version: **b9106**
Current llama.cpp pinned version: **b9134**

## Upgrading CUDA Version

Expand Down Expand Up @@ -253,6 +253,12 @@ Also review the project `CMakeLists.txt` for build-system-level breaks (e.g. ren
| ~b9103–b9106 | `ggml/src/ggml-vulkan/ggml-vulkan.cpp` + Vulkan shaders | Vulkan flash attention refactored: `pipeline_flash_attn_f32_f16` changed from a per-type array of maps to a single map; mixed K/V quant types (e.g. Q4_0 K + F16 V) now supported on all Vulkan FA paths (scalar, cm1, cm2) rather than coopmat2 only; per-type SPIR-V variants replaced by two generic modules (`flash_attn_f32_f16` and `flash_attn_f32_f16_int8`) that select K/V type at runtime via `FaTypeK`/`FaTypeV` spec constants; new `flash_attn_dequant.glsl` contains aliased SSBO views and an uber `dequantize4()` switch; the K/V type mismatch guard removed from `ggml_backend_vk_device_supports_op`; internal Vulkan backend refactor, no project changes required |
| ~b9103–b9106 | `ggml/src/ggml-cuda/argsort.cu` | Added `#include <cuda/iterator>` for CCCL ≥ 3.1 strided-iterator path; internal CUDA backend, no project changes required |
| ~b9103–b9106 | `convert_hf_to_gguf.py` | Mistral Medium 3.5 mmproj support: `n_embd_text` now reads `"dim"` key instead of `"hidden_dim"`; negative `img_break_tok_id` placeholders resolved from `tekken.json` or `tokenizer.json`; conversion tool only, no project changes required |
| ~b9106–b9134 | `common/arg.cpp` | CLI option `--spec-draft-ctx-size` / `-cd` / `--ctx-size-draft` REMOVED — throws `std::invalid_argument` at parse time; `ModelParameters.setCtxSizeDraft()` removed; no replacement (context size now managed internally by speculative engine) |
| ~b9106–b9134 | `common/arg.cpp` | CLI option `--spec-draft-replace` / `--spec-replace` REMOVED — throws `std::invalid_argument` at parse time; no corresponding Java method existed |
| ~b9106–b9134 | `common/speculative.h` | Full redesign: `common_speculative_type` enum values renamed `DRAFT`&#x2192;`DRAFT_SIMPLE`, `EAGLE3`&#x2192;`DRAFT_EAGLE3`; `common_params_speculative.type` (single enum) &#x2192; `.types` (vector); `common_speculative_n_max()` / `common_speculative_n_min()` REMOVED; new `common_speculative_init(params, n_seq)` no longer takes ctx; new `common_speculative_begin(spec, seq_id, prompt)`, `common_speculative_draft(spec)`, `common_speculative_accept(spec, seq_id, n)`, `common_speculative_process(spec, batch)` signatures; `common_speculative_draft_params` struct added; server sources compiled directly, no project JNI changes required |
| ~b9106–b9134 | `common/common.h` | New `common_prompt_checkpoint` struct (contains `data_tgt` + `data_dft`) replaces the old `server_prompt_checkpoint` in `server-task.h`; compiled from upstream server sources, no project JNI changes required |
| ~b9106–b9134 | `tools/server/server-task.cpp` | `task_params::to_json()` renamed field `"speculative.type"` &#x2192; `"speculative.types"` (now serialises the vector); test `SlotParamsToJson.SpeculativeFields_Present` updated accordingly |
| ~b9106–b9134 | `include/llama.h` | New `LLAMA_STATE_SEQ_FLAGS_NONE = 0` macro added; additive, no project changes required |

## Build Commands

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ set(GGML_AVX512 OFF CACHE BOOL "" FORCE)
FetchContent_Declare(
llama.cpp
GIT_REPOSITORY https://github.com/ggerganov/llama.cpp.git
GIT_TAG b9106
GIT_TAG b9134
)
FetchContent_MakeAvailable(llama.cpp)

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
![Java 8+](https://img.shields.io/badge/Java-8%2B-informational)
[![llama.cpp b9106](https://img.shields.io/badge/llama.cpp-%23b9106-informational)](https://github.com/ggml-org/llama.cpp/releases/tag/b9106)
[![llama.cpp b9134](https://img.shields.io/badge/llama.cpp-%23b9134-informational)](https://github.com/ggml-org/llama.cpp/releases/tag/b9134)
[![Maven Central](https://img.shields.io/maven-central/v/net.ladenthin/llama)](https://central.sonatype.com/artifact/net.ladenthin/llama)
[![Snapshot](https://img.shields.io/badge/snapshot-latest-informational)](https://central.sonatype.com/repository/maven-snapshots/net/ladenthin/llama/)

Expand Down
11 changes: 0 additions & 11 deletions src/main/java/net/ladenthin/llama/ModelParameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -1263,17 +1263,6 @@ public ModelParameters setDraftPMin(float draftPMin) {
return this;
}

/**
* Set the size of the prompt context for the draft model.
*
* @param ctxSizeDraft the prompt context size for the draft model
* @return this builder
*/
public ModelParameters setCtxSizeDraft(int ctxSizeDraft) {
parameters.put("--spec-draft-ctx-size", String.valueOf(ctxSizeDraft));
return this;
}

/**
* Set the comma-separated list of devices to use for offloading the draft model.
*
Expand Down
5 changes: 2 additions & 3 deletions src/test/cpp/test_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,8 @@ TEST(SlotParamsToJson, SpeculativeFields_Present) {
task_params p;
const json j = p.to_json();

// b8962: only speculative.type is serialised; n_max/n_min/p_min are
// input-only (consumed by params_from_json_cmpl, not emitted by to_json)
EXPECT_TRUE(j.contains("speculative.type"));
// b9134: field renamed speculative.type → speculative.types (now a vector)
EXPECT_TRUE(j.contains("speculative.types"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The comment indicates speculative.types is now a vector, but the test only checks that the field exists. Since the API change includes a type change from enum to vector, the assertion should verify the serialization format:

Suggested change
EXPECT_TRUE(j.contains("speculative.types"));
// b9134: field renamed speculative.type → speculative.types (now a vector)
EXPECT_TRUE(j.contains("speculative.types"));
EXPECT_TRUE(j.at("speculative.types").is_array());

This ensures the field isn't just present, but serialized correctly as a JSON array.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

The suggestion is incorrect — speculative.types is serialized as a comma-separated string, not a JSON array. common_speculative_type_name_str (in common/speculative.cpp:794) returns a std::string by iterating the vector and joining with ",". The to_json() call in server-task.cpp:79 therefore produces e.g. "draft-simple" or "draft-simple,eagle3", so is_array() would fail on a default-constructed task_params. The contains assertion is sufficient and correct.


Generated by Claude Code

}
Comment on lines 243 to 248

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correct test update. The comment accurately reflects the b9134 API change (field renamed from speculative.type to speculative.types now that it's a vector). Test expectation is properly updated.


TEST(SlotParamsToJson, GrammarTriggers_IsArrayByDefault) {
Expand Down
1 change: 0 additions & 1 deletion src/test/java/net/ladenthin/llama/LlamaModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ public void testSpeculativeDecoding() {
.setModel(TestConstants.MODEL_PATH)
.setModelDraft(TestConstants.DRAFT_MODEL_PATH)
.setCtxSize(128)
.setCtxSizeDraft(128)
.setDraftMax(8)
.setDraftMin(1)
.setGpuLayers(gpuLayers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,12 +897,6 @@ public void testSetModelDraft() {
assertEquals("/path/to/draft.gguf", p.parameters.get("--spec-draft-model"));
}

@Test
public void testSetCtxSizeDraft() {
ModelParameters p = new ModelParameters().setCtxSizeDraft(512);
assertEquals("512", p.parameters.get("--spec-draft-ctx-size"));
}

@Test
public void testSetDeviceDraft() {
ModelParameters p = new ModelParameters().setDeviceDraft("cuda0");
Expand Down
Loading