evaluation
Evaluate MatterGen crystal structures with MatterSim or precomputed energies, matching ordered or disordered structures against compatible reference datasets and exporting aggregate, detailed, and relaxed-structure results.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- evaluation
- license
- MIT
- metadata
- { "disco-role": "operating" }
- description
- Evaluate MatterGen crystal structures with MatterSim or precomputed energies, matching ordered or disordered structures against compatible reference datasets and exporting aggregate, detailed, and relaxed-structure results.
- disable-model-invocation
- true
02 资源文件 5
- 参考文档references/api-reference.md5.1 KB
- 参考文档references/data-formats.md4.2 KB
- 参考文档references/troubleshooting.md5.6 KB
- 参考文档references/workflows.md4.6 KB
- 脚本scripts/evaluate_structures.py10.7 KB
03 SKILL.md 正文
MatterGen evaluation
Use this sub-skill when the task is to score generated crystal structures for validity, uniqueness, novelty, stability, energy above hull, relaxation RMSD, or related metrics. It covers MatterGen 1.0.3's evaluation API and CLI. It does not generate structures, run DFT, or acquire large model/reference assets.
Start with the mode decision
Choose exactly one mode before loading data:
- Relaxed evaluation (
relax=True): pass structures to MatterSim'sBatchRelaxer; its final structures and total energies are evaluated. Do not passenergies/--energies_pathin this mode. - Precomputed-energy evaluation (
relax=False): pass already relaxed structures and one externally computed total energy per structure. The array must have the same count and order as the loader result.
The implementation raises if both relax=True and energies are supplied, even
though an older docstring says energies would be ignored. Use the safe wrapper
at scripts/evaluate_structures.py for
input/mode validation and clear errors; it only invokes package APIs when the
script is explicitly run.
Read the applicable reference before running:
references/workflows.mdfor recipes, output precedence, and expensive/network boundaries.references/api-reference.mdfor exact Python and CLI parameters, defaults, and metrics.references/data-formats.mdfor structure, energy-array, reference, and output formats.references/troubleshooting.mdfor install/backend, data, matcher, correction, and workflow failures.
Minimal preflight
- Confirm the input path exists and is one of
.xyz,.extxyz,.zip, or a directory containing lowercase.cif,.xyz, or.extxyzfiles. - Record the loader order. A direct XYZ/EXTXYZ file is read frame-by-frame;
a ZIP is extracted temporarily; a directory is traversed in the exact
os.listdirorder (not sorted). Keep any energy array in that same order. - For
relax=False, load a one-dimensional, numeric, finiteenergies.npyand verifylen(energies) == len(structures)before callingevaluate. - Select a matcher:
disorderedis the robust default for generated alloys, partial occupancies, and mixed ordered/disordered sets; useorderedonly when the data and reference are genuinely ordered and strict reduced-formula grouping is intended. - Select a correction/reference pair. MP2020 is the historical benchmark
pairing. TRI2024 (
TRI110Compatibility2024) plus the TRI2024 reference is recommended for work outside historical benchmarking. Never mix a correction scheme with a reference corrected under another scheme. - Check device, MatterSim availability/cache, disk space for outputs, and whether a large relaxation is affordable. The wrapper does not download datasets or potential files.
Canonical API
The package function is:
evaluate(
structures, relax=True, energies=None, reference=None,
structure_matcher=DefaultDisorderedStructureMatcher(),
save_as=None, save_detailed_as=None, potential_load_path=None,
device="cuda", structures_output_path=None,
energy_correction_scheme=MaterialsProject2020Compatibility(),
)
It returns a dictionary of aggregate metric values. With reference=None, the
metric evaluator selects the MP2020 preset, or the TRI2024 preset when the
TRI2024 correction object is supplied. A supplied reference is deserialized by
the CLI from the gzip-compressed LMDB format. Missing terminal systems can make
energy metrics unavailable while structure metrics remain computable; treat
warnings and absent metrics as results to investigate, not as zeros.
CLI routing
The safe script uses these exact underscore flags:
--structures_path PATH required
--relax {True,False} default True
--energies_path PATH required in no-relax mode
--structure_matcher {ordered,disordered}
--save_as PATH aggregate JSON
--save_detailed_as PATH per-structure serialized table
--potential_load_path PATH local MatterSim checkpoint
--reference_dataset_path PATH .gz LMDB reference
--device DEVICE auto, cpu, cuda[:N], or mps
--structures_output_path PATH relaxed EXTXYZ, relax mode only
--energy_correction_scheme {MP2020,TRI2024}
Example relaxed evaluation:
python <mattergen-skill-root>/sub-skills/evaluation/scripts/evaluate_structures.py \
--structures_path results \
--relax True --structure_matcher disordered \
--reference_dataset_path data/reference_TRI2024correction.gz \
--energy_correction_scheme TRI2024 \
--save_as results/metrics.json \
--save_detailed_as results/detailed_metrics.json \
--structures_output_path results/relaxed.extxyz
Example with external energies:
python <mattergen-skill-root>/sub-skills/evaluation/scripts/evaluate_structures.py \
--structures_path results.extxyz --relax False \
--energies_path energies.npy --structure_matcher disordered \
--reference_dataset_path data/reference_TRI2024correction.gz \
--energy_correction_scheme TRI2024 --save_as metrics.json
Interpret the result
The evaluator can report structure metrics (precision, recall,
frac_unique_structures, frac_novel_structures, frac_novel_unique_structures,
chemical-system novelty, validity, and composition validity), energy metrics
(avg_energy_above_hull_per_atom, frac_stable_structures,
frac_novel_unique_stable_structures), and relaxation RMSD when original and
final structures are both available. energy_above_hull is per atom; stability
uses the implementation's 0.1 eV/atom threshold. Detailed output exposes
per-structure columns such as energy_above_hull,
self_consistent_energy_above_hull, stable, novel, unique, and RMSD.
MatterSim energies are MLFF predictions, not DFT energies. Agreement with DFT is not guaranteed, especially for uncommon chemistry; confirm important claims with an explicitly documented DFT workflow. A TRI2024 result is not directly comparable with MP2020 metrics: corrections alter entries and therefore hulls, stability, and any stability-conditioned novelty/uniqueness aggregate.
Recovery rules
- Import or dependency failures: inspect
references/troubleshooting.md, then run the wrapper's--helpand a small import/device probe before an expensive job. - Optional backend failures: use CPU only for a small diagnostic; relaxation is substantially more expensive and may require CUDA plus compatible MatterSim.
- Input/config failures: fix suffixes, lowercase directory extensions, ZIP
contents, energy shape/order, reference
.gzpath, and mode conflicts first. - Matcher failures: use
disorderedfor any partial occupancy or disordered structure; an ordered matcher is not valid when the evaluator detects a disordered structure. - Reference/correction failures: rebuild or select a reference with the same correction convention; do not silence compatibility assertions.
- Workflow failures: preserve input files and partial metrics, rerun a small subset or no-relax path, and only then retry relaxation. Do not make the wrapper fetch a missing reference or potential implicitly.
Linked runtime material
scripts/evaluate_structures.py— safe, lazy-importing CLI adapter.references/api-reference.md— API, defaults, flags, and metric contract.references/workflows.md— evaluation recipes, output precedence, and resource boundaries.references/data-formats.md— accepted input, energy, reference, and output serialization.references/troubleshooting.md— actionable diagnosis and recovery.
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).