Skip to content

fix(qiskit): Update AerSampler import to SamplerV2 for Qiskit compatibility#312

Open
yurekami wants to merge 1 commit into
mit-han-lab:mainfrom
yurekami:fix/issue-303-samplerv2-import
Open

fix(qiskit): Update AerSampler import to SamplerV2 for Qiskit compatibility#312
yurekami wants to merge 1 commit into
mit-han-lab:mainfrom
yurekami:fix/issue-303-samplerv2-import

Conversation

@yurekami
Copy link
Copy Markdown

Summary

Fixes #303

The qiskit_aer.primitives.Sampler class has been deprecated in newer Qiskit versions, and its constructor signature changed, causing the error:

Sampler.__init__() got an unexpected keyword argument 'options'

This PR updates the import to use SamplerV2 as recommended by @zkysfls in issue #303.

Changes

  • Updated import from from qiskit_aer.primitives import Sampler as AerSampler to from qiskit_aer.primitives import SamplerV2 as AerSampler
  • Updated logger message to reflect AerSamplerV2
  • Removed commented-out duplicate import

Why SamplerV2?

According to Qiskit Aer documentation, SamplerV2:

  • Supports the options parameter with backend_options (matching our existing code)
  • Supports the seed parameter (matching our existing code)
  • Is the recommended primitive for Qiskit Aer going forward

Backward Compatibility

The existing code already uses the SamplerV2-compatible interface:

self.sampler = AerSampler(options={"backend_options": backend_opts}, seed=self.seed_simulator)

By aliasing SamplerV2 as AerSampler, no other code changes are required.

Test plan

  • Verify import works with latest qiskit-aer (0.17.x)
  • Run basic quantum circuit simulation
  • Test with noise model enabled

🤖 Generated with Claude Code

…bility

Fixes mit-han-lab#303

The old qiskit_aer.primitives.Sampler class has been deprecated and its
constructor signature changed in newer Qiskit versions, causing the error:
"Sampler.__init__() got an unexpected keyword argument 'options'"

This change updates the import to use SamplerV2, which:
- Supports the options parameter with backend_options
- Is the recommended primitive for Qiskit Aer going forward
- Maintains backward compatibility with existing code since we alias it as AerSampler

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sampler.__init__() got an unexpected keyword argument 'options'

1 participant