Skip to content

Conversation

Copy link

Copilot AI commented Jan 8, 2026

Motivation

Roofline data processing accesses kernel_objs dictionary without verifying the kernel exists, causing KeyError when roofline data references kernels absent from dispatch data. PC sampling already implements this check correctly.

Technical Details

Added kernel existence validation before accessing kernel_objs in roofline data loop (lines 146-151 in analysis_db.py):

  • Check if roofline_data.kernel_name exists in kernel_objs before access
  • Log warning and skip entry when kernel is missing
  • Mirrors existing pattern from PC sampling data handling (lines 166-171)
# Add roofline data points
for roofline_data in self._roofline_data_per_workload.get(
    workload_path, pd.DataFrame()
).itertuples():
    if roofline_data.kernel_name not in kernel_objs:
        console_warning(
            f"Kernel {roofline_data.kernel_name} from roofline data "
            "not found in dispatch data. Skipping roofline entry."
        )
        continue
    Database.get_session().add(
        orm.RooflineData(
            total_flops=roofline_data.total_flops,
            l1_cache_data=roofline_data.l1_cache_data,
            l2_cache_data=roofline_data.l2_cache_data,
            hbm_cache_data=roofline_data.hbm_cache_data,
            kernel=kernel_objs[roofline_data.kernel_name],
        )
    )

JIRA ID

N/A

Test Plan

  • Python syntax validation passed
  • CodeQL security scan: no alerts

Test Result

No issues found in automated checks.

Submission Checklist


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Address feedback on Analysis database v1.2.0 PR Add kernel existence check for roofline data to prevent KeyError Jan 8, 2026
Copilot AI requested a review from vedithal-amd January 8, 2026 17:10
@vedithal-amd vedithal-amd marked this pull request as ready for review January 8, 2026 17:13
@vedithal-amd vedithal-amd requested a review from a team as a code owner January 8, 2026 17:13
Copilot AI review requested due to automatic review settings January 8, 2026 17:13
@vedithal-amd vedithal-amd merged commit a572b2f into users/vedithal/rocprofiler-compute-analysis-db Jan 8, 2026
3 checks passed
@vedithal-amd vedithal-amd deleted the copilot/sub-pr-2526 branch January 8, 2026 17:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a defensive check to prevent KeyError exceptions when roofline data references kernels that don't exist in dispatch data. The fix mirrors an existing pattern already implemented for PC sampling data.

Key changes:

  • Added kernel existence validation before accessing kernel_objs dictionary in roofline data processing loop
  • Warning message logged and entry skipped when kernel is missing
Comments suppressed due to low confidence (1)

projects/rocprofiler-compute/src/rocprof_compute_analyze/analysis_db.py:34

  • Module 'utils.analysis_orm' is imported with both 'import' and 'import from'.
import utils.analysis_orm as orm

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vedithal-amd added a commit that referenced this pull request Jan 9, 2026
* Initial plan

* Add kernel existence check for roofline data to prevent KeyError

Co-authored-by: vedithal-amd <[email protected]>

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: vedithal-amd <[email protected]>
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