Open
Description
Issue Description
When following the PennyLane blog tutorial, I observed that the results differ based on when DisCoPy is installed.
- If LAMBEQ and DisCoPy are pre-installed before running the code, the final results are different from when DisCoPy is installed dynamically at the
"Initializing the model"
step. - There is a noticeable drop in accuracy when DisCoPy is pre-installed before execution.
- Uninstalling and reinstalling DisCoPy results in higher accuracy in a local environment, but in Google Colab, it produces the same results as if DisCoPy had not been uninstalled.
This suggests that pre-installing both LAMBEQ and DisCoPy might introduce unexpected interactions, affecting some processes.
This issue affects the reproducibility of quantum NLP models trained with LAMBEQ and PennyLane. If the model's accuracy depends on the installation timing of DisCoPy, it becomes difficult to ensure consistent training results.
Environment
Component | Version |
---|---|
Python Interpreter | 3.11.11 |
PyTorch | 2.5.1 |
PennyLane | 0.40.0 |
LAMBEQ | 0.4.3 |
DisCoPy | 1.2.0 |
- Installation Method: pip
Steps to Reproduce
Case 1: Installing DisCoPy During Execution
- Start with only
lambeq
installed:pip3 install torch torchvision torchaudio pip install pennylane pip install lambeq
- Run the tutorial code from the PennyLane blog tutorial.
- During the 'Initializing the model' step of the tutorial, install DisCoPy dynamically:
pip install "discopy>=1.1.0"
- Observe the final accuracy.
- Restart the kernel and re-run the code.
Case 2: Pre-installing DisCoPy
- Install all dependencies before running the code:
pip3 install torch torchvision torchaudio pip install pennylane pip install lambeq pip install "discopy>=1.1.0"
- Observe the final accuracy.
- Compare the results.
Expected Behavior
The results should be consistent regardless of whether DisCoPy is pre-installed or installed dynamically.
Reference Notebook
The following Jupyter Notebook contains the code from the PennyLane blog tutorial, provided here for reference.
qnlp_pennylane_blog.ipynb.zip
Metadata
Metadata
Assignees
Labels
No labels