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

Bug#600 qkt deepcopies kernel internally, fails with runtime primitives #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,8 @@

translations_list = [
("en", "English"),
("bn_BN", "Bengali"),
("fr_FR", "French"),
("hi_IN", "Hindi"),
("ja_JP", "Japanese"),
("ko_KR", "Korean"),
("ru_RU", "Russian"),
("es_UN", "Spanish"),
("ta_IN", "Tamil"),
("tr_TR", "Turkish"),
]
language = "en"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2021, 2023.
# (C) Copyright IBM 2021, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -13,7 +13,6 @@
"""Quantum Kernel Trainer"""
from __future__ import annotations

import copy
from functools import partial
from typing import Sequence

Expand Down Expand Up @@ -198,13 +197,17 @@ def fit(
msg = "Quantum kernel cannot be fit because there are no user parameters specified."
raise ValueError(msg)

# Bind inputs to objective function
output_kernel = copy.deepcopy(self._quantum_kernel)

# Randomly initialize the initial point if one was not passed
if self._initial_point is None:
self._initial_point = algorithm_globals.random.random(num_params)

# Bind inputs to objective function
output_kernel = type(self._quantum_kernel)(
feature_map=self._quantum_kernel.feature_map,
training_parameters=self._quantum_kernel.training_parameters,
)
output_kernel.assign_training_parameters(parameter_values=self.initial_point)

# Perform kernel optimization
loss_function = partial(
self._loss.evaluate, quantum_kernel=self.quantum_kernel, data=data, labels=labels
Expand Down