Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ElementaryOpoerator.define override option #2419

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ikkoham
Copy link
Contributor

@ikkoham ikkoham commented Nov 26, 2024

Description

There are cases where we want to experiment with various definitions of the Hamiltonian and collapse operators.
Of course, it's possible to modify the id during execution or exploit lazy evaluation (I will mention this later), but these approaches don’t feel intuitive.
Therefore, I'd like to propose an option to allow overrides. By using this, users will be able to conduct experiments with different definitions more intuitively and effectively. Especially when developing with Jupyter Notebook, it’s quite inconvenient to have to restart the kernel every time we want to change a definition.

This proposal allows

ElementaryOperator.define(
    "operator",
    expected_dimensions=[n],
    create= lambda: operator1,
)
ElementaryOperator.define(
    "operator",
    expected_dimensions=[n],
    create= lambda: operator2,
    override=True,
)

Alternatives (Workaround)

Use different id.

ElementaryOperator.define(
    "operator1",
    expected_dimensions=[n],
    create= lambda: operator1,
)
ElementaryOperator.define(
    "operator2",
    expected_dimensions=[n],
    create= lambda: operator2,
)

Redefine the operator itself. (lazy evaluation)

ElementaryOperator.define(
    "operator",
    expected_dimensions=[n],
    create= lambda: operator,
)
operator = operator2

Copy link

copy-pr-bot bot commented Nov 26, 2024

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.

I, ikkoham <ikkoham@users.noreply.github.com>, hereby add my Signed-off-by to this commit: ef0c599

Signed-off-by: ikkoham <ikkoham@users.noreply.github.com>
@schweitzpgi schweitzpgi added the python-lang Anything related to the Python CUDA Quantum language implementation label Dec 10, 2024
@schweitzpgi
Copy link
Collaborator

schweitzpgi commented Dec 18, 2024

/ok to test

Command Bot: Processing...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python-lang Anything related to the Python CUDA Quantum language implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants