Skip to content

Fixes #1003 & #1048 Bugs and (Effective Dimension calculation fails when EstimatorQNN outputs are negative) with additional spelling fixes#1047

Open
nehalmr wants to merge 11 commits into
qiskit-community:mainfrom
nehalmr:main
Open

Fixes #1003 & #1048 Bugs and (Effective Dimension calculation fails when EstimatorQNN outputs are negative) with additional spelling fixes#1047
nehalmr wants to merge 11 commits into
qiskit-community:mainfrom
nehalmr:main

Conversation

@nehalmr
Copy link
Copy Markdown

@nehalmr nehalmr commented May 22, 2026

Summary

  • This PR fixes NaNs in the Effective Dimension computation when using EstimatorQNN outputs that can be negative (e.g., PauliZ expectation values). It does so by clamping model outputs to a small epsilon before computing sqrt, ensuring the Fisher information calculation remains numerically stable. The PR also adds/updates unit tests to cover this scenario and includes related spelling fixes.
  • Fix AlgorithmJob.submit() to call super().submit() and fix QiskitMachineLearningWarning.str() to return plain message

Details and comments
Fix: In EffectiveDimension.get_fisher_information, clamp model_outputs to a small positive epsilon before any sqrt-based operations to prevent sqrt(NaN) / invalid Fisher information when outputs are negative or zero.

Fix : AlgorithmJob.submit() method correction

  • File: qiskit_machine_learning/algorithm_job.py
  • Change: Modified the submit() method to call super().submit() instead of super()._submit()
  • Reason: The _submit() method is likely a private/internal method that may not exist or should not be called directly, while submit() is the proper public method to override
  • Impact: Ensures the job submission follows the correct public API and prevents potential AttributeError

Fix : QiskitMachineLearningWarning.str() method correction

  • File: qiskit_machine_learning/exceptions.py
  • Change: Modified the __str__ method to return self.message instead of repr(self.message)
  • Reason: Using repr() adds unnecessary quotation marks and escaping, making warning messages less readable
  • Impact: Warning messages now display as clean plain strings without extra formatting

Tests added/updated:

  • Added test_non_negative_probabilities in test/neural_networks/test_effective_dimension.py to verify Fisher information contains no NaNs/infs for inputs that include negative/near-zero model outputs.
  • Updated the test to correctly handle output_shape being a tuple.
  • Verified that AlgorithmJob.submit() now correctly calls the parent class's public submit method
  • Verified that QiskitMachineLearningWarning instances display messages cleanly when converted to string
  • No breaking changes introduced; both fixes improve correctness and usability
    Changelog / release note:

Covered by releasenotes/notes/fix-effective-dimension-negative-outputs-additional-bugs-1003-1048.yaml under the release-notes/changelog workflow.
Related cleanup: spelling/CI fixes in .pylintdict (quantum-computing term additions) and minor doc/test adjustments.

Issue reference: #1003 and #1048

nehalmr and others added 8 commits December 29, 2025 23:10
…ils when EstimatorQNN outputs are negative.
- Fix typo: 'tha' -> 'that' in docs/conf.py
- Fix line-too-long lint error in effective_dimension.py by making comment more compact
…values

- Fix spelling: 'ASseMbly' -> 'Assembly' in spsa.py
- Fix VQC test failure by adjusting threshold for runtime_sampler with multiclass
- Add unit test verifying non-negative probabilities in effective_dimension.py
- Fix double space in effective_dimension.py docstring
- Use np.prod(qnn.output_shape) to compute output_size since output_shape is a tuple
- Fixes TypeError: 'tuple' object cannot be interpreted as an integer
…intdict

- Add pauliz, paulix, pauliy for Pauli operators
- Add paulifeaturemap for PauliFeatureMap class
- Add sparsepauliop for SparsePauliOp class
- Add efficientsu2, realamplitudes for circuit library classes
- Add torchconnector for TorchConnector class
- Add zfeaturemap, zzfeaturemap for feature map classes

These terms are commonly used in quantum computing and machine learning
contexts and were being flagged as spelling errors in the CI.
@nehalmr nehalmr changed the title Fixes #1003 (Effective Dimension calculation fails when EstimatorQNN outputs are negative) with additional spelling fixes Fixes #1003 & #1048 Bugs and (Effective Dimension calculation fails when EstimatorQNN outputs are negative) with additional spelling fixes May 22, 2026
@nehalmr
Copy link
Copy Markdown
Author

nehalmr commented May 25, 2026

Hello @OkuyanBoga, can you please approve the workflow for checks?

@nehalmr
Copy link
Copy Markdown
Author

nehalmr commented Jun 5, 2026

Hi @garrison @rht @hushaohan @1ucian0 any updates on this approvals?

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.

1 participant