Skip to content

Conversation

@phantmgx
Copy link

fixes #3
This pull request adds a flexible, modular circuit composition system to the QPIXL framework.

What's Included

  • qpixl_module.py: A clean wrapper to generate QPIXL-encoded quantum circuits
  • quantum_composer.py: A reusable system to compose circuits using merge, sequential, or hardware-aware strategies
  • QPIXL_demo_composer_extension.ipynb: Full demo with tests including:
    • Image encoding + algorithm circuits
    • Audio-derived QPIXL circuits
    • Gate injection and compression comparison
    • Hardware-aware transpilation

Key Features

  • Works with Qiskit 2.0+
  • Fully modular (QPIXLModule, QiskitCircuitModule, QuantumComposer)
  • Easily extensible to future integration rules
  • All code follows strict mode and validated with multiple tests

Where Changes Were Made

  • Files added to QPIXL/qiskit/
  • Notebook placed in root as QPIXL_demo_composer_extension.ipynb

Please see the notebook for outputs and circuit diagrams.

@danielbultrini
Copy link
Contributor

Hey phantmgx, I can see that you worked quite hard on this! But the examples you showed don't really have the algorithm circuit interacting with the qpixl decoding!
Do you think you could add these quickly?

@danielbultrini danielbultrini marked this pull request as draft June 11, 2025 11:09
@phantmgx
Copy link
Author

phantmgx commented Jun 11, 2025

yes sure
i have added the updated test please check . Thank you

…RY injection)

The test is at the very last .
@danielbultrini
Copy link
Contributor

Hey Phantmgx, great work on all of your submissions, I was going through this one, and I could not quite see how I could do something like this, where you slice both circuits and add connection rules inbetween them. If you mange to do this (no-one else has yet) then you would be much more likely to win.
Screenshot 2025-06-12 at 13 08 13

@phantmgx
Copy link
Author

Sure i will try it , thanks!

@phantmgx
Copy link
Author

@danielbultrini I have implemented dual-slicing of both the QPIXL circuit and the algorithm circuit, with support for:

  • Interleaving slices of both circuits

  • Customizable connection rules (cx, cz, swap) between sliced segments

  • Configurable slice_size, connection_map, etc.

  • Example tests added:
    -Cross-sliced entangled circuits
    -Sliced algorithm interleaved into QPIXL
    -Multi-qubit connection mappings
    -Full composer-based integration

These are all demonstrated in the final notebook (QPIXL_demo_composer_extension_v3.ipynb) using the "slice" rule in quantum_composer.

Let me know if you’d like any of them highlighted further!

@danielbultrini danielbultrini marked this pull request as ready for review June 13, 2025 12:23
@danielbultrini
Copy link
Contributor

Okay, it took me a while, but I think I finally figured out that the last cell has exactly what I was envisioning. Thanks a lot for clearing that up! Could I ask you to clean everything up a bit (just one notebook with your examples) and ensure that the examples used in your cells aren't extremely long (for example your cell under # Test 7: Combined Image, Audio, and Algorithm with Entanglement) is impossible to scroll through, since it is an example you can cut the audio numpy array to be just the first 16 data points or something.

@danielbultrini danielbultrini marked this pull request as draft June 13, 2025 12:33
@danielbultrini
Copy link
Contributor

Also, I noticed that if I do

image_data = np.linspace(0, np.pi / 2, 16)
qpixl_mod = QPIXLModule(image_data, name="QPIXLDATA")

qpixl_mod2 = QPIXLModule(image_data, name="QPIXLDATA").get_circuit()
algo_mod = QiskitCircuitModule(qpixl_mod2, name="ALGO")

# 3. Composer with dual-slice + entanglement
composer = QuantumComposer([qpixl_mod, algo_mod])
combined = composer.combine(
    rule="slice",
    slice_size=4,
    connection_rule="cz",
    connection_map=[(0, 0)]  # Connect data qubit 1 to algo qubit 0
)

# 4. Draw result
combined.draw("mpl")```
I get something like this attached image
![image](https://github.com/user-attachments/assets/d12f6e45-97eb-4cd7-8f14-ad2a0b5ee1a8)
Which has qubits 5 and 11 that shouldn't be there. It would be great if you could remove those, thanks! I think they must be created by accident in QPIXLModule. 

@phantmgx
Copy link
Author

Sure , I'll get them removed , thanks

@phantmgx
Copy link
Author

@danielbultrini I have resolved the Ghost qubit issue is fully resolved using a patched QPIXLModule.get_circuit
I have added a test at the very end to confirm the fix .
I have also shortened the output circuits as you suggested.

@danielbultrini danielbultrini marked this pull request as ready for review June 16, 2025 07:24
@danielbultrini
Copy link
Contributor

Hey @phantmgx , sadly the ghost qubits still appear to be there - I really appreciate your contributions on all the submissions, so I feel quite bad saying this, but a competitor did it better. However, we would like to award you with a honorable mention and a prize separately for your efforts! Please send me any handle/social media you would like us to shout you out with in our post soon.

@phantmgx
Copy link
Author

phantmgx commented Jun 16, 2025

@danielbultrini unfortunately i dont have any linkedin account yet , for now you can use my github account . Thank you!

@phantmgx
Copy link
Author

@danielbultrini thank you for your generosity! On another note, could you let me know the process for receiving the prize you mentioned?

@danielbultrini
Copy link
Contributor

@phantmgx please share your email with us, and we will contact you.

@phantmgx
Copy link
Author

@danielbultrini I just wanted to follow up regarding the prize you mentioned. I had shared my email ID as requested, so just wanted to check in in case something was missed.
Looking forward to hearing from you and thank you again

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.

Make a function that takes a circuit as an input and mixes it with the QPIXL input.

2 participants