class-sr
Multi-dataset class symbolic regression with shared and realization-specific free constants.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- class-sr
- license
- MIT
- metadata
- { "disco-role": "operating" }
- read_when
- Use when multiple related realizations must share one symbolic law with class and realization-specific constants.
- description
- Multi-dataset class symbolic regression with shared and realization-specific free constants.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/data-shapes.md3.5 KB
- 参考文档references/troubleshooting.md4.4 KB
- 参考文档references/workflows.md3.7 KB
- 脚本scripts/smoke_class_sr_quick_start.py3.5 KB
03 SKILL.md 正文
Class SR
Role
Use this sub-skill when the user has multiple realizations of the same phenomenon and wants one shared symbolic form with:
- class free constants shared by every realization
- realization-specific free constants (
spe_free_consts) - ClassSR-specific data-shape validation and quick-start guidance
If the user has only one dataset, route to the sibling sr sub-skill instead.
If the user mainly needs expression-tree or constant-table manipulation, hand off to the sibling toolkit sub-skill.
Included
physo.ClassSRmulti_X,multi_y,multi_y_weightsclass_free_consts_*andspe_free_consts_*- ClassSR config selection (
config0b,config1b,config2b) - safe quick-start execution on CPU
- loading and inspecting Pareto logs
- constant inspection handoff to toolkit-style workflows
Excluded
- single-dataset
physo.SR - benchmark equivalence utilities and benchmark runner automation
- generated jobfile helpers and maintainer-only benchmark orchestration
- generic multi-task ML workflows that are not ClassSR
Verified entry points
physo.ClassSRphyso.config.config0b.config0bphyso.config.config1b.config1bphyso.config.config2b.config2bphyso.read_pareto_pklphyso.load_exprrun_logger.get_pareto_front()best_expr.free_consts.class_valuesbest_expr.free_consts.spe_valuesbest_expr.get_infix_sympy(evaluate_consts=True)
Canonical workflow
- Build
multi_Xandmulti_yas lists with one element per realization.- Each
X_imust have shape(n_dim, n_samples_i). - Each
y_imust have shape(n_samples_i,). - Different realizations may have different sample counts.
- Each
- Provide weights with
multi_y_weightswhen you need to bias one realization or one region of a realization. - Define constants and units.
class_free_consts_*are shared across realizations.spe_free_consts_*may vary by realization.
- Pick a ClassSR config.
config0b: quick smoke / demosconfig1b: dimensional-analysis-heavy ClassSR and Milky Way streamsconfig2b: class benchmark style runs- prefer the
bvariants for ClassSR because they give more free-constant optimization steps
- Run
physo.ClassSR(...)on CPU for a smoke test, or on the target device if the environment is already verified. - Inspect the result with
best_expr.get_infix_pretty(),run_logger.get_pareto_front(), andbest_expr.free_consts. - If you need deeper program or constant-table work, switch to the sibling
toolkitsub-skill instead of expanding this one.
Input / output contract
- Input
multi_X: list-like of lengthn_realizations; each item is array-like with shape(n_dim, n_samples_i). - Input
multi_y: list-like of lengthn_realizations; each item is array-like with shape(n_samples_i,). - Input
multi_y_weights: one of- a single scalar, broadcast to every realization
- a list/array of length
n_realizationscontaining one scalar per realization - a list/array of length
n_realizationscontaining one weight array per realization with shape(n_samples_i,)
- Input
class_free_consts_names/class_free_consts_units/class_free_consts_init_val: same length, one entry per shared constant.- In the
ClassSRwrapper, pass init values in name order as a list/array-like container.
- In the
- Input
spe_free_consts_names/spe_free_consts_units/spe_free_consts_init_val: same length, one entry per realization-specific constant.- In the
ClassSRwrapper, pass init values in name order as a list/array-like container. spe_free_consts_init_valmay use a scalar or a length-n_realizationsvector per constant.
- In the
- Output
best_expression:physo.physym.program.Program - Output
run_logger: logger object with Pareto-front access - Output
best_expression.free_consts.class_values: shape(1, n_class_free_consts) - Output
best_expression.free_consts.spe_values: shape(1, n_spe_free_consts, n_realizations) - Output
best_expression.get_infix_sympy(evaluate_consts=True): array with one expression per realization
Quick safe run
Use the bundled smoke helper for a CPU-safe sanity check:
python skills/disco/physo/sub-skills/class-sr/scripts/smoke_class_sr_quick_start.py
The helper uses tiny deterministic data, short epochs, CPU execution, and temporary log files.
Troubleshooting
- If imports fail, check the environment first:
physo,torch,numpy,sympy,pandas,matplotlib,scikit-learn. - If a realization has a different sample count, that is allowed; only each
X_i/y_ipair must match. - If
multi_y_weightslength does not matchmulti_y, or any per-point weight array has the wrong length, fix the list shape first. - If class/spe constant unit arrays do not match the name counts, fix the name/unit lists before running.
- If
spe_free_consts_init_valis a vector, its length must matchn_realizations. - If
parallel_modeor CUDA behavior is unclear, keep the smoke run ondevice='cpu'withparallel_mode=False. - CUDA-capable torch builds may still print parallel-mode warnings during a CPU smoke run; treat them as expected noise unless the run actually fails.
- If LaTeX or display extras are missing, prefer
get_infix_pretty()orget_infix_sympy(); pretty LaTeX rendering is optional. - If you need saved logs or Pareto reloads, use
run_logger.get_pareto_front()first and thenphyso.read_pareto_pkl(...)on the saved_pareto.pklfile.
Related native tests and examples
physo/task/tests/class_sr_UnitTest.py— canonical ClassSR task checkphyso/physym/tests/free_const_UnitTest.py— class/spe constant table behaviorphyso/physym/tests/dataset_UnitTest.py— realization and weight-shape validationphyso/benchmark/ClassDataset/tests/ClassProblem_UnitTest.py— benchmark-shaped multi-dataset loadingdemos/class_sr_quick_start.py— source quick-start recipe adapted by the smoke scriptdemos/class_sr/demo_free_fall/demo_free_fall.py— reference ClassSR example with class and spe constantsdemos/class_sr/demo_milky_way_streams/MW_streams_run.py— reference-only, longer benchmark-style run
See also
- Root
physoskill for package-level routing and shared troubleshooting - Sibling
toolkitskill for program inspection, constant-table work, and log loading - Sibling
benchmarksskill for benchmark problem loaders and symbolic comparison
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).