Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions crates/higgs-engine/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mod tests {
completion_tokens: 0,
token_logprobs: None,
};
assert!(output.text.is_empty());
assert_eq!(output.text, "");
assert_eq!(output.prompt_tokens, 0);
assert_eq!(output.completion_tokens, 0);
}
Expand Down Expand Up @@ -113,7 +113,7 @@ mod tests {
token_logprob: None,
prefill_progress: None,
};
assert!(output.new_text.is_empty());
assert_eq!(output.new_text, "");
assert_eq!(output.prompt_tokens, 0);
assert_eq!(output.completion_tokens, 0);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/higgs-engine/src/mtp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,13 +822,13 @@ mod tests {
fn prompt_lookup_ignores_current_tail_self_match() {
let context = [1, 2, 3, 4];

assert!(prompt_lookup_draft(&context, 3, 4, 64).is_empty());
assert_eq!(prompt_lookup_draft(&context, 3, 4, 64), Vec::<u32>::new());
}

#[test]
fn prompt_lookup_respects_search_window() {
let context = [1, 2, 3, 4, 5, 1, 2];

assert!(prompt_lookup_draft(&context, 3, 4, 3).is_empty());
assert_eq!(prompt_lookup_draft(&context, 3, 4, 3), Vec::<u32>::new());
}
}
6 changes: 3 additions & 3 deletions crates/higgs-engine/src/reasoning_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ mod tests {
fn only_think_block_no_visible() {
let input = "<think>All reasoning, no response.</think>";
let result = parse_reasoning(input);
assert!(result.text.is_empty());
assert_eq!(result.text, "");
assert_eq!(
result.reasoning.as_deref(),
Some("All reasoning, no response.")
Expand All @@ -287,7 +287,7 @@ mod tests {
let mut tracker = StreamingReasoningTracker::new();

let (vis, reas) = tracker.process("<think>thinking");
assert!(vis.is_empty());
assert_eq!(vis, "");
assert!(reas.contains("thinking") || tracker.has_reasoning());

let (vis, reas) = tracker.process("</think>answer");
Expand All @@ -307,7 +307,7 @@ mod tests {
let total_visible = format!("{vis}{vis2}");
let total_reasoning = format!("{reas}{reas2}");
assert!(total_visible.contains("Hello world"));
assert!(total_reasoning.is_empty());
assert_eq!(total_reasoning, "");
assert!(!tracker.has_reasoning());
}

Expand Down
42 changes: 33 additions & 9 deletions crates/higgs-engine/src/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3244,18 +3244,24 @@ mod tests {

#[test]
fn test_extract_eos_tokens_missing_field() {
assert!(eos_from_config(r#"{"model_type": "qwen2"}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"model_type": "qwen2"}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_unexpected_type() {
assert!(eos_from_config(r#"{"eos_token_id": "string"}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": "string"}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_missing_config_file() {
let dir = tempfile::tempdir().unwrap();
assert!(super::extract_eos_tokens(dir.path()).is_empty());
assert_eq!(super::extract_eos_tokens(dir.path()), Vec::<u32>::new());
}

// -- Additional check_stop_sequences edge cases --
Expand Down Expand Up @@ -3293,35 +3299,53 @@ mod tests {
#[test]
fn test_extract_eos_tokens_float_value() {
// serde_json parses 151643.0 as a float, and as_u64() returns None for floats
assert!(eos_from_config(r#"{"eos_token_id": 151643.0}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": 151643.0}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_string_value() {
assert!(eos_from_config(r#"{"eos_token_id": "not_a_number"}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": "not_a_number"}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_nested_array() {
// Inner arrays are not numbers, so as_u64() returns None for them
assert!(eos_from_config(r#"{"eos_token_id": [[1, 2], [3, 4]]}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": [[1, 2], [3, 4]]}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_negative_number() {
// as_u64() returns None for negative numbers
assert!(eos_from_config(r#"{"eos_token_id": -1}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": -1}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_very_large_number() {
// u32::MAX is 4294967295; as_u64() succeeds but u32::try_from fails
assert!(eos_from_config(r#"{"eos_token_id": 4294967296}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": 4294967296}"#),
Vec::<u32>::new()
);
}

#[test]
fn test_extract_eos_tokens_empty_array() {
assert!(eos_from_config(r#"{"eos_token_id": []}"#).is_empty());
assert_eq!(
eos_from_config(r#"{"eos_token_id": []}"#),
Vec::<u32>::new()
);
}

#[test]
Expand Down
10 changes: 5 additions & 5 deletions crates/higgs-engine/src/tool_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ mod tests {
{"name": "get_weather", "arguments": {"city": "London"}}
</tool_call>"#;
let result = assert_parse(input, 1, None);
assert!(result.text.is_empty());
assert_eq!(result.text, "");
assert_eq!(first_tool_name(&result), "get_weather");
}

Expand Down Expand Up @@ -861,7 +861,7 @@ I've requested the weather."#;
#[test]
fn test_empty_text() {
let result = assert_parse("", 0, None);
assert!(result.text.is_empty());
assert_eq!(result.text, "");
}

#[test]
Expand Down Expand Up @@ -1206,7 +1206,7 @@ After last."#;
let tc = result.tool_calls.first().unwrap();
assert_eq!(tc.name, "get_weather");
assert_eq!(tc.arguments, serde_json::json!({ "city": "London" }));
assert!(result.text.is_empty());
assert_eq!(result.text, "");
}

/// Multiple parameters, and a multi-line value: only the single wrapping
Expand Down Expand Up @@ -1404,7 +1404,7 @@ After last."#;
let tc = result.tool_calls.first().unwrap();
assert_eq!(tc.name, "get_weather");
assert_eq!(tc.arguments, serde_json::json!({ "city": "London" }));
assert!(result.text.is_empty());
assert_eq!(result.text, "");
}

/// Multiple consecutive blocks, with text before/between them preserved.
Expand Down Expand Up @@ -1446,7 +1446,7 @@ After last."#;
assert!(code.contains("fn main()"));
assert!(code.contains("</function> not a real close"));
assert!(code.contains('\n'));
assert!(result.text.is_empty());
assert_eq!(result.text, "");
}

/// Declared schema coerces `MiniCPM` param values; a `string`-typed `"123"`
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs-models/src/deepseek_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn compute_yarn_freqs(
let mask = 1.0 - ramp;
let inter = freq_inter[i];
let extra = freq_extra[i];
let denom = inter * mask + extra * (1.0 - mask);
let denom = inter.mul_add(mask, extra * (1.0 - mask));
freqs.push((inter * extra) / denom);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/higgs-models/src/qwen3_moe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ mod tests {
assert_eq!(args.num_experts_per_tok, 8);
assert_eq!(args.moe_intermediate_size, 1536);
assert_eq!(args.decoder_sparse_step, 1);
assert!(args.mlp_only_layers.is_empty());
assert_eq!(args.mlp_only_layers, Vec::<i32>::new());
assert!(args.norm_topk_prob);
assert!(!args.tie_word_embeddings);
assert!(!args.attention_bias);
Expand Down Expand Up @@ -735,7 +735,7 @@ mod tests {
assert_eq!(args.num_experts_per_tok, 0);
assert_eq!(args.moe_intermediate_size, 0);
assert_eq!(args.decoder_sparse_step, 0);
assert!(args.mlp_only_layers.is_empty());
assert_eq!(args.mlp_only_layers, Vec::<i32>::new());
assert!(!args.norm_topk_prob);
assert!(args.quantization.is_none());
}
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs-models/src/qwen3_next.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5804,7 +5804,7 @@ mod tests {
assert_eq!(args.num_experts_per_tok, 0);
assert_eq!(args.decoder_sparse_step, 0);
assert!(args.norm_topk_prob);
assert!(args.mlp_only_layers.is_empty());
assert_eq!(args.mlp_only_layers, Vec::<i32>::new());
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions crates/higgs-models/src/turboquant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const TWO_BIT_CENTROIDS: [f32; 4] = [-1.5104, -0.4528, 0.4528, 1.5104];
const THREE_BIT_CENTROIDS: [f32; 8] = [
-2.1520, -1.3440, -0.7560, -0.2451, 0.2451, 0.7560, 1.3440, 2.1520,
];
// Lloyd-Max centroids for a unit Gaussian; ±1.6180 matches the golden ratio only by coincidence.
#[allow(clippy::approx_constant)]
const FOUR_BIT_CENTROIDS: [f32; 16] = [
-2.7326, -2.0690, -1.6180, -1.2562, -0.9424, -0.6568, -0.3881, -0.1284, 0.1284, 0.3881, 0.6568,
0.9424, 1.2562, 1.6180, 2.0690, 2.7326,
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs-models/src/yarn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub(crate) fn compute_yarn_freqs(
let mask = 1.0 - ramp;
let inter = freq_inter[i];
let extra = freq_extra[i];
let denom = inter * mask + extra * (1.0 - mask);
let denom = inter.mul_add(mask, extra * (1.0 - mask));
freqs.push((inter * extra) / denom);
}

Expand Down
2 changes: 1 addition & 1 deletion crates/higgs-models/tests/adapter_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ fn unknown_family_error_lists_supported_ranges() {
#[test]
fn supported_adapter_ids_are_unique() {
let supported = adapter::supported();
assert!(!supported.is_empty());
assert_ne!(supported.len(), 0);
let mut ids = supported.iter().map(|info| info.id).collect::<Vec<_>>();
ids.sort_unstable();
ids.dedup();
Expand Down
4 changes: 1 addition & 3 deletions crates/higgs/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,16 @@ pub fn cmd_stop(profile: Option<&str>, force: bool) -> i32 {
}
remove_pid_file(profile);
eprintln!("stopped {label} (pid {pid})");
0
}
Some(_) => {
remove_pid_file(profile);
eprintln!("{label} is not running (stale pid file removed)");
0
}
None => {
eprintln!("{label} is not running (no pid file)");
0
}
}
0
}

#[allow(clippy::print_stderr)]
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/src/metrics_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ mod tests {

// The main file should now be empty (new file created after rotation).
let main_content = fs::read_to_string(&log_path).unwrap();
assert!(main_content.is_empty());
assert_eq!(main_content, "");
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/src/model_download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ mod tests {
fn non_interactive_writes_no_prompt() {
let mut out = Vec::new();
let _ = offer_download("org/model", false, &mut out, b"".as_slice(), ok_download);
assert!(out.is_empty());
assert_eq!(out, Vec::<u8>::new());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/src/tui/views/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn format_duration(dur: std::time::Duration) -> String {
let total_secs = dur.as_secs_f64();
if total_secs >= 60.0 {
let mut minutes = (total_secs / 60.0).floor();
let mut seconds = total_secs - minutes * 60.0;
let mut seconds = minutes.mul_add(-60.0, total_secs);
// Clamp to avoid "1m60.0s" from rounding
if seconds >= 59.95 {
minutes += 1.0;
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/src/types/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ mod tests {

#[test]
fn test_stop_sequence_extract() {
assert!(StopSequence::extract(None).is_empty());
assert_eq!(StopSequence::extract(None), Vec::<String>::new());

let single = StopSequence::extract(Some(StopSequence::Single("x".to_owned())));
assert_eq!(single, vec!["x"]);
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/tests/integration/request_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ fn chat_request_stop_array() {
#[test]
fn stop_sequence_extract_none() {
let result = StopSequence::extract(None);
assert!(result.is_empty());
assert_eq!(result, Vec::<String>::new());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/higgs/tests/integration/response_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ fn anthropic_message_start_event() {
let json = assert_event_type(&event, "message_start");
assert_eq!(json["message"]["type"], "message");
assert_eq!(json["message"]["role"], "assistant");
assert!(json["message"]["content"].as_array().unwrap().is_empty());
assert_eq!(json["message"]["content"], serde_json::json!([]));
assert!(json["message"]["stop_reason"].is_null());
}

Expand Down
Loading