docs: add Qiskit code validation IVR example#576
docs: add Qiskit code validation IVR example#576ajbozarth merged 8 commits intogenerative-computing:mainfrom
Conversation
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🟢 Enforce conventional commitWonderful, this rule succeeded.Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
|
This is a work in progress example that I adapted from a notebook by @vabarbosa We are still in the process of optimizing it, currently all the example prompts succeed on the two larger models, but when run on the small model they only success occasionally with a higher loop budget. |
44e7b5a to
6eef1d2
Compare
Add comprehensive example demonstrating Instruct-Validate-Repair pattern for Qiskit quantum computing code generation with external validation. Features: - Pre-condition validation (prompt and input code) - Post-condition validation using flake8-qiskit-migration - Automatic repair loop with detailed error feedback - Code extraction from markdown blocks - Real-world use case: fixing deprecated Qiskit APIs Updated README with example description and requirements. Co-authored-by: va <va@us.ibm.com> Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
6eef1d2 to
ed1e20b
Compare
jakelorocco
left a comment
There was a problem hiding this comment.
This is a really good example! Left a few comments.
I think you may need to specify installing another package:
QKT100: qiskit.Aer has moved; install separate `qiskit-aer` package and replace `qiskit.Aer` with `qiskit_aer.Aer`
QKT100: qiskit.execute has been removed; explicitly transpile and run the circuit instead (see https://docs.quantum.ibm.com/api/migration-guides/qiskit-1.0-features#execute)
pip install --upgrade qiskit qiskit-aer
And is there a reason we skip this example? I think it seems like an interesting enough one to showcase / highlight so we should make sure to keep it working. If you agree, please make sure to remove the skip and add the packages to the pyproject.
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
|
Feedback from Ismael: we should probably separate the helper functions out into a separate file |
That looks like a IVR response in the example, did you hit that yourself? What was the surrounding output?
The example is flaky and rarely passes on the small model, it requires the larger models (15-20GB download) to succeed, thus skip. If we manager to get it to consistently work with a small model I'll remove the skip (we plan to try this week) |
Makes sense on both points. For the first, I mistook the LLM generated pip command as part of the output for the error the validation printed. |
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
docs/examples/instruct_validate_repair/qiskit_code_validation.py
Outdated
Show resolved
Hide resolved
run ruff format Signed-off-by: va <va@us.ibm.com>
Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
- Move helper functions to validation_helpers.py - Reorganize into qiskit_code_validation/ subdirectory - Prepare structure for additional documentation Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
- Add comprehensive README with example prompts and troubleshooting - Move configuration inline for easier editing - Update parent README to document subdirectory - Add 'aer' to codespell ignore list for qiskit_aer package Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
I had Bob put together a summary of all the updates I made today and what is left to work on (apologizes it's wordy, I manually parsed it a bit already): Review Comments AddressedI've pushed 3 commits addressing the review feedback: Addressed
Not Addressed
Still to be addressed
Previously Addressed by @vabarbosa
|
Add concise documentation of planned enhancements: - MultiTurnStrategy integration for conversation-based repair - Grounding context to enable smaller models Addresses remaining work items from PR generative-computing#576 review discussion. Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
Per conversation with @vabarbosa and @psschwei I've added a future work section to the README to look into the review items focused on improving the effectiveness of the example. @vabarbosa will be looking into those but we decided they shouldn't block this example from merging. As such I've moved this out of draft. |
|
Nice! |
Fun fact I learned while writing the docs for this PR, if you want to have triple backticks in your code block you can use quadruple backticks for the outside block to prevent issues (https://github.com/ajbozarth/mellea/blob/dbc4b23571e459db399e6c2dc7c8d82956ccbece/docs/examples/instruct_validate_repair/qiskit_code_validation/README.md?plain=1#L141-L177) |
ea8d21e

Misc PR
Type of PR
Description
Add comprehensive example demonstrating Instruct-Validate-Repair patternfor Qiskit quantum computing code generation with external validation.
Features:
Updated README with example description and requirements.
Testing