Repository navigation
Fix device sections and partial-comparison crash in nvbench_compare.py - #492
Open
MaxFreedomPollard wants to merge 1 commit into
Open
MaxFreedomPollard wants to merge 1 commit into
MaxFreedomPollard wants to merge 1 commit into
Conversation
compare_benches() loops over the compare benchmark's devices, but the inner loop walked every state of every device and then looked up the reference device through the `ref_state` variable left over from the last loop iteration. As a result: - With results from more than one GPU, every "## [id] name" section listed the states of all GPUs, sections were labelled with the device of whichever state happened to be processed last (the bundled test_ref.json/test_cmp.json print "## [1] Quadro GP100 vs. [0] Quadro GV100" for device 0), and the summary counted each state once per device. - When the last compare state has no reference counterpart (for example the compare run sweeps an extra axis value), `ref_state` is None and the script crashed with "TypeError: 'NoneType' object is not subscriptable". Only compare the states that belong to the current device, as nvbench_compare_robust.py and nvbench_json_summary.py already do, and take the reference device from the states that produced rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
nvbench_compare.py(nvbench-compare-legacy) has two bugs incompare_benches(), both caused by the same loop:Results from more than one GPU are printed wrong. Each
## [id] namesection lists the states of all GPUs. Sections get the label of whichever state was processed last, and the summary counts every state once per device. The repo's own sample files show it:--plotalso gets 176 bars instead of 88. With--ignore-devices, device 0 is reported as[1] <ref GPU 1> vs. [0] <cmp GPU 0>.Crash when the last compare state has no reference state. A compare run that sweeps an extra axis value, such as
Elements[pow2]=[16,20,24]against a reference that has only[16,20], is a partial comparison (Allow partial comparison innvbench_compare.py#295). It fails with:Root cause
The loop
for cmp_device_id in cmp_device_ids:walks every state without checkingcmp_state["device"]. Afterwards, the reference device comes fromref_state, which is whatever the last loop iteration left behind. That value can be another device's state, orNonewhen the last compare state was skipped as unmatched. The per-device loop has never filtered states by device. Theref_state["device"]lookup was added with--ignore-devices(#297).Fix
nvbench_compare_robust.pyandnvbench_json_summary.pyalready use.The change is 4 lines in
compare_benches(). Output for single-GPU runs is the same, except that the crash above is gone.Verification
python/test/test_nvbench_compare.py: per-device sections, and a trailing compare state with no reference state. Both fail onmain, one with the wrong header and one with theTypeError, and both pass with this change. They use a faketabulate, like the robust-compare tests, so they also pass on Python 3.10 without thecompareextra installed.pytest python/test/test_nvbench_compare.py python/test/test_nvbench_tooling_deps.py python/test/test_nvbench_compare_robust.py: 181 passed.test_ref.json/test_cmp.json, the output now has## [0] Quadro GV100and## [1] Quadro GP100sections withTotal Matches: 88. The multiset of comparison rows matches one section of the old output.--plotgets 88 entries.--ignore-deviceslabels each section[n] ref vs. [n] cmp.ruff check,ruff format --check(v0.15.20, the pre-commit pin) andcodespellpass.🤖 Generated with Claude Code