analysis-and-measurements
Use OpenFermion for bounded sparse or dense operator analysis, Davidson and eigensolver workflows, RDM reconstruction and mapping, symmetry-sector restriction, measurement grouping and partitioning, VPE estimation, resource functionals, and grid or lattice numerical helpers.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- analysis-and-measurements
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Use OpenFermion for bounded sparse or dense operator analysis, Davidson and eigensolver workflows, RDM reconstruction and mapping, symmetry-sector restriction, measurement grouping and partitioning, VPE estimation, resource functionals, and grid or lattice numerical helpers.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/api-reference.md16.1 KB
- 参考文档references/troubleshooting.md11.9 KB
- 参考文档references/workflows.md12.2 KB
- 脚本scripts/sparse_analysis_smoke.py3.1 KB
03 SKILL.md 正文
Analysis and measurements
Use this route when the task is to analyze an already constructed public OpenFermion operator or numerical tensor: obtain a sparse matrix, compute a small spectrum or ground state, restrict a Jordan–Wigner operator to a symmetry sector, map or validate RDMs, group compatible measurements, estimate a VPE functional, or use grid/lattice indexing helpers.
Route first
- Operator construction, fermion-to-qubit transforms, or choosing a mapping: route to operators-and-transforms.
- Molecular, Hubbard, jellium, or other model construction: route to hamiltonians-and-chemistry.
- Circuit synthesis, VPE circuit creation, or state simulation: route to circuits-and-simulation. This skill only processes bounded numerical or measurement data for those workflows.
- Large benchmarks, performance claims, multiprocessing experiments, and production integrations are evidence only; do not infer scalability from a tiny smoke check.
Read references/api-reference.md for signatures, shape conventions, and public import locations. Read references/workflows.md before doing a numerical workflow. Use references/troubleshooting.md when an import, dimension, backend, tensor, or solver check fails.
Guardrails before numerical work
- Identify the operator family (
QubitOperator,FermionOperator, bosonic operator, polynomial tensor, or an existing sparse/linear operator), the qubit/mode count, and whether the operator is Hermitian. - For a qubit Hilbert space, require the matrix dimension to be exactly
2**n_qubits; reject an underspecifiedn_qubitsrather than silently truncating. For bosons, provide a positive integertruncand estimate the dimensiontrunc**n_modesfirst. - Keep dense diagonalization bounded.
sparse_eigenspectrumconverts the entire matrix to dense form and is appropriate only for a deliberately tiny matrix. Preferget_ground_state,get_gap, or Davidson for larger but still bounded sparse cases. - Check state shape and normalization before
expectationorvariance. These functions do not repair a wrong basis, wrong dimension, or an unnormalized state. - For RDMs, state the number of spin-orbitals, particle number, and exact tensor convention before converting. Reject incompatible ranks or leading dimensions before calling an einsum or reconstruction routine.
Main routes
- Sparse matrix and spectrum: use
get_sparse_operator; inspect.shape,.format, and.nnz; useget_ground_statefor the lowest state,get_gapfor a Hermitian gap, andsparse_eigenspectrumonly after a dense memory bound. The bundled sparse analysis smoke helper is a safe tiny example and prints the matrix shape and ground energy. - Symmetry-sector analysis: use
jw_number_restrict_operatororjw_sz_restrict_operatoron a Jordan–Wigner sparse matrix, or useget_number_preserving_sparse_operatorwhen constructing a fermionic matrix directly in a bounded sector. Restricted state vectors are generally not normalized; renormalize before interpreting expectations. - Davidson: use
SparseDavidsonfor a sparse matrix andQubitDavidsonfor aQubitOperatorwithout materializing its full matrix. Supply a diagonal, a dimension-compatible initial guess, and boundedDavidsonOptions; inspect the returnedsuccessflag and residual rather than assuming convergence. - RDMs and equality constraints: use the mapping functions only with the
documented OpenFermion index order.
get_interaction_rdmreconstructs anInteractionRDMfrom measured qubit-term coefficients and can be O(n_qubits**4); specifyn_qubitswhen identity or trailing orbitals make counting ambiguous. Equality projection is a resource-functional workflow, not a generic RDM repair operation. - Measurement grouping and partitioning: use tensor-product basis grouping
for a
QubitOperator; use qubit partition iterators for coverage families; use fermion/Majorana pairings only when their combinatorial output is the requested measurement schedule. They do not synthesize circuits or estimate shot noise. - VPE and resource functionals:
PhaseFitEstimatorrequires known eigenvalues and phase samples aligned to its simulation points. The one-norm functions consume spatial-orbital integral tensors and distinguish inclusion of the constant.is_contextualis imported fromopenfermion.functionals.contextuality, not the root package. - Grid and lattice helpers: use
Gridfor centered real-space and reciprocal-space indexing, andHubbardSquareLatticefor site, degree of freedom, spin, and neighbor iteration. These helpers do not construct a Hamiltonian; route model construction elsewhere.
Completion checklist
- Record input type,
n_qubits/mode count, truncation or sector, matrix shape, Hermiticity check, solver path, tolerance/iteration bound, and numerical result. - For spectra, state whether the result was dense or iterative and give the expected dimension. For RDMs, record ranks, shapes, particle/hole counts, contraction identity, and round-trip or trace checks.
- For measurements, record the partition/grouping convention and whether identity terms or unpaired labels are present.
- Stop and diagnose shape, basis, backend, or convergence failures using the troubleshooting table; do not increase dimensions or iteration limits blindly.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).