Skip to content

fix(rocprofiler-compute): Repair counter grouping policy coalescing - #10912

Open
feizheng10 wants to merge 2 commits into
rocprofiler-compute-developfrom
users/feizheng10/fix-counter-grouping-pack
Open

fix(rocprofiler-compute): Repair counter grouping policy coalescing#10912
feizheng10 wants to merge 2 commits into
rocprofiler-compute-developfrom
users/feizheng10/fix-counter-grouping-pack

Conversation

@feizheng10

Copy link
Copy Markdown
Contributor

Motivation

Fix counter grouping policy bugs called out in #9324 review: _ACCUM buckets were skipped during metric-aware coalesce (sparse perfmon YAMLs / extra passes), priority metrics used global SUPPORTED_DENOM spill when deciding same-bucket partners (e.g. gfx1250 CP Utilization split across passes), and gfx1151–gfx1153 never loaded the shared gfx115x policy block.

This PR is intended to land before #9324 so HBM / grouping-policy changes stack on a working allocator.

Technical Details

  • Accum bucket packing: remove the _ACCUM skip in _metric_aware_coalesce_pass so regular PMCs can pack into level/accum buckets when block capacity allows (reservations preserved via _trial_counter_file_with_extra).
  • Formula-only grouping: add extract_metric_formula_hw_counters() for metric-aware coalesce; profiling still uses full extract_counters_and_variables() in detect_counters().
  • gfx115x policy lookup: resolve profiling_counter_grouping_policy.yaml and analysis configs via canonical_config_arch() for gfx1151–gfx1153 (inspector + soc_base).
  • Optional cleanup (follow-up, not in this PR): fold extract_metric_formula_hw_counters() into extract_counters_and_variables(..., include_supported_denom=True) to DRY the shared variable-resolution loop once behavior is stable in review.

Full-panel perfmon passes (before → after)

Measured with tools/counter_grouping_inspector.py full counter set vs origin/rocprofiler-compute-develop (bucket count = perfmon passes).

Architecture Before After Delta
gfx908 12 12 +0
gfx90a 13 13 +0
gfx940 13 13 +0
gfx941 13 13 +0
gfx942 13 13 +0
gfx950 20 20 +0
gfx1151 10 10 +0
gfx1152 10 10 +0
gfx1153 10 10 +0
gfx1250 23 17 −6

CDNA arches (empty grouping policy) unchanged on pass count. gfx1250 drops from 23 → 17 (matches the 17-pass target documented in profiling_counter_grouping_policy.yaml). gfx115x pass count unchanged; grouping policy now activates (4 priority metric ids) where it was previously a no-op.

JIRA ID

AIPROFCOMP-78

Test Plan

  • PYTHONPATH=src pytest tests/unit/rocprof_compute_soc/test_soc_base.py tests/unit/utils/test_utils_counter_defs.py
  • python3 tools/counter_grouping_inspector.py --arch gfx1250 --block 17.1.1 (CP Utilization single bucket)
  • python3 tools/counter_grouping_inspector.py --arch gfx1151 (gfx115x config tree + 10 passes)
  • Hardware smoke profile on gfx1250 / gfx115x (optional)

Test Result

  • Unit tests pass (grouping, gfx115x policy lookup, formula-only extraction)
  • Inspector full-panel pass table above

Submission Checklist

Made with Cursor

- Pack regular PMCs into _ACCUM buckets during metric-aware coalesce
- Use formula-only counter discovery for same-bucket grouping decisions
- Resolve gfx115x grouping policy and configs for gfx1151–gfx1153

Co-Authored-By: Auto
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@feizheng10
feizheng10 marked this pull request as ready for review August 28, 2026 21:50
@feizheng10
feizheng10 requested a review from a team as a code owner August 28, 2026 21:50
Copilot AI lite review requested due to automatic review settings August 28, 2026 21:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes bugs in rocprofiler-compute’s counter grouping / metric-aware coalescing so priority metrics and accumulator (“_ACCUM”) buckets are handled correctly, and gfx1151–gfx1153 correctly resolve the shared gfx115x grouping policy/config tree (intended to land before #9324 so subsequent HBM/pass-coalescing changes stack on a correct allocator).

Changes:

  • Update metric-aware coalescing to consider only counters referenced by a metric’s formula (excluding global SUPPORTED_DENOM spill) and allow packing into _ACCUM buckets.
  • Canonicalize analysis-config and grouping-policy lookup (e.g., gfx1151gfx115x) in the inspector and allocator policy lookup.
  • Add unit tests covering formula-only extraction, _ACCUM bucket packing behavior, and gfx115x policy resolution.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/rocprofiler-compute/tools/counter_grouping_inspector.py Resolve analysis config subdirectory via canonical_config_arch() so gfx115x uses the shared config tree.
projects/rocprofiler-compute/tests/unit/utils/test_utils_counter_defs.py Add unit test ensuring formula-only counter extraction omits SUPPORTED_DENOM spill counters.
projects/rocprofiler-compute/tests/unit/rocprof_compute_soc/test_soc_base.py Add unit tests for metric-aware coalesce behavior (_ACCUM packing, ratio partner co-location) and gfx115x policy activation.
projects/rocprofiler-compute/src/utils/utils_counter_defs.py Add extract_metric_formula_hw_counters() to support formula-only counter extraction for coalescing decisions.
projects/rocprofiler-compute/src/rocprof_compute_soc/soc_base.py Use canonical arch for grouping policy lookup, switch coalesce to formula-only extraction, and remove _ACCUM skip during greedy packing.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants