Skip to content

Unexpected Results Depending on DisCoPy Installation Timing #207

Open
@SiyoonKIM

Description

@SiyoonKIM

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

  1. Start with only lambeq installed:
    pip3 install torch torchvision torchaudio
    pip install pennylane
    pip install lambeq
  2. Run the tutorial code from the PennyLane blog tutorial.
  3. During the 'Initializing the model' step of the tutorial, install DisCoPy dynamically:
    pip install "discopy>=1.1.0"
  4. Observe the final accuracy.
    Image
  5. Restart the kernel and re-run the code.

Case 2: Pre-installing DisCoPy

  1. Install all dependencies before running the code:
    pip3 install torch torchvision torchaudio
    pip install pennylane
    pip install lambeq
    pip install "discopy>=1.1.0"
  2. Observe the final accuracy.
    Image
  3. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions