Skip to content

add multi-mode reduction, percentiles, and log comparison to log_parser - #398

Merged
Jacob-Chmura merged 2 commits into
tgm-team:mainfrom
alekseevpavel04:add-multi-mode-reduction-percentiles-and-log-compa
Mar 20, 2026
Merged

add multi-mode reduction, percentiles, and log comparison to log_parser#398
Jacob-Chmura merged 2 commits into
tgm-team:mainfrom
alekseevpavel04:add-multi-mode-reduction-percentiles-and-log-compa

Conversation

@alekseevpavel04

Copy link
Copy Markdown
Contributor

Summary / Description

The log parser only did mean reduction and had no way to compare runs. Added a MetricSummary dataclass, a compute_summary fn for full stats (count, mean, std, min, max, configurable percentiles), and a reduce_metrics fn that supports mean/median/min/max/last/full strategies. Also added compare_logs which diffs two log files side by side and reports absolute and relative deltas per metric. collect_raw_metrics splits out the file reading from reduction so both pieces are testable independently. parse_log_file is kept as a thin wrapper for backward compat. CLI gets three new args: --reduction, --percentiles, and --compare.

Related Issues: #

Type of Change

  • Bug fix
  • New feature
  • Breaking Change
  • Refactoring
  • Documentation update

Test Evidence

Manual testing with existing log files. The old default behavior (mean reduction, no comparison) is unchanged.

  • Unit tests
  • Integration tests
  • Performance tests

Questions / Discussion Points

The percentile interpolation uses linear interp between adjacent sorted values, same approach as numpy percentile with interpolation='linear'. Open to switching to a different method if there is a project preference.

@codecov

codecov Bot commented Mar 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@Jacob-Chmura Jacob-Chmura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great contribution. We can at some point update the CI script to properly diff integration test runs using this logic.

Triggering a small integration test to check parsing

Comment thread tools/log_parser.py
MetricSummary with count, mean, std, min, max, and optional percentiles.
"""
n = len(values)
mean = sum(values) / n

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
mean = sum(values) / n
mean = statistics.mean(values) if n > 1 else 0.0

Comment thread tools/log_parser.py Outdated
Comment on lines +98 to +101
idx = (p / 100.0) * (n - 1)
lo = int(idx)
hi = min(lo + 1, n - 1)
pct[f'p{p:g}'] = sorted_vals[lo] + (sorted_vals[hi] - sorted_vals[lo]) * (idx - lo)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note that requires n > 1

@Jacob-Chmura Jacob-Chmura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approving to unblock, just try to run the ruff formatter before merging.

@Jacob-Chmura
Jacob-Chmura merged commit 242a251 into tgm-team:main Mar 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants