When attempting to run the trainer.fit method with the provided datasets and early stopping parameters, the following error is encountered:
CircuitNotRunError: Circuit corresponding to ResultHandle('1d68d2f5-60a4-48af-b771-51637cd791b3', 0, 3, 'null') has not been run by this backend instance.
This error occurs within the pytket library when trying to retrieve the result of a quantum circuit that has not been executed. The error is raised from the get_result method in the pytket backend.
Steps to Reproduce
Define train_dataset and val_dataset.
Initialize the trainer object.
Call the fit method on the trainer object with the following parameters:
Expected Behavior
The fit method should execute the training process without errors, utilizing the provided datasets and early stopping parameters.
Actual Behavior
The fit method raises a CircuitNotRunError, indicating that a quantum circuit corresponding to a specific ResultHandle has not been executed by the backend instance. This is followed by a KeyError when trying to access the result from the cache.
Error Traceback
---------------------------------------------------------------------------
CircuitNotRunError Traceback (most recent call last)
File c:\Users\enzok\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytket\extensions\qiskit\backends\aer.py:344, in _AerBaseBackend.get_result(self, handle, **kwargs)
343 try:
--> 344 return super().get_result(handle)
345 except CircuitNotRunError:
File c:\Users\enzok\AppData\Local\Programs\Python\Python311\Lib\site-packages\pytket\backends\backend.py:347, in Backend.get_result(self, handle, **kwargs)
346 return cast(BackendResult, self._cache[handle]["result"])
--> 347 raise CircuitNotRunError(handle)
CircuitNotRunError: Circuit corresponding to ResultHandle('1d68d2f5-60a4-48af-b771-51637cd791b3', 0, 3, 'null') has not been run by this backend instance.
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
Cell In[8], line 1
----> 1 trainer.fit(train_dataset, val_dataset,
2 early_stopping_criterion='acc',
3 early_stopping_interval=5,
4 minimize_criterion=False)
File c:\Users\enzok\AppData\Local\Programs\Python\Python311\Lib\site-packages\lambeq\training\quantum_trainer.py:204, in QuantumTrainer.fit(self, train_dataset, val_dataset, log_interval, eval_interval, eval_mode, early_stopping_criterion, early_stopping_interval, minimize_criterion, full_timing_report)
191 def fit(self,
192 train_dataset: Dataset,
...
356 "result"
357 ] = backres
359 return cast(BackendResult, self._cache[handle]["result"])
KeyError: ResultHandle('1d68d2f5-60a4-48af-b771-51637cd791b3', 1, 3, 'null')
When attempting to run the
trainer.fit
method with the provided datasets and early stopping parameters, the following error is encountered:This error occurs within the pytket library when trying to retrieve the result of a quantum circuit that has not been executed. The error is raised from the get_result method in the pytket backend.
Steps to Reproduce
Expected Behavior The fit method should execute the training process without errors, utilizing the provided datasets and early stopping parameters.
Actual Behavior The fit method raises a CircuitNotRunError, indicating that a quantum circuit corresponding to a specific ResultHandle has not been executed by the backend instance. This is followed by a KeyError when trying to access the result from the cache.
Error Traceback
Environment Python Version: 3.11 pytket Version: 1.32.0 lambeq Version: 0.4.3 Operating System: Windows
The code is shared on: https://github.com/enzokgomes/NLP-quantum-training