Skip to content

Commit 0607cc1

Browse files
committed
Fix: Driver errors on Summit runs
1 parent 95d7594 commit 0607cc1

3 files changed

Lines changed: 35 additions & 19 deletions

File tree

include/chimbuko/param/hbos_param.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ namespace chimbuko {
7474
/**
7575
* @brief Create new histogram locally for AD module's batch data instances
7676
*/
77-
void create_histogram(const std::vector<double>& r_times);
77+
int create_histogram(const std::vector<double>& r_times);
7878

7979

80-
void merge_histograms(const Histogram& g, const std::vector<double>& runtimes);
80+
int merge_histograms(const Histogram& g, const std::vector<double>& runtimes);
8181

8282
/**
8383
* @brief Combine two Histogram instances such that the resulting statistics are the union of the two

src/ad/ADOutlier.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,16 @@ Anomalies ADOutlierHBOS::run(int step) {
258258
}
259259
if (runtimes.size() > 0) {
260260
if (!g.find(func_id)) { // If func_id does not exist
261-
param[func_id].create_histogram(runtimes);
261+
const int r = param[func_id].create_histogram(runtimes);
262+
if (r < 0) {return outliers;}
262263
}
263264
else { //merge with exisiting func_id, not overwrite
264265

265-
param[func_id].merge_histograms(g[func_id], runtimes);
266+
const int r = param[func_id].merge_histograms(g[func_id], runtimes);
267+
if (r < 0) {return outliers;}
266268
}
267269
}
270+
else { return outliers;}
268271
}
269272

270273
//Update temp runstats to include information collected previously (synchronizes with the parameter server if connected)
@@ -332,7 +335,7 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
332335
verboseStream << "min_score = " << min_score << std::endl;
333336
verboseStream << "max_score = " << max_score << std::endl;
334337

335-
if (out_scores_i.size() == 0) return 0;
338+
if (out_scores_i.size() <= 0) {return 0;}
336339

337340
//compute threshold
338341
verboseStream << "Global threshold before comparison with local threshold = " << param[func_id].get_threshold() << std::endl;
@@ -359,28 +362,32 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
359362
double ad_score;
360363

361364
const int bin_ind = ADOutlierHBOS::np_digitize_get_bin_inds(runtime_i, param[func_id].bin_edges());
362-
verboseStream << "bin_ind: " << bin_ind << " for runtime_i: " << runtime_i << std::endl;
365+
verboseStream << "bin_ind: " << bin_ind << " for runtime_i: " << runtime_i << ", where bin_edges Size:" << param[func_id].bin_edges().size() << " & num_bins: "<< num_bins << std::endl;
363366
/**
364367
* If the sample does not belong to any bins
365368
* bin_ind == 0 (fall outside since it is too small)
366369
*/
367370
if( bin_ind == 0){
368371
const double first_bin_edge = param[func_id].bin_edges().at(0);
369372
const double dist = first_bin_edge - runtime_i;
373+
verboseStream << "First_bin_edge: " << first_bin_edge << std::endl;
370374
if( dist <= (bin_width * 0.05) ){
371375
verboseStream << runtime_i << " is on left of histogram but NOT outlier" << std::endl;
376+
if(param[func_id].counts().size() < 1) {return 0;}
372377
if(param[func_id].counts().at(0) == 0) { /**< Ignore zero counts */
373-
378+
374379
ad_score = l_threshold - 1;
375380
verboseStream << "corrected ad_score: " << ad_score << std::endl;
376381
}
377382
else {
378383
ad_score = out_scores_i.at(0);
384+
verboseStream << "ad_score: " << ad_score << std::endl;
379385
}
380386
}
381387
else{
382388
verboseStream << runtime_i << " is on left of histogram and an outlier" << std::endl;
383389
ad_score = max_score;
390+
verboseStream << "ad_score(max_score): " << ad_score << std::endl;
384391
}
385392

386393
}
@@ -391,21 +398,23 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
391398
const int last_idx = param[func_id].bin_edges().size() - 1;
392399
const double last_bin_edge = param[func_id].bin_edges().at(last_idx);
393400
const double dist = runtime_i - last_bin_edge;
394-
401+
verboseStream << "last_indx: " << last_idx << ", last_bin_edge: " << last_bin_edge << std::endl;
395402
if (dist <= (bin_width * 0.05)) {
396-
if(param[func_id].counts().at(bin_ind) == 0) { /**< Ignore zero counts */
403+
if(param[func_id].counts().at(num_bins - 1) == 0) { //bin_ind) == 0) { /**< Ignore zero counts */
397404

398405
ad_score = l_threshold - 1;
399406
verboseStream << "corrected ad_score: " << ad_score << std::endl;
400407
}
401408
else {
402409
verboseStream << runtime_i << " is on right of histogram but NOT outlier" << std::endl;
403410
ad_score = out_scores_i.at(num_bins - 1);
411+
verboseStream << "ad_score: " << ad_score << ", num_bins: " << num_bins << ", out_scores_i size: " << out_scores_i.size() << std::endl;
404412
}
405413
}
406414
else{
407415
verboseStream << runtime_i << " is on right of histogram and an outlier" << std::endl;
408416
ad_score = max_score;
417+
verboseStream << "ad_score(max_score): " << ad_score << ", num_bins: " << num_bins << ", out_scores_i size: " << out_scores_i.size() << std::endl;
409418
}
410419

411420
}
@@ -419,6 +428,7 @@ unsigned long ADOutlierHBOS::compute_outliers(Anomalies &outliers,
419428
else {
420429
verboseStream << runtime_i << " maybe be an outlier" << std::endl;
421430
ad_score = out_scores_i.at( bin_ind - 1);
431+
verboseStream << "ad_score(else): " << ad_score << ", bin_ind: " << bin_ind << ", num_bins: " << num_bins << ", out_scores_i size: " << out_scores_i.size() << std::endl;
422432
}
423433

424434
}

src/param/hbos_param.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ using namespace chimbuko;
147147
Histogram chimbuko::operator+(const Histogram& g, const Histogram& l) {
148148
Histogram combined;
149149
double min_runtime, max_runtime;
150-
verboseStream << "Bin_Edges Size of Global Histogram: " << std::to_string(g.bin_edges().size()) << ", Bin_Edges Size of Local Histogram: " << std::to_string(l.bin_edges().size()) << std::endl;
150+
//verboseStream << "Bin_Edges Size of Global Histogram: " << std::to_string(g.bin_edges().size()) << ", Bin_Edges Size of Local Histogram: " << std::to_string(l.bin_edges().size()) << std::endl;
151151
verboseStream << "Counts Size of Global Histogram: " << std::to_string(g.counts().size()) << ", Counts Size of Local Histogram: " << std::to_string(l.counts().size()) << std::endl;
152152

153153
if (g.counts().size() <= 0) {
@@ -222,12 +222,17 @@ using namespace chimbuko;
222222
comb_binedges[1] = edge_val + bin_width;
223223
}
224224
else{
225+
/*
225226
comb_binedges.resize(floor((max_runtime - min_runtime)/bin_width) + 2);
226227
for (int i = 0; i < comb_binedges.size(); i++) {
227228
comb_binedges[i] = edge_val;
228229
edge_val += bin_width;
229230
}
230-
231+
*/
232+
for(edge_val = min_runtime; edge_val < max_runtime;) {
233+
comb_binedges.push_back(edge_val);
234+
edge_val += bin_width;
235+
}
231236
}
232237
}
233238

@@ -282,7 +287,7 @@ using namespace chimbuko;
282287

283288

284289
*this = combined;
285-
//this->set_hist_data(Histogram::Data(this->get_threshold(), this->counts(), this->bin_edges()));
290+
this->set_hist_data(Histogram::Data(this->get_threshold(), this->counts(), this->bin_edges()));
286291
return *this;
287292
}
288293

@@ -334,7 +339,7 @@ using namespace chimbuko;
334339
var = var / size;
335340
verboseStream << "Final Variance in _scott_binWidth: " << var << std::endl;
336341
std = sqrt(var);
337-
verboseStream << "STD in _scott_binWidth: " << std << std::endl;
342+
verboseStream << "STD in merging _scott_binWidth: " << std << std::endl;
338343
if (std <= 100.0) {return 0;}
339344

340345
return ((3.5 * std ) / pow(size, 1/3));
@@ -370,10 +375,11 @@ using namespace chimbuko;
370375
// m_histogram.runtimes.push_back(x);
371376
//}
372377

373-
void Histogram::create_histogram(const std::vector<double>& r_times)
378+
int Histogram::create_histogram(const std::vector<double>& r_times)
374379
{
375380
std::vector<double> runtimes = r_times;
376381
const double bin_width = Histogram::_scott_binWidth(runtimes);
382+
if (bin_width <= 0) {return -1;}
377383
std::sort(runtimes.begin(), runtimes.end());
378384
const int h = runtimes.size() - 1;
379385

@@ -406,10 +412,10 @@ using namespace chimbuko;
406412
m_histogram.glob_threshold = min_threshold;
407413
}
408414
this->set_hist_data(Histogram::Data( m_histogram.glob_threshold, m_histogram.counts, m_histogram.bin_edges ));
409-
415+
return 0;
410416
}
411417

412-
void Histogram::merge_histograms(const Histogram& g, const std::vector<double>& runtimes)
418+
int Histogram::merge_histograms(const Histogram& g, const std::vector<double>& runtimes)
413419
{
414420

415421
std::vector<double> r_times = runtimes;
@@ -421,10 +427,10 @@ using namespace chimbuko;
421427
}
422428

423429
m_histogram.glob_threshold = g.get_threshold();
424-
// verboseStream << "glob_threshold in merge_histograms = " << m_histogram.glob_threshold << std::endl;
425-
this->create_histogram(r_times);
430+
//verboseStream << "glob_threshold in merge_histograms = " << m_histogram.glob_threshold << std::endl;
431+
return this->create_histogram(r_times);
426432
//this->set_hist_data(Histogram::Data( m_histogram.glob_threshold, m_histogram.counts, m_histogram.bin_edges ));
427-
433+
428434
}
429435

430436
nlohmann::json Histogram::get_json() const {

0 commit comments

Comments
 (0)