• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rendezqueue / rendezllama / 21034303061

15 Jan 2026 01:57PM UTC coverage: 90.228% (+5.5%) from 84.745%
21034303061

push

github

grencez
qual(test): inference

409 of 418 new or added lines in 5 files covered. (97.85%)

2022 of 2241 relevant lines covered (90.23%)

55.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.59
/test/language/inference_test.cc
1
#include "src/chat/display.hh"
2
#include "src/chat/opt.hh"
3
#include "src/chat/trajectory.hh"
4
#include "src/language/inference.hh"
5
#include "src/language/vocabulary.hh"
6

7
#include <cassert>
8
#include <iostream>
9
#include <tuple>
10
#include <vector>
11

12
#include <fildesh/fildesh.h>
13

14
#include "llama.h"
15

16
using rendezllama::ChatDisplay;
17
using rendezllama::ChatOptions;
18
using rendezllama::ChatTrajectory;
19
using rendezllama::Inference;
20
using rendezllama::Vocabulary;
21

22
static
23
  void
24
noop_log_callback(enum ggml_log_level level, const char* text, void* user_data)
173✔
25
{
26
  (void) level;
173✔
27
  (void) text;
173✔
28
  (void) user_data;
173✔
29
}
173✔
30

31
static void test_antiprompt_suffix() {
1✔
32
  std::set<std::string> antiprompts;
1✔
33
  antiprompts.insert("User:");
2✔
34
  antiprompts.insert("\nUser:");
2✔
35

36
  // Case: No match
37
  assert(rendezllama::antiprompt_suffix("Hello World", antiprompts).empty());
1✔
38

39
  // Case: Exact match
40
  assert(rendezllama::antiprompt_suffix("User:", antiprompts) == "User:");
1✔
41

42
  // Case: Suffix match
43
  assert(rendezllama::antiprompt_suffix("Hello User:", antiprompts) == "User:");
1✔
44

45
  // Case: Longest match check (order in set matters)
46
  // "User:" is a suffix of "\nUser:" but "\nUser:" is longer.
47
  // In std::set, "\nUser:" (byte 10) comes before "User:" (byte 85).
48
  // The function iterates and returns the first match.
49
  // "\nUser:" should be checked first.
50
  assert(rendezllama::antiprompt_suffix("Hello\nUser:", antiprompts) == "\nUser:");
1✔
51

52
  // Case: Partial match should fail
53
  assert(rendezllama::antiprompt_suffix("User", antiprompts).empty());
1✔
54
}
1✔
55

56
static void inference_test(const std::string& model_filename) {
1✔
57
  llama_log_set(noop_log_callback, NULL);
1✔
58

59
  ChatOptions opt;
1✔
60
  opt.model_filename = model_filename;
1✔
61
  // Initialize infer_via with default Sampling to avoid assertion failure in Inference::reinitialize.
62
  opt.infer_via.emplace<rendezllama::inference::Sampling>();
1✔
63

64
  struct llama_model* model = nullptr;
1✔
65
  struct llama_context* ctx = nullptr;
1✔
66
  std::tie(model, ctx) = rendezllama::make_llama_context(opt);
1✔
67
  assert(model);
1✔
68
  assert(ctx);
1✔
69

70
  Vocabulary vocabulary(model);
1✔
71
  Inference inference(vocabulary);
1✔
72
  ChatTrajectory chat_traj(vocabulary.bos_token_id());
1✔
73
  ChatDisplay chat_disp;
1✔
74
  // Use /dev/null for display to avoid spamming test output, we check tokens programmatically.
75
  chat_disp.out_ = open_FildeshOF("/dev/null");
1✔
76

77
  // Add a simple prompt to start generation.
78
  // "Once upon a time"
79
  chat_traj.tokenize_append("Once upon a time", vocabulary);
1✔
80
  chat_disp.show_new(chat_traj, vocabulary);
1✔
81

82
  using rendezllama::inference::AdjustViaKind;
1✔
83
  using rendezllama::inference::Sampling;
1✔
84
  using rendezllama::inference::Mirostat;
1✔
85

86
  std::vector<Sampling> samplings;
1✔
87
  // Temperature
88
  {
1✔
89
    Sampling s;
1✔
90
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::temperature>, 0.8f);
1✔
91
    samplings.push_back(s);
1✔
NEW
92
  }
×
93
  // Top K
94
  {
1✔
95
    Sampling s;
1✔
96
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::top_k>, 40u);
1✔
97
    samplings.push_back(s);
1✔
NEW
98
  }
×
99
  // Top P
100
  {
1✔
101
    Sampling s;
1✔
102
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::top_p>, 0.9f);
1✔
103
    samplings.push_back(s);
1✔
NEW
104
  }
×
105
  // Min P
106
  {
1✔
107
    Sampling s;
1✔
108
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::min_p>, 0.05f);
1✔
109
    samplings.push_back(s);
1✔
NEW
110
  }
×
111
   // Typical P
112
  {
1✔
113
    Sampling s;
1✔
114
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::typical_p>, 0.9f);
1✔
115
    samplings.push_back(s);
1✔
NEW
116
  }
×
117
  // Mirostat V2
118
  {
1✔
119
    Sampling s;
1✔
120
    s.pick_via = Mirostat{2, 5.0f, 0.1f};
1✔
121
    samplings.push_back(s);
1✔
NEW
122
  }
×
123
  // Penalties
124
  {
1✔
125
    Sampling s;
1✔
126
    rendezllama::inference::PenalizeWith p;
1✔
127
    p.window_length = 5;
1✔
128
    p.repetition = 1.1f;
1✔
129
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::penalize_with>, p);
1✔
130
    samplings.push_back(s);
1✔
NEW
131
  }
×
132
  // Dry
133
  {
1✔
134
    Sampling s;
1✔
135
    rendezllama::inference::Dry d;
1✔
136
    d.multiplier = 0.8f;
1✔
137
    d.base = 1.75f;
1✔
138
    d.allowed_length = 2;
1✔
139
    d.window_length = 0; // Default
1✔
140
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::dry>, d);
1✔
141
    samplings.push_back(s);
1✔
NEW
142
  }
×
143
  // XTC
144
  {
1✔
145
    Sampling s;
1✔
146
    rendezllama::inference::Xtc x;
1✔
147
    x.threshold = 0.1f;
1✔
148
    x.probability = 0.5f;
1✔
149
    s.adjust_thru.emplace_back(std::in_place_index<AdjustViaKind::xtc>, x);
1✔
150
    samplings.push_back(s);
1✔
NEW
151
  }
×
152

153
  // Iterate through different sampling options.
154
  for (const auto& sampling : samplings) {
10✔
155
    opt.infer_via = sampling;
9✔
156
    if (!inference.commit_to_context(ctx, chat_disp, chat_traj, opt, model)) {
9✔
157
      break;
158
    }
159
    inference.sample_to_trajectory(chat_traj, ctx, false);
9✔
160
    chat_disp.show_new(chat_traj, vocabulary);
9✔
161
  }
162

163
  llama_free(ctx);
1✔
164
  llama_model_free(model);
1✔
165
}
1✔
166

167
int main(int argc, char** argv)
1✔
168
{
169
  rendezllama::GlobalScope rendezllama_global_scope;
1✔
170
  assert(argc == 2);
1✔
171
  test_antiprompt_suffix();
1✔
172
  inference_test(argv[1]);
2✔
173
  return 0;
1✔
174
}
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc