Skip to content

fix(walltime): handle skipped states in nvbench-walltime - #491

Open
v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/walltime-skipped-states
Open

v0ropaev wants to merge 1 commit into
NVIDIA:mainfrom
v0ropaev:fix/walltime-skipped-states

Conversation

@v0ropaev

Copy link
Copy Markdown

nvbench-walltime fails on any JSON file that has a skipped state. The JSON printer writes "summaries": null for those states, and get_measures() hands that None straight to filter(). Running the tool on the in-tree python/scripts/test_ref.json, which has skipped states such as Device=0 In=I8 Out=I8 in copy_type_conversion_sweep, exits with TypeError: 'NoneType' object is not iterable at nvbench_walltime.py line 97.

Guarding the None alone is not enough. get_measures() only returns the measures it actually found, so a skipped state gives {}, and append_measure_values() then hits KeyError: 'cold' because it indexes every active measure for every row. The change reads state.get("summaries") or [], the same guard nvbench_plot_bwutil.py already uses, and starts times from init_measures() so each measure is always present with 0.0. Skipped states show up as zero rows in the report.

I added python/test/test_nvbench_walltime.py. It writes a small JSON file with one skipped state and one measured state, runs main() with a stub tabulate that records the rows, and checks the configuration table. On main it fails with the TypeError. With only the or [] part it fails with KeyError: 'cold'. With the full change it passes. test_nvbench_compare.py and test_nvbench_tooling_deps.py also pass, and ruff 0.15.20 (check and format) and codespell 2.4.2 report nothing on the touched files.

I also ran python nvbench_walltime.py test_ref.json and the same for test_cmp.json from python/scripts with tabulate installed. Both exit 0 now. For test_ref.json the overview reads 03:08.374 total, 01:47.430 isolated and 01:20.943 batch, and skipped rows such as Device=0 In=I8 Out=I8 print 0.00% and a plain 0 in each time column, since tabulate reformats the numeric-looking "0.000" strings.

The JSON printer writes "summaries": null for a skipped state, because
it creates the key but never adds anything to it. get_measures() passed
that None straight to filter(), so nvbench-walltime failed with
"TypeError: 'NoneType' object is not iterable" on any file with a
skipped state. The in-tree python/scripts/test_ref.json is one of them.

Treating a null summaries list as empty was not enough on its own.
get_measures() only returned the measures it found, and the table code
indexes every active measure for every row, so the skipped row then
raised KeyError: 'cold'. Start from init_measures() so each measure is
always present, with 0.0 when the state has no walltime for it. Skipped
states now show up as zero rows.

Signed-off-by: Dmitry Voropaev <dy.voropaev@gmail.com>
@copy-pr-bot

copy-pr-bot Bot commented Oct 21, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator

Verified claimed unexpected behavior:

Log ``` (py313) opavlyk@ee09c48-lcedt:~/repos/nvbench$ nvbench-walltime python/scripts/test_ref.json Traceback (most recent call last): File "/home/opavlyk/miniforge/envs/py313/bin/nvbench-walltime", line 6, in sys.exit(main()) ~~~~^^ File "/home/opavlyk/miniforge/envs/py313/lib/python3.13/site-packages/cuda/bench/scripts/nvbench_walltime.py", line 377, in main file_data = consume_file(filename) File "/home/opavlyk/miniforge/envs/py313/lib/python3.13/site-packages/cuda/bench/scripts/nvbench_walltime.py", line 148, in consume_file bench_data = consume_benchmark(bench, file_root) File "/home/opavlyk/miniforge/envs/py313/lib/python3.13/site-packages/cuda/bench/scripts/nvbench_walltime.py", line 182, in consume_benchmark state_measures = get_measures(state) File "/home/opavlyk/miniforge/envs/py313/lib/python3.13/site-packages/cuda/bench/scripts/nvbench_walltime.py", line 97, in get_measures filter(lambda s: s["tag"] == measure_walltime_tag, summaries), None ~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: 'NoneType' object is not iterable ```

@oleksandr-pavlyk

Copy link
Copy Markdown
Collaborator

/ok to test cc8fb51

This branch has not been deployed

No deployments
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.

2 participants