feat: Add Ising analysis and atomic visualization features (#58 #59)#71
Merged
yhteoh merged 4 commits intoOpenQuantumDesign:uhack_ising_and_visualizationfrom Jun 16, 2025
Conversation
… introduces an analysis pass to check if an AnalogGate implements an Ising-like Hamiltonian. The analysis verifies: - Only qubit registers are used. - Hamiltonian is composed of weight-2 Pauli strings (or weight-1/0). - Coefficients are time-independent. It also extracts coupling matrices (XX, YY, ZZ, XY, XZ, YZ) for valid Ising-like Hamiltonians. Includes unit tests for various valid and invalid cases. Closes OpenQuantumDesign#59
…visualization tool to plot energy level diagrams (Grotrian-like) for Ion instances from the atomic interface. The function generate_energy_level_plot takes an Ion object and produces a matplotlib figure showing its energy levels grouped by orbital quantum number and the transitions between them. Matplotlib has been added as a project dependency. Closes OpenQuantumDesign#58
…t introduces two complementary features for quantum system analysis: 1. Ising Hamiltonian Analysis (OpenQuantumDesign#59): - Analyzes AnalogGate for Ising-like properties - Extracts coupling matrices for Pauli interactions (XX, YY, ZZ, XY, XZ, YZ) - Validates qubit-only, weight-2, time-independent constraints - Includes comprehensive unit tests 2. Atomic Energy Level Visualization (OpenQuantumDesign#58): - Generates Grotrian-like diagrams for Ion instances - Plots energy levels grouped by orbital quantum number - Shows transitions between energy levels with customizable styling - Supports various plot customization options Both features integrate seamlessly with the existing oqd-core infrastructure. Matplotlib dependency added for visualization support. Closes OpenQuantumDesign#58 OpenQuantumDesign#59
This was referenced Jun 16, 2025
c712887
into
OpenQuantumDesign:uhack_ising_and_visualization
15 checks passed
This was referenced Jun 16, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
issue 58 & 59
What is the current behavior? (You can also link to an open issue here)
What is the new behavior (if this is a feature change)?
tested to pass ruff tests, same code of the two PRs merged in one PR that was tested locally to pass the ruff tests
Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
Other information:
closes #58
closes #59
Summary
This PR combines two complementary features for quantum system analysis and visualization:
AnalogGateimplements an Ising-like Hamiltonian #59) - Analyzes AnalogGate for Ising-like propertiesAtomicobjects #58) - Generates Grotrian-like diagrams for Ion instancesWhy Combined PR?
These two features are being submitted together because:
src/oqd_core/__init__.py,src/oqd_core/compiler/analog/passes/__init__.py)each feature was submitted in it's PR, this one is combining them, no code change execept for combining and passing ruff tests
Features Added
1. Ising Hamiltonian Analysis (#59)
AnalogGateinstances to determine if they implement Ising-like Hamiltonians2. Atomic Energy Level Visualization (#58)
Ioninstancesmatplotlibas a project dependencyTesting Status
Files Changed
Core Infrastructure:
src/oqd_core/__init__.py- Added visualizations module importsrc/oqd_core/compiler/analog/passes/__init__.py- Added Ising analysis exportpyproject.toml- Added matplotlib dependencyIsing Analysis Feature:
src/oqd_core/compiler/analog/passes/ising_analysis.py- Main analysis logicsrc/oqd_core/compiler/analog/passes/ising_types.py- Data structurestests/test_analog/test_ising_analysis.py- Comprehensive test suiteVisualization Feature:
src/oqd_core/visualizations/__init__.py- Package initializationsrc/oqd_core/visualizations/atomic.py- Plotting implementationUsage Examples
Ising Analysis
from oqd_core.compiler.analog.passes import analyze_ising_gate
from oqd_core.interface.analog import AnalogGate, OperatorKron, PauliX
gate = AnalogGate(hamiltonian=OperatorKron(op1=PauliX(), op2=PauliX()))
result = analyze_ising_gate(gate)
print(f"Is Ising-like: {result.is_ising_like}")
print(f"XX coupling: {result.coupling_matrices.XX}")
Visualization
from oqd_core.visualizations import generate_energy_level_plot
from oqd_core.interface.atomic import Ion, Level, Transition
Create Ion with levels and transitions
ion = Ion(levels=[...], transitions=[...])
fig = generate_energy_level_plot(ion, figure={'figsize': (10, 8)})
fig.show()
some figs of the tests included