Skip to main content

Tutorial 14 — Tuning Physical-Layer Constants

Objective: Sweep PhysicalConfig parameters (fiber loss, T2 memory lifetime, generation rate) to see how fidelity and success rate shift — useful as a sensitivity-style demo for network optimization.

Network performance is determined by physical-layer parameters that are often costly to change in practice. Understanding which parameters have the most impact helps prioritize capital allocation.

Define Baseline Parameters

from qnet_core import QNetEngine, NodeDefinition, LinkDefinition, StrategyType, SimulationConfig

nodes = [
NodeDefinition(id="Alice", memory_lifetime_t2=1.0),
NodeDefinition(id="Bob", memory_lifetime_t2=1.0),
]

links = [
LinkDefinition("Alice", "Bob", distance_km=20.0, base_fidelity=0.90, generation_rate_hz=1_000.0),
]


def simulate_with_config(alpha_loss=None, t2=1.0):
"""Helper: run with custom physical config."""
from qnet_core import SimulationConfig

cfg = SimulationConfig(
total_time_cutoff_ms=10_000.0,
step_resolution_ms=0.1,
alpha_loss_db_km=alpha_loss if alpha_loss else 0.22,
)

t2_nodes = [
NodeDefinition(id="Alice", memory_lifetime_t2=t2),
NodeDefinition(id="Bob", memory_lifetime_t2=t2),
]

eng = QNetEngine(config=cfg)
eng.define_network(t2_nodes, links)

return eng.simulate(
from_node="Alice", to="Bob",
fidelity_target=0.85, max_latency_ms=10_000.0,
runs=300, strategy=StrategyType.HighestFidelity, seed=42,
)

Sweep 1: Fiber Loss Coefficient (α)

Fiber attenuation is the dominant loss mechanism in quantum networks. Standard telecom fiber at 1550 nm has α ≈ 0.22 dB/km, but different wavelengths or fiber types can vary significantly.

print("=== Sensitivity: Fiber Loss Coefficient (α_loss_db_km) ===\n")
print(f"{'alpha (dB/km)':<16} {'Success':>9} {'Fidelity':>10} {'Latency':>12}")
print("-" * 52)

alphas = [0.10, 0.15, 0.20, 0.25, 0.30, 0.40]

for alpha in alphas:
stats = simulate_with_config(alpha_loss=alpha)
print(f"{alpha:<16.2f} {stats.empirical_success_rate:>8.1%} "
f"{stats.mean_fidelity:>9.4f} {stats.mean_latency_ms:>11.1f} ms")

Expected trend: As alpha increases, fidelity drops (more loss per km) and success rate decreases (lower effective generation rate due to attenuation). Beyond a critical alpha (~0.35 dB/km on this distance), purification can no longer recover fidelity and success collapses.

Sweep 2: Qubit Memory Lifetime (T2)

T2 coherence time determines how long qubits survive in quantum memory. For multi-hop networks, longer T2 is more critical because each hop adds latency before purification.

print("\n=== Sensitivity: Qubit Memory Lifetime (T2) ===\n")
print(f"{'T2 (s)':<14} {'Success':>9} {'Fidelity':>10} {'Latency':>12}")
print("-" * 48)

t2_values = [0.1, 0.3, 0.5, 0.8, 1.0, 2.0]

for t2 in t2_values:
stats = simulate_with_config(t2=t2)
print(f"{t2:<14.1f} {stats.empirical_success_rate:>8.1%} "
f"{stats.mean_fidelity:>9.4f} {stats.mean_latency_ms:>11.1f} ms")

Expected trend: For direct (single-hop) links, T2 matters less because there's no waiting between hops. But for multi-hop networks, longer T2 directly improves success rate by reducing decoherence during routing and purification.

Higher generation rates mean more frequent link attempts, which reduces the time to establish entanglement but doesn't change the fidelity floor (which is determined by physics, not rate).

print("\n=== Sensitivity: Link Generation Rate ===\n")
print(f"{'Rate (Hz)':<12} {'Success':>9} {'Fidelity':>10} {'Latency':>12}")
print("-" * 48)

rates = [50, 100, 300, 500, 1_000, 3_000]

for rate in rates:
links_rate = [LinkDefinition("Alice", "Bob", distance_km=20.0, base_fidelity=0.90, generation_rate_hz=rate)]
eng = QNetEngine()
eng.define_network(nodes, links_rate)

stats = eng.simulate(
from_node="Alice", to="Bob",
fidelity_target=0.85, max_latency_ms=10_000.0,
runs=300, strategy=StrategyType.HighestFidelity, seed=42,
)
print(f"{rate:<12,d} {stats.empirical_success_rate:>8.1%} "
f"{stats.mean_fidelity:>9.4f} {stats.mean_latency_ms:>11.1f} ms")

Expected trend: Higher rate → lower latency (entanglement established faster), same fidelity floor, slightly higher success rate (more attempts before timeout).

Key Insights Summary

ParameterHigh value helps...When it matters most
Low α_loss (dB/km)Fidelity and success rateLong-distance links (>30 km)
High T2 (s)Success rate in multi-hopAny network with 2+ repeaters
High generation_rate (Hz)Latency (lower is better)All networks — always optimize first

What's next