Downloads · 30 days
0
AIResAgTeam/quantum-nsn-integration
quantum-nsn-integration is a machine learning model from AIResAgTeam. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as cc-by-nc-sa-4.0.
Comprehensive integration of Nested Subspace Networks (NSNs) with LIMIT-Graph and REPAIR to enhance quantum benchmarking and multilingual edit reliability.
Downloads · 30 days
0
Access
Public
Updated Oct 23, 2025
Repo size
—
Likes
0
Public
Click a slice to open those files.
.py161 KB · 76%
From the Hugging Face model README
Comprehensive integration of Nested Subspace Networks (NSNs) with LIMIT-Graph and REPAIR to enhance quantum benchmarking and multilingual edit reliability.
This integration implements three key stages:
nsn_integration/
├── __init__.py # Package initialization
├── backend_aware_rank_selector.py # Stage 1: Backend-aware rank selection
├── multilingual_nsn_evaluator.py # Stage 2: Multilingual evaluation
├── nsn_leaderboard.py # Stage 3: Contributor challenges
├── nsn_dashboard.py # Visualization dashboard
├── limit_graph_nsn_integration.py # LIMIT-Graph integration
├── demo_complete_nsn_integration.py # Complete demo
└── README.md # This file
from quantum_integration.nsn_integration import BackendAwareRankSelector, BackendType
# Create selector
selector = BackendAwareRankSelector()
# Get rank recommendation
recommendation = selector.get_rank_recommendation(
backend_type=BackendType.IBM_WASHINGTON,
compute_budget=1e8,
min_reliability=0.85
)
print(f"Recommended Rank: {recommendation['recommended_rank']}")
print(f"Expected Reliability: {recommendation['expected_reliability']:.3f}")
print(f"Rationale: {recommendation['rationale']}")
# Compute FLOPs vs reliability curve
curve = selector.compute_flops_vs_reliability(BackendType.IBM_WASHINGTON)
from quantum_integration.nsn_integration import MultilingualNSNEvaluator
# Create evaluator
evaluator = MultilingualNSNEvaluator()
# Evaluate single language
result = evaluator.evaluate_language_edit(
language='indonesian',
rank=64
)
print(f"Accuracy: {result.edit_accuracy:.3f}")
print(f"Uncertainty: {result.uncertainty:.3f}")
# Comprehensive analysis
languages = ['english', 'chinese', 'indonesian', 'swahili']
analysis = evaluator.analyze_rank_language_matrix(languages)
# Get uncertainty weights for balanced training
weights = evaluator.compute_uncertainty_weights(languages)
# Analyze subspace containment
containment = evaluator.evaluate_subspace_containment(
source_lang='indonesian',
target_lang='english',
rank=64
)
print(f"Containment Score: {containment.containment_score:.3f}")
from quantum_integration.nsn_integration import NSNLeaderboard
# Create leaderboard
leaderboard = NSNLeaderboard()
# Create challenge
challenge = leaderboard.create_challenge(
challenge_id="multilingual_edit_2025",
title="Multilingual Model Editing Challenge",
description="Optimize edit accuracy across languages and ranks",
languages=['english', 'chinese', 'indonesian'],
ranks=[8, 16, 32, 64, 128, 256]
)
# Submit edit
rank_results = {
8: {'accuracy': 0.75, 'uncertainty': 0.20, 'flops': 6.4e5, 'efficiency': 0.012},
32: {'accuracy': 0.88, 'uncertainty': 0.12, 'flops': 1.02e7, 'efficiency': 0.009},
128: {'accuracy': 0.95, 'uncertainty': 0.05, 'flops': 1.64e8, 'efficiency': 0.006}
}
submission = leaderboard.submit_edit(
challenge_id="multilingual_edit_2025",
contributor_id="contributor_001",
language="english",
edit_description="Optimized factual correction",
rank_results=rank_results
)
# Get leaderboard
rankings = leaderboard.get_leaderboard("multilingual_edit_2025")
# Compute Pareto frontier
frontier = leaderboard.compute_pareto_frontier("multilingual_edit_2025")
# Generate feedback
feedback = leaderboard.generate_feedback(submission.submission_id)
from quantum_integration.nsn_integration import NSNDashboard
# Create dashboard
dashboard = NSNDashboard()
# Plot FLOPs vs Reliability
dashboard.plot_flops_vs_reliability(
backend_curves=backend_curves,
save_path='flops_vs_reliability.png'
)
# Plot multilingual heatmap
dashboard.plot_multilingual_heatmap(
accuracy_matrix=accuracy_matrix,
save_path='multilingual_heatmap.png'
)
# Plot Pareto frontier
dashboard.plot_pareto_frontier(
frontier_data=frontier_data,
save_path='pareto_frontier.png'
)
# Create comprehensive dashboard
dashboard.create_comprehensive_dashboard(
backend_curves=backend_curves,
accuracy_matrix=accuracy_matrix,
containment_data=containment_data,
frontier_data=frontier_data,
leaderboard=rankings,
save_path='comprehensive_dashboard.png'
)
The NSN integration is embedded into the LIMIT-Graph benchmarking harness for seamless evaluation:
from quantum_integration.nsn_integration.limit_graph_nsn_integration import (
LIMITGraphNSNBenchmark,
BenchmarkConfig
)
# Create configuration
config = BenchmarkConfig(
backend_type=BackendType.IBM_WASHINGTON,
languages=['english', 'chinese', 'indonesian'],
target_reliability=0.85,
compute_budget=1e8
)
# Create benchmark
benchmark = LIMITGraphNSNBenchmark(config)
# Run benchmark
test_cases = [
{'language': 'english', 'text': 'The capital of France is Paris'},
{'language': 'chinese', 'text': '北京是中国的首都'},
{'language': 'indonesian', 'text': 'Jakarta adalah ibu kota Indonesia'}
]
results = benchmark.run_benchmark(test_cases)
# Visualize results
benchmark.visualize_benchmark_results(results, save_path='benchmark_results.png')
# Compare backends
comparison = benchmark.compare_backends(test_cases)
# Run complete NSN integration demo
python quantum_integration/nsn_integration/demo_complete_nsn_integration.py
# Run LIMIT-Graph integration demo
python quantum_integration/nsn_integration/limit_graph_nsn_integration.py
The demo will:
nsn_flops_vs_reliability.png: Backend performance curvesnsn_multilingual_heatmap.png: Language-rank accuracy matrixnsn_subspace_containment.png: Subspace nesting visualizationnsn_pareto_frontier.png: Compute-performance frontiernsn_leaderboard_rankings.png: Top contributor rankingsnsn_uncertainty_analysis.png: Uncertainty reduction analysisnsn_comprehensive_dashboard.png: Multi-panel dashboardlimit_graph_nsn_results.json: Benchmark resultsNSNs represent model parameters in nested subspaces of increasing rank:
Quantum backend characteristics determine optimal rank:
Low-resource language edits often nest within high-resource language subspaces:
This enables transfer learning and cross-lingual edit propagation.
from quantum_integration.social_science_extensions import REPAIRInferenceWrapper
from quantum_integration.nsn_integration import BackendAwareRankSelector
# Select rank based on backend
selector = BackendAwareRankSelector()
rank_config = selector.select_rank(BackendType.IBM_WASHINGTON)
# Use rank in REPAIR inference
# (REPAIR wrapper can be extended to accept rank parameter)
from quantum_integration import quantum_health_checker
from quantum_integration.nsn_integration import BackendAwareRankSelector
# Check backend health
health = quantum_health_checker.check_backend_health('ibm_washington')
# Adjust rank based on health
if health['status'] == 'degraded':
# Use lower rank for stability
rank = 32
else:
# Use optimal rank
rank = selector.select_rank(BackendType.IBM_WASHINGTON).rank
| Backend | Rank | Accuracy | Uncertainty | FLOPs | Inference Time |
|---|---|---|---|---|---|
| IBM Manila | 8 | 0.76 | 0.18 | 6.4e5 | 10ms |
| IBM Washington | 128 | 0.95 | 0.05 | 1.6e8 | 160ms |
| Russian Simulator | 256 | 0.97 | 0.03 | 6.6e8 | 320ms |
| Language | Resource Level | Rank 8 | Rank 32 | Rank 128 |
|---|---|---|---|---|
| English | High | 0.90 | 0.93 | 0.96 |
| Chinese | High | 0.89 | 0.92 | 0.95 |
| Russian | Medium | 0.78 | 0.85 | 0.91 |
| Indonesian | Low | 0.65 | 0.75 | 0.85 |
| Swahili | Low | 0.62 | 0.72 | 0.83 |
To contribute to NSN integration:
This integration is based on the Nested Subspace Networks (NSN) framework from:
@article{zhang2025deep,
title={Deep Hierarchical Learning with Nested Subspace Networks},
author={Zhang, Yifan and others},
journal={arXiv preprint},
year={2025},
note={NSN framework for hierarchical representation learning with nested subspaces}
}
If you use this NSN integration in your research, please cite both the original NSN paper and this implementation:
@software{nsn_limit_graph_integration,
title={NSN Integration with LIMIT-Graph and REPAIR for Quantum Benchmarking},
author={AI Research Agent Team},
year={2025},
url={https://github.com/NurcholishAdam/Quantum-LIMIT-Graph-v2.4.0-NSN},
note={Integration of Nested Subspace Networks with quantum computing backends and multilingual model editing}
}
We acknowledge the original NSN framework authors for their foundational work on hierarchical representation learning with nested subspaces, which enabled this integration with quantum benchmarking and multilingual edit reliability.
This integration is part of the LIMIT-Graph project and follows the same license terms.
For questions or issues:
Module: backend_telemetry_rank_adapter.py
Dynamically adjusts NSN ranks based on real-time backend health metrics.
Inputs:
backend_id: e.g., "ibm_washington"telemetry: Dict with error_rate, coherence_time, gate_fidelityChallenge Extension:
Usage:
from quantum_integration.nsn_integration import BackendTelemetryRankAdapter
adapter = BackendTelemetryRankAdapter()
result = adapter.adapt_rank(
backend_id='ibm_washington',
telemetry={
'error_rate': 0.02,
'coherence_time': 120.0,
'gate_fidelity': 0.98
},
current_rank=128
)
print(f"Adapted Rank: {result.adapted_rank}")
print(f"Reliability: {result.reliability_score:.3f}")
print(f"Rationale: {result.rationale}")
Module: edit_propagation_engine.py
Transfers high-resource corrections to low-resource languages using containment scores.
Inputs:
source_lang: High-resource languagetarget_lang: Low-resource languagerank: NSN rankedit_vector: Edit to propagateDashboard Extension:
Usage:
from quantum_integration.nsn_integration import EditPropagationEngine
import numpy as np
engine = EditPropagationEngine()
# Evaluate containment
containment = engine.evaluate_subspace_containment(
source_lang='english',
target_lang='indonesian',
rank=128
)
print(f"Containment Score: {containment.containment_score:.3f}")
# Propagate edit
edit_vector = np.random.randn(256) * 0.1
result = engine.propagate_edit(
source_lang='english',
target_lang='indonesian',
rank=128,
edit_vector=edit_vector
)
print(f"Quality Score: {result.quality_score:.3f}")
Module: rank_feedback_generator.py
Recommends optimal ranks based on contributor history and efficiency.
Inputs:
contributor_id: Contributor identifierpast_submissions: List with accuracy, flops, uncertaintyLeaderboard Extension:
Usage:
from quantum_integration.nsn_integration import RankFeedbackGenerator
generator = RankFeedbackGenerator()
# Record submissions
generator.record_submission(
contributor_id='contributor_001',
language='english',
rank=64,
accuracy=0.92,
flops=4.1e7,
uncertainty=0.08
)
# Get recommendation
recommendation = generator.recommend_rank('contributor_001')
print(f"Badge: {recommendation.personalized_badge}")
print(f"Recommended Rank: {recommendation.recommended_rank}")
print(f"Rationale: {recommendation.rationale}")
# Get feedback panel
panel = generator.generate_feedback_panel('contributor_001')
print(f"Suggestions: {panel['suggestions']}")
Module: ensemble_inference_manager.py
Runs edits across multiple backends and computes agreement scores.
Inputs:
edit_vector: Edit to applybackend_list: e.g., ['ibm_manila', 'ibm_washington', 'russian_simulator']Dashboard Extension:
Usage:
from quantum_integration.nsn_integration import EnsembleInferenceManager
import numpy as np
manager = EnsembleInferenceManager()
edit_vector = np.random.randn(256) * 0.1
result = manager.run_ensemble_inference(
edit_vector=edit_vector,
backend_list=['ibm_manila', 'ibm_washington', 'russian_simulator']
)
print(f"Agreement Score: {result.agreement_score:.3f}")
print(f"Reliability Boost: {result.reliability_boost:.3f}")
print(f"Best Backend: {result.best_backend}")
# Get agreement matrix for visualization
agreement_matrix, labels = manager.get_agreement_heatmap(
backend_list=['ibm_manila', 'ibm_washington', 'russian_simulator'],
edit_vector=edit_vector
)
# Run complete v2.4.0 scenarios demo
python quantum_integration/nsn_integration/demo_v2.4.0_scenarios.py
The demo will:
telemetry_edits_v2.4.0.json: Telemetry-aware rank adaptations for leaderboard