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

backend.target_history() caches backend properties #1956

Closed
jyu00 opened this issue Oct 1, 2024 · 2 comments · Fixed by #1957
Closed

backend.target_history() caches backend properties #1956

jyu00 opened this issue Oct 1, 2024 · 2 comments · Fixed by #1957
Assignees
Labels
bug Something isn't working
Milestone

Comments

@jyu00
Copy link
Collaborator

jyu00 commented Oct 1, 2024

Describe the bug

backend.target_history() calls _get_properties():

def target_history(self, datetime: Optional[python_datetime] = None) -> Target:
"""A :class:`qiskit.transpiler.Target` object for the backend.
Returns:
Target with properties found on `datetime`
"""
self._get_properties(datetime=datetime)

which saves the properties of that given timestamp as _properties:

def _get_properties(self, datetime: Optional[python_datetime] = None) -> None:
"""Gets backend properties and decodes it"""
if datetime:
datetime = local_to_utc(datetime)
if datetime or not self._properties:
api_properties = self._api_client.backend_properties(self.name, datetime=datetime)
if api_properties:
backend_properties = properties_from_server_data(api_properties)
self._properties = backend_properties

which means if I do

old_history = backend.target_history(datetime=<1 year ago>)
props = backend.properties()

I'll actually get old_history back in my second call.

Steps to reproduce

Expected behavior

Historical properties should not be cached. backend.properties() does this correctly.

Suggested solutions

Don't cache properties if datetime is provided.

Additional Information

  • qiskit-ibm-runtime version:
  • Python version:
  • Operating system:
@jyu00 jyu00 added the bug Something isn't working label Oct 1, 2024
@kt474
Copy link
Member

kt474 commented Oct 1, 2024

Should the target also not be cached when calling target_history()? Currently, calling backend.target after backend.target_history() would still return the old target.

@kt474 kt474 self-assigned this Oct 1, 2024
@jyu00
Copy link
Collaborator Author

jyu00 commented Oct 10, 2024

Should the target also not be cached when calling target_history()? Currently, calling backend.target after backend.target_history() would still return the old target.

Right. Backend properties should not be cached if an older copy is requested.

@kt474 kt474 added this to the 0.33.0 milestone Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants