cuda-quantum icon indicating copy to clipboard operation
cuda-quantum copied to clipboard

docs/notebook_validation.py: update nbconvert logs

Open mitchdz opened this issue 9 months ago • 27 comments

Improve the timing logs for the docker container validation during nbconvert.

This is because in CI, the list of timings is printed after the nbconvert is done, so you see something like:

...
[NbConvertApp] Converting notebook applications/python/readout_error_mitigation.ipynb to notebook
[NbConvertApp] Writing 187307 bytes to applications/python/readout_error_mitigation.nbconvert.ipynb
[NbConvertApp] Converting notebook applications/python/deutsch_jozsa.ipynb to notebook
[NbConvertApp] Writing 10396 bytes to applications/python/deutsch_jozsa.nbconvert.ipynb
Time taken for nbconvert: 6.10 seconds
Time taken for nbconvert: 7.83 seconds
Time taken for nbconvert: 10.72 seconds
Time taken for nbconvert: 3.18 seconds
Time taken for nbconvert: 7.33 seconds
...

See: https://github.com/NVIDIA/cuda-quantum/actions/runs/13690948087/job/38285994246#step:5:1387

Which makes it hard to see what took a long time.

mitchdz avatar Mar 06 '25 17:03 mitchdz

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.

copy-pr-bot[bot] avatar Mar 06 '25 17:03 copy-pr-bot[bot]

Let's hold off on merging this in, there's some higher priority PRs in the pipeline for release.

mitchdz avatar Mar 06 '25 18:03 mitchdz

@mitchdz Is this PR good to go now?

sacpis avatar Mar 21 '25 23:03 sacpis

Let's send it.

mitchdz avatar Mar 21 '25 23:03 mitchdz

Actually let me add your suggestion real quick since we don't have a release to squeeze this into.

mitchdz avatar Mar 21 '25 23:03 mitchdz

There we go. Added the os.remove into a finally block.

mitchdz avatar Mar 21 '25 23:03 mitchdz

/ok to test

Command Bot: Processing...

mitchdz avatar Mar 21 '25 23:03 mitchdz

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Mar 22 '25 01:03 github-actions[bot]

Thanks @mitchdz. Mind adding the output of validation script in the description. So that it is easy to see before and after.

sacpis avatar Mar 25 '25 23:03 sacpis

Sure thing. It outputs a little differently in the terminal when ran manually due to how the github logs run, but here's a manual run:

$ docker run --rm --gpus all --network host -it -v /home/mdzurick:/host/ nvcr.io/nvidia/quantum/cuda-quantum:cu12-0.10.0
$ git clone https://github.com/mitchdz/cuda-quantum.git -b mitch/update-docker-validation-logs
$ cd cuda-quantum/docs
# modify notebook_validation.py to use notebook_filenames = ['sphinx/applications/python/hybrid_qnns.ipynb', 'sphinx/applications/python/qaoa.ipynb', 'sphinx/applications/python/deutschs_algorithm.ipynb', 'sphinx/applications/python/quantum_transformer.ipynb']
$ cudaq@2570547-lcedt:~/cuda-quantum/docs$ echo "nvidia" | python3 notebook_validation.py
[NbConvertApp] Converting notebook sphinx/applications/python/qaoa.ipynb to notebook
[NbConvertApp] Writing 20945 bytes to sphinx/applications/python/qaoa.nbconvert.ipynb
Time taken for nbconvert : 2.97 seconds for 'sphinx/applications/python/qaoa.ipynb'
[NbConvertApp] Converting notebook sphinx/applications/python/deutschs_algorithm.ipynb to notebook
[NbConvertApp] Writing 16516 bytes to sphinx/applications/python/deutschs_algorithm.nbconvert.ipynb
Time taken for nbconvert : 2.58 seconds for 'sphinx/applications/python/deutschs_algorithm.ipynb'
Success! The following notebook(s) executed successfully:
sphinx/applications/python/qaoa.ipynb sphinx/applications/python/deutschs_algorithm.ipynb
::warning::Skipped validation for the following notebook(s):
quantum_transformer.ipynb hybrid_qnns.ipynb

mitchdz avatar Mar 26 '25 00:03 mitchdz

In the github CI/CD logs, it will look like this:

[NbConvertApp] Converting notebook sphinx/applications/python/qaoa.ipynb to notebook
[NbConvertApp] Writing 20945 bytes to sphinx/applications/python/qaoa.nbconvert.ipynb
[NbConvertApp] Converting notebook sphinx/applications/python/deutschs_algorithm.ipynb to notebook
[NbConvertApp] Writing 16516 bytes to sphinx/applications/python/deutschs_algorithm.nbconvert.ipynb
Time taken for nbconvert : 2.97 seconds for 'sphinx/applications/python/qaoa.ipynb'
Time taken for nbconvert : 2.58 seconds for 'sphinx/applications/python/deutschs_algorithm.ipynb'
Success! The following notebook(s) executed successfully:
sphinx/applications/python/qaoa.ipynb sphinx/applications/python/deutschs_algorithm.ipynb
::warning::Skipped validation for the following notebook(s):
quantum_transformer.ipynb hybrid_qnns.ipynb

mitchdz avatar Mar 26 '25 00:03 mitchdz

In the github CI/CD logs, it will look like this:

[NbConvertApp] Converting notebook sphinx/applications/python/qaoa.ipynb to notebook
[NbConvertApp] Writing 20945 bytes to sphinx/applications/python/qaoa.nbconvert.ipynb
[NbConvertApp] Converting notebook sphinx/applications/python/deutschs_algorithm.ipynb to notebook
[NbConvertApp] Writing 16516 bytes to sphinx/applications/python/deutschs_algorithm.nbconvert.ipynb
Time taken for nbconvert : 2.97 seconds for 'sphinx/applications/python/qaoa.ipynb'
Time taken for nbconvert : 2.58 seconds for 'sphinx/applications/python/deutschs_algorithm.ipynb'
Success! The following notebook(s) executed successfully:
sphinx/applications/python/qaoa.ipynb sphinx/applications/python/deutschs_algorithm.ipynb
::warning::Skipped validation for the following notebook(s):
quantum_transformer.ipynb hybrid_qnns.ipynb

Just a question, can we make it like this one?

[NbConvertApp] Converting notebook sphinx/applications/python/qaoa.ipynb to notebook
[NbConvertApp] Writing 20945 bytes to sphinx/applications/python/qaoa.nbconvert.ipynb
Time taken for nbconvert : 2.97 seconds for 'sphinx/applications/python/qaoa.ipynb'

sacpis avatar Mar 26 '25 00:03 sacpis

I'm not exactly sure why the output is buffered like that. I assume it is because the Github CI buffers the output of each command and the output of NBConvert separately.

At first I thought because it's parallel threaded, but that doesn't seem to be the case.

mitchdz avatar Mar 26 '25 01:03 mitchdz

/ok to test

Command Bot: Processing...

mitchdz avatar Apr 09 '25 17:04 mitchdz

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Apr 09 '25 20:04 github-actions[bot]

/ok to test 2791ccd

Command Bot: Processing...

mitchdz avatar Apr 24 '25 21:04 mitchdz

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Apr 24 '25 22:04 github-actions[bot]

/ok to test

Command Bot: Processing...

mitchdz avatar Apr 28 '25 15:04 mitchdz

/ok to test

@mitchdz, there was an error processing your request: E1

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/1/

copy-pr-bot[bot] avatar Apr 28 '25 15:04 copy-pr-bot[bot]

/ok to test 492d9826f746e1a1fb0691f0dfb0328377157712

Command Bot: Processing...

mitchdz avatar Apr 28 '25 20:04 mitchdz

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions[bot] avatar Apr 28 '25 22:04 github-actions[bot]

/ok to test 7907d8b

Command Bot: Processing...

mitchdz avatar May 14 '25 21:05 mitchdz

Just a quick check. Are we now seeing the output in the following format?

[NbConvertApp] Converting notebook sphinx/applications/python/qaoa.ipynb to notebook
[NbConvertApp] Writing 20945 bytes to sphinx/applications/python/qaoa.nbconvert.ipynb
Time taken for nbconvert : 2.97 seconds for 'sphinx/applications/python/qaoa.ipynb'

sacpis avatar May 14 '25 22:05 sacpis

Yes, it will look like that.

mitchdz avatar May 15 '25 15:05 mitchdz

Yes, it will look like that.

If the output is same as the one above then we are good to go here.

sacpis avatar May 15 '25 17:05 sacpis

/ok to test 39b566c

Command Bot: Processing...

mitchdz avatar May 15 '25 17:05 mitchdz

/ok to test fdd281e

Command Bot: Processing...

mitchdz avatar May 15 '25 19:05 mitchdz

/ok to test 70f812b

Command Bot: Processing...

mitchdz avatar May 23 '25 21:05 mitchdz

/ok to test bf462c5

Command Bot: Processing...

mitchdz avatar May 23 '25 22:05 mitchdz

/ok to test 98617ef

Command Bot: Processing...

mitchdz avatar May 27 '25 13:05 mitchdz