roofline: emit raw per-tensor data for DDR byte accounting (single + fused) - #48
Merged
Merged
Conversation
roberteg16
marked this pull request as ready for review
July 14, 2026 07:40
mgehre-amd
reviewed
Jul 14, 2026
mgehre-amd
reviewed
Jul 14, 2026
Fused rows previously carried a group HBM byte total computed in-tree. Instead, emit raw per-fused-node facts -- each tensor's byte count, a storage id (view_src root, so aliasing is visible) and a source tensor id -- and let the consumer (rocm-scripts tools/roofline) compute external in/out. This lets the consumer apply the exclusion policy it owns: skip no-op views (VIEW/RESHAPE), drop in-place destinations (e.g. SET_ROWS/CPY writing their own dst), exclude internal tensors, and dedup reads by source. It also matches how non-fused rows already work (producer reports facts, consumer sums). Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Non-fused rows already emit dst/src byte counts; also emit the dst storage id, per-source ids and per-source storage ids (all already captured by fill_head_record). This lets the consumer apply the same in-place-destination rule to single kernels as to fused ones -- e.g. a standalone CPY or SET_ROWS no longer has its write target (dst passed in as a source) double-counted. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Address review: define "tensor id" (a ggml_tensor's address, dedup key) and "storage id" (the view_src-root buffer address, shared by aliasing tensors) at the op_record fields, and drop the vague word "facts" from the surrounding comments in favour of concrete wording. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
Address review: the emitted keys and op_record members used cryptic names. Rename dst_sid -> dst_storage_id, src_ids -> src_tensor_ids, src_sids -> src_storage_ids (both the C++ members and the JSON keys). No behavior change. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
roberteg16
force-pushed
the
rogarcia.roofline-fused-raw-facts
branch
from
July 14, 2026 12:09
7928cfe to
43efae8
Compare
Extend the op_record comment: the storage id alone is not enough. The storage id (buffer identity) drives the view/in-place/internal exclusions; the tensor id drives read dedup. They diverge when distinct sources alias one buffer (e.g. two ops reading the two halves of a tensor: one storage id, two tensor ids) -- deduping by storage id would undercount, so dedup keys on the tensor id. Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
mgehre-amd
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The HIP roofline profiler emits raw per-tensor data instead of computing DDR byte totals in-tree. For every tensor — on fused nodes and on the top-level (single-op) row — it reports: byte count, a storage id (the
view_srcroot, so the consumer sees which tensors alias the same buffer), and a source tensor id. The consumer (rocm-scriptstools/roofline) computes external in/out from those facts.Improvements
VIEW/RESHAPE), in-place copy/scatter destinations (CPY/SET_ROWSpass their own output buffer in as a source — written, not read), and internal tensors. This fixes real double-counts — the KV-cache write was counted twice, in both fused and standaloneSET_ROWS/CPY.Two commits: (1) raw facts for fused nodes + drop the in-tree fused computation; (2) emit the same ids on non-fused rows so single kernels get the same treatment.
Companion consumer PR: FaaSApps/rocm-scripts#682.
A/B on Qwen2.5-3B / gemma-3-12B / Qwen3.6-35B: only view / in-place-destination cases change (e.g.
SET_ROWS−49%, standaloneCPY−33%); every other row is byte-identical.