Skip to content

Add exact persistent representation broker routes - #62

Draft
Inserian wants to merge 271 commits into
mainfrom
qsa/0.2.1-persistent-mps
Draft

Add exact persistent representation broker routes#62
Inserian wants to merge 271 commits into
mainfrom
qsa/0.2.1-persistent-mps

Conversation

@Inserian

@Inserian Inserian commented Aug 11, 2026

Copy link
Copy Markdown
Member

QSA exact-representation progression remains on this draft/unmerged staging PR.

Accepted authorities:

  • factor broker: 423be022f348f102d700dbcc368a7545744419f6
  • direct persistent TTN: f723ea81bd0374f13eca4869118f195550c08c32
  • TTN marginal resource certificate: 30b0cbbc4617058947ea9b6099c8881068a4fe6b
  • marginal-only TTN execution broker: 487858b1baea9eb9604a79fc973409f05eb53f33

Accepted factor broker order remains:
ChainTransfer -> AffineXOR -> DecisionDiagram -> VariableElimination

Public ExactFactorBrokerRoute values remain stable: ChainTransfer=0, DecisionDiagram=1, VariableElimination=2, AffineXOR=3.

Direct TTN — accepted direct representation

TreeTensorState is accepted as a persistent exact state representation for branching entanglement.

Accepted TTN contract:

  • deterministic balanced binary qubit tree;
  • canonical QSA OperationCode dispatch for X/Y/Z/H/S/Sdg/T/Tdg/Rx/Ry/Rz and exact CNOT/CZ;
  • arbitrary-leaf CNOT/CZ through exact operator-Schmidt rank-2 branch insertion along the unique tree path;
  • touched path bonds double exactly and internal path tensors enforce branch equality;
  • no SVD, truncation or approximation;
  • explicit max-bond, state-scalar, materialization and marginal-workspace caps;
  • controlled-gate resource growth is preflighted before allocation or mutation;
  • failed resource gates preserve accepted state/statistics;
  • exact amplitudes/probabilities and selected-qubit marginals by double-layer tree contraction;
  • workspace generation and per-node shapes are revalidated, including cross-state reuse.

All 17 exact-head workflows were green on direct authority f723ea81bd0374f13eca4869118f195550c08c32.

Decision-bearing direct TTN evidence: run 31642042492, artifact 9159238027, ZIP digest sha256:aedbebf6e9c10926c883cd85b610016e6632585fe25656866e5e362cf7664225, embedded evidence SHA-256 7441c9cda7611222a0b7ddcfd9acad5f5cbb03ca2aea20c5795969cdc9f71630.

Accepted direct evidence:

  • matched 16-qubit carrier: 12 controlled gates, max path 4, max bond 8, 867 state scalars; TTN setup 0.012339 ms vs dense setup 2.452984 ms; prepared TTN query 0.02588327 ms; plan 18,120 bytes; workspace 14,352 bytes; amplitude error 2.78e-17; marginal error 0;
  • 4,096-qubit carrier: 1,024 independent four-leaf branching blocks, 3,072 exact controlled gates, max path 4, max bond 8, 222,207 state scalars; setup 2.739705 ms; selected-block marginal query 7.6754504 ms; plan 4,636,680 bytes; workspace 3,674,112 bytes; selected probability 0.0119166075286; independent block-control error 2.75e-15.

QRegister amplitude comparisons use QSA's established physical-state equivalence up to one global phase; marginal probabilities remain strict. TTN is exact and topology/workload-specific. Repeated overlapping paths can grow bonds exponentially and must fail closed. No universal or quantum-advantage claim is made.

TTN marginal resource certificate — accepted

TreeTensorMarginalPlan is accepted as a bounded preconstruction resource certificate and prepared marginal wrapper. It builds bounded O(n) topology/resource vectors but does not allocate TTN amplitude/tensor storage during certification; it is not described as allocation-free.

The certificate predicts and verifies the accepted executor's qubit/node counts, state scalar count, maximum bond dimension, controlled-gate count, maximum controlled path length, generation count and double-layer marginal-workspace scalar requirement. It fails closed on any prediction/executor disagreement.

Focused certificate run 31643019804 is green on Ubuntu 24.04, Windows 2022, macOS full-core and ASan/UBSan. All 18 exact-head workflows were green on 30b0cbbc4617058947ea9b6099c8881068a4fe6b.

The focused gate includes the independent workspace boundary: in the repeated 4-qubit cross-root carrier, TTN state storage is exactly 228 scalars while marginal workspace requires 259; cap 259 succeeds, cap 258 still permits direct state construction but direct marginal rejects, while the certificate rejects before TTN construction/query.

Marginal-only TTN execution broker — accepted

ExactPreparedProbabilityPlan now appends public execution route TreeTensor=8 without renumbering existing routes: Register=0, CausalPauli=1, TensorNetwork=2, PersistentMPS=3, PhaseGraph=4, UniformMagnitude=5, BasisPermutation=6, Stabilizer=7.

Promotion scope is deliberately narrow:

  • TTN is reachable only from marginal preparation / marginal_probability_from_zero;
  • existing BasisPermutation -> UniformMagnitude -> Stabilizer -> PersistentMPS marginal authority remains ahead of TTN;
  • TTN is attempted only after MPS rejection and before dense QRegister fallback;
  • full-basis probability preparation cannot select TTN;
  • TTN rejection remains visible and falls through to exact Register;
  • unsupported trajectory operations still prove the Register fallback path;
  • direct TTN and certificate implementations remain unchanged from their accepted authorities.

The production promotion itself is compact: include/qubit/qbroker.hpp adds 4 lines and src/qbroker.cpp adds 22 lines, with zero production deletions relative to the accepted certificate authority. The remainder is focused tests and evidence carriers.

All 20 exact-head workflows are green on 487858b1baea9eb9604a79fc973409f05eb53f33, including Build/Test, full Runtime Evidence, inherited Exact Execution Broker, TTN direct/QRegister/certificate gates, Tensor, factor routes, Causal, Pauli, Structural, Dense COW and Brain Recovery. The focused marginal-TTN broker gate is green on Ubuntu 24.04, Windows 2022, macOS and ASan/UBSan.

Decision-bearing broker evidence: run 31645271142, artifact 9160517879, ZIP digest sha256:c3830b40182be055f0a0636b5c2110c0094a7803d7edc536075e527f510d0d9a, embedded evidence SHA-256 642bcfb882e605811b4b8bcc252d9415f5e9553fa6d183db7f20367d0ac2d63f. GitHub metadata, the independently downloaded ZIP and the embedded receipt were reconciled.

Accepted broker evidence:

  • matched 16-qubit / 20-operation carrier: route TreeTensor; broker setup 0.011996 ms vs direct TTN 0.010943 ms; broker query 0.02077274 ms vs direct TTN 0.01973342 ms; broker plan 19,611 bytes vs direct 18,271; error 6.94e-18;
  • 4,096-qubit / 5,120-operation branching carrier: route TreeTensor; broker setup 2.993234 ms vs direct TTN 2.530621 ms; broker query 6.7874135 ms vs direct TTN 5.7179153 ms; broker plan 4,638,171 bytes vs direct 4,636,831; selected/control probability 0.0119166075286; error 2.75e-15.

The measured routing wrapper is not free: about 9.62% setup / 5.27% query overhead on the 16-qubit carrier and 18.28% setup / 18.70% query overhead on the 4,096-qubit carrier, with a fixed 1,340-byte retained-plan delta in these measurements. Direct TTN remains the stronger path when the caller already knows the representation. Broker value is exact eligibility/route selection and fail-closed fallback, not a claim that indirection is faster.

Next bounded phase — direct exact QTT functional representation

The next new representation frontier is QTT/tensor-train scoring for exponentially indexed but low-rank structured functions. Keep this phase direct-only first; do not add it to ExactExecutionBroker until independent evidence earns promotion.

Initial contract:

  • exact binary quantization of a logical 2^n index into tensor-train cores;
  • construct only from inputs carrying an exact low-rank certificate or from exact generators whose TT ranks are known by construction;
  • no approximate TT-SVD, truncation, tolerance-based rank guessing or silent compression;
  • explicit max-rank / max-core-scalar caps and fail-closed rank-growth checks;
  • exact point evaluation, norm/partition-style contraction and a bounded marginal/reduction only where the rank certificate supports it;
  • strong controls against direct closed-form evaluation, current MPS/Tensor where the workload overlaps, and dense materialization only at small sizes;
  • include no-benefit/adversarial high-rank inputs where QTT must reject rather than densify.

TreeTransfer remains rejected/parked. Prior accepted Tensor, ChainTransfer, DecisionDiagram, AffineXOR, TTN direct/certificate/broker and cost-aware tensor-planning mechanisms remain closed unless new evidence exposes a distinct mechanism failure.

Keep PR #62 draft and unmerged. Do not merge without explicit authorization.

@Inserian Inserian changed the title Add persistent exact matrix-product states Add exact persistent representation broker routes Aug 12, 2026
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