sr
Single-dataset symbolic regression with PhySO SR, including units, weights, presets, logging, and Pareto inspection.
- License 许可
- MIT
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- sr
- license
- MIT
- metadata
- { "disco-role": "operating" }
- read_when
- Use when the user has one X/y dataset and wants physo.SR guidance, dimensional-analysis units, y_weights, candidate_wrapper, config0/config0b, CPU/parallel notes, logs, or a safe quick-start smoke.
- description
- Single-dataset symbolic regression with PhySO SR, including units, weights, presets, logging, and Pareto inspection.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/configurations.md5.4 KB
- 参考文档references/troubleshooting.md6.6 KB
- 参考文档references/workflows.md6.3 KB
- 脚本scripts/smoke_sr_quick_start.py3.5 KB
03 SKILL.md 正文
PhySO SR Sub-skill
Role
Use this sub-skill to help a Researcher run single-dataset symbolic regression with physo.SR. It covers preparing one X, y dataset, optional point weights, dimensional-analysis units, free/fixed constants, operator choices, light run configurations, logging, and result/Pareto-front inspection. For root routing across all PhySO sub-skills, see the parent skill at ../../SKILL.md.
Boundaries
Included:
- One dataset with
Xshaped(n_dim, n_samples)andyshaped(n_samples,). X_names,X_units,y_name,y_units, fixed constants, and SR free constants.y_weightsas either one scalar or one per-sample vector aligned withy.candidate_wrapper,op_names,use_protected_ops,config0/config0bselection,epochs,stop_reward,max_n_evaluations, logging, and CPU-safe execution.- Handoff to Pareto/log inspection helpers after a run.
Excluded:
- Multi-dataset
physo.ClassSR, class free constants, and realization-specific free constants; use siblingclass-srwhen the user has multiple datasets or class/spe constants. - Benchmark-problem definitions or maintainer benchmark runners; use sibling
benchmarksfor packaged Feynman/Class benchmark loaders. - Low-level expression/library construction and random-expression sampling; use sibling
toolkitfor those APIs. - Generic PyTorch or scikit-learn regression advice outside the PhySO SR workflow.
Verified entry points
physo.SR(X, y, y_weights=1.0, X_names=None, X_units=None, y_name=None, y_units=None, fixed_consts=None, fixed_consts_units=None, free_consts_names=None, free_consts_units=None, free_consts_init_val=None, op_names=None, use_protected_ops=True, stop_reward=1.0, max_n_evaluations=None, stop_after_n_epochs=10, epochs=None, candidate_wrapper=None, run_config=None, get_run_logger=None, get_run_visualiser=None, parallel_mode=True, n_cpus=None, device="cpu")physo.config.config0.config0andphyso.config.config0b.config0bfor light SR presets.physo.learn.monitoring.RunLoggerandphyso.learn.monitoring.RunVisualiserfor logs and optional plots.logs.get_pareto_front()from the returned logger.physo.read_pareto_pkl,physo.read_pareto_csv, andphyso.load_exprfor saved-result inspection.
Operating workflow
- Route first. Stay here for one
X, ydataset. If the request mentions several realizations, shared formula across datasets, class constants, or per-dataset constants, route toclass-sr. - Prepare numeric inputs. Convert tabular data to floating arrays, then transpose feature matrices so
X.shape == (n_dim, n_samples)andy.shape == (n_samples,). Keepy_weightseither a scalar or a per-sample float array with the same shape asy. - Define units and constants. If dimensional analysis matters, give every variable and constant a consistent units vector of length up to seven; otherwise omit units or use zero vectors. SR free constants are single-dataset/class-style constants only.
- Choose operators and wrappers. Start with the default operator set unless the task needs a narrow grammar. Keep
candidate_wrappercallable, top-level if multiprocessing is used, differentiable, and implemented with torch operations when free constants are optimized. - Choose a preset. Use
config0for demos and short smokes. Useconfig0bwhen a quick SR task has free constants and you want more LBFGS constant-optimization steps without moving to heavier presets. Deep-copy presets before editing. - Run safely. For notebooks, debugging, and the verified CPU smoke path, set
parallel_mode=False,n_cpus=1, anddevice="cpu". This skill does not verify CUDA behavior. - Inspect results. Treat the returned
expressionas the current bestProgram; uselogs.get_pareto_front()for the complexity/reward/RMSE front, and saved Pareto pkl/csv helpers for later inspection. - Recover from failures. Use
references/troubleshooting.mdbefore changing algorithms; most SR failures are shape, units, weights, wrapper, preset-mutation, or optional-display issues.
Input and output contract
Inputs expected by this sub-skill:
X: float NumPy array or torch tensor convertible to shape(n_dim, n_samples).y: float vector convertible to shape(n_samples,)with no NaNs.- Optional
y_weights: scalar, or float vector with the same sample length asy. - Optional units:
X_unitslength equalsn_dim;y_units,fixed_consts_units, andfree_consts_unitsuse the same convention and vector length up to seven. - Optional grammar/config:
op_names,use_protected_ops, a deep-copiedrun_config, and a torch-compatiblecandidate_wrapper.
Outputs returned by physo.SR:
expression: aphyso.physym.program.Programfor the best expression found so far.logs: aRunLoggerwith histories andget_pareto_front()returning(complexities, programs, rewards, rmse).- Optional saved artifacts if the logger/visualiser are configured to save: run CSV logs, Pareto CSV, Pareto pkl, and plots.
Bundled references and helper
references/workflows.md: quick-start, weighted data, dimensional-analysis, wrapper, and result-inspection recipes.references/configurations.md: preset choice, safe edits, stopping criteria, parallel/device notes, and operator/prior alignment.references/troubleshooting.md: recover from import, shape, unit, weight, wrapper, parallel, display, and Pareto-loading mistakes.scripts/smoke_sr_quick_start.py: short CPU-only smoke adapted from the SR quick start; it runs a tiny weighted single-dataset SR call and reloads the Pareto pkl it writes.
Related native tests and examples
Native candidates for later verification of this route:
physo.task.tests.sr_UnitTest: deterministicphyso.SRcalls, including the canonical energy-style quick-start and a reduced-operator case that tolerates prior warnings.physo.physym.tests.execute_UnitTest: lower-level expression execution on CPU/CUDA-capable hosts; use only as execution evidence here, not as CUDA proof.physo.physym.tests.program_display_UnitTest: string, SymPy, LaTeX, and optional tree-display behavior; display extras can fail gracefully.physo.learn.tests.monitoring_UnitTest: SR logging, Pareto-front collection, and cleanup behavior.
Source examples distilled into this sub-skill:
- The bundled smoke helper adapts the canonical SR quick-start into a tiny CPU-only installed-package check.
- The y-weights demo material is distilled into the weighted-data workflow reference rather than copied as a runnable notebook.
- The damped harmonic oscillator demo is useful as a longer, dimensioned SR reference, but its long run settings are not bundled as a smoke helper.
- Feynman benchmark runners and job-file generators are maintainer/reference material, not SR runtime helpers; use benchmark-focused siblings for packaged benchmark problem loaders.
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).