Skip to content

005 distribution trace visual#17

Merged
blizhan merged 6 commits into
mainfrom
005-distribution-trace-visual
Apr 30, 2026
Merged

005 distribution trace visual#17
blizhan merged 6 commits into
mainfrom
005-distribution-trace-visual

Conversation

@blizhan

@blizhan blizhan commented Apr 30, 2026

Copy link
Copy Markdown
Owner

No description provided.

blizhan and others added 4 commits April 26, 2026 16:55
- Added support for visualizing distribution traces with histogram and heatmap outputs.
- Updated command help to include new usage examples for distribution tracing.
- Implemented step selection for distribution traces, allowing users to specify exact or nearest steps.
- Enhanced tests to cover new distribution visualization features and ensure correct behavior across various output formats.
- Updated `.gitignore` to include additional temporary files related to distribution tracing.
…t practices

- Added a new section on "Fast Recipes" in SKILL.md for common analysis tasks.
- Introduced detailed analysis workflows and critical rules for using aimx effectively.
- Included guidelines for ranking runs, inspecting curve health, and compact local analysis.
- Enhanced aimx-cli.md with analysis patterns and examples for comparing runs and detecting anomalies.
- Emphasized the importance of structured evidence and compact reporting in analysis.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the aimx trace distribution command, enabling users to visualize Aim distribution sequences as terminal-based histograms and heatmaps. The changes include a refactored trace command pipeline, new rendering logic using Rich for blue-gradient visuals, and extensive documentation updates covering analysis patterns and workflows. The review feedback correctly identifies several edge cases in the new rendering code, specifically regarding the handling of non-finite values (NaN/Inf) and a potential division-by-zero error when the terminal height is configured to a very small value.



def _sample_points_for_height(points: list[Any], max_rows: int) -> list[Any]:
if max_rows <= 0 or len(points) <= max_rows:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

If max_rows is 1 and len(points) > 1, the calculation of indexes on line 171 will raise a ZeroDivisionError because of max_rows - 1. This can be triggered by a user providing a small --height value (e.g., 12 or 13). The guard should be updated to handle max_rows <= 1.

Suggested change
if max_rows <= 0 or len(points) <= max_rows:
if max_rows <= 1 or len(points) <= max_rows:

Comment thread src/aimx/rendering/trace_views.py Outdated
start = index * len(values) // width
end = (index + 1) * len(values) // width
bucket = values[start:end] or [values[start]]
compressed.append(max(bucket))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If a bucket contains non-finite values (NaN or Inf), max(bucket) may return them, which can cause issues during rendering in _intensity_text. It is safer to filter for finite values and provide a default.

Suggested change
compressed.append(max(bucket))
compressed.append(max((v for v in bucket if math.isfinite(v)), default=0.0))

Comment thread src/aimx/rendering/trace_views.py Outdated
text = Text()
if not values:
return text
max_value = max(float(v) for v in values)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

If values contains non-finite values (NaN or Inf), max() will return them. This can lead to a ValueError when round() is called on a NaN scale later in the function. Filtering for finite values ensures robustness against unexpected data in the Aim repository.

    finite_values = [float(v) for v in values if math.isfinite(v)]
    max_value = max(finite_values, default=0.0)

return text
for value in values:
if value <= 0:
text.append(_DISTRIBUTION_BLOCKS[0], style=_DISTRIBUTION_ZERO_STYLE)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Non-finite values should be treated as zero or skipped to avoid crashes during scale calculation and rounding.

Suggested change
text.append(_DISTRIBUTION_BLOCKS[0], style=_DISTRIBUTION_ZERO_STYLE)
if not math.isfinite(value) or value <= 0:

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8c5ef4d329

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +169 to +171
if max_rows <= 0 or len(points) <= max_rows:
return points
indexes = sorted({round(i * (len(points) - 1) / (max_rows - 1)) for i in range(max_rows)})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Guard one-row heatmap sampling against zero division

When --height is small (e.g., 12 or 13), render_distribution_visual computes max_heatmap_rows as 1; if the selected series has more than one point, _sample_points_for_height reaches the index calculation and divides by (max_rows - 1), which is zero. This raises ZeroDivisionError and makes aimx trace distribution ... --height <small> fail instead of rendering a reduced heatmap, so the sampler should special-case max_rows == 1 before the interpolation formula.

Useful? React with 👍 / 👎.

@blizhan blizhan merged commit 96eaa00 into main Apr 30, 2026
1 check 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.

1 participant