Skip to content

Algorithm settings

Each algorithm has its own config class. Once kd.Model(config=...) receives one it is the single source of that algorithm's settings, and passing the same settings as kd.Model keywords alongside it raises. Every field of every class is documented below. The main parameters of each, with their defaults and resume tiers, are tabulated on the algorithm's own page, read from the same definitions.

Name Summary
kd.instrument_schemas() Return agent-facing schemas for facade plugins in registration order.
kd.SGAConfig(num, p_var[, ...]) Configuration for the SGA search algorithm.
kd.DLGAConfig(mode, library[, ...]) DLGA Stage I (constant-coefficient) configuration.
kd.DiscoverConfig(n_iterations, seed[, ...]) Configuration for a DISCOVER (RL + optional PINN) search run.
kd.EqGPTConfig(sparsity_alpha, seed[, ...]) Static configuration for the EqGPT plugin.
kd.Llm4edConfig(temperature, max_tokens[, ...]) Static configuration for the LLM4ED plugin.
kd.PySRConfig(terms, seed[, ...]) Frozen configuration for a PySR symbolic-regression run.
kd.PySINDyConfig(terms, threshold[, ...]) Frozen configuration for a PySINDy STLSQ fit.

instrument_schemas

instrument_schemas() -> list[dict[str, Any]]

Return agent-facing schemas for facade plugins in registration order.

SGAConfig dataclass

Configuration for the SGA search algorithm.

aic_ratio class-attribute instance-attribute

aic_ratio: float = 1.0

AIC penalty ratio.

autograd_train_epochs class-attribute instance-attribute

autograd_train_epochs: int = 1000

Maximum training epochs for the auto-trained FieldModel. Only used when use_autograd=True and field_model is None.

autograd_train_lr class-attribute instance-attribute

autograd_train_lr: float = 0.001

Learning rate for the auto-trained FieldModel. Only used when use_autograd=True and field_model is None.

autograd_train_patience class-attribute instance-attribute

autograd_train_patience: int | None = None

Early-stopping patience for the auto-trained FieldModel (epochs without validation improvement). None (default) disables early stopping, so the surrogate trains the full autograd_train_epochs budget — the v1 / paper reference semantics (sgapde/metann.py fixed-step training, no early stop). Requires autograd_train_val_ratio > 0 (there is no validation signal to monitor otherwise). Only used when use_autograd=True and field_model is None; ignored in finite-diff mode (same handling as autograd_train_epochs).

autograd_train_val_ratio class-attribute instance-attribute

autograd_train_val_ratio: float = 0.0

Fraction of data held out for validation while auto-training the FieldModel. 0.0 (default) trains on ALL data — the v1 / paper reference semantics (full-data training, no val split). Set > 0 only when using autograd_train_patience for early stopping. Only used when use_autograd=True and field_model is None; ignored in finite-diff mode (same handling as autograd_train_epochs).

d_tol class-attribute instance-attribute

d_tol: float = 1.0

Tolerance step size for STRidge sweep.

dedup_mode class-attribute instance-attribute

dedup_mode: DedupMode = 'pre_prune'

Deduplication strategy for genetic offspring.

depth class-attribute instance-attribute

depth: int = 4

Maximum tree depth for each term.

field_model class-attribute instance-attribute

field_model: FieldModel | None = None

Optional pre-trained FieldModel surrogate (skips auto-training when use_autograd=True). Must have matching coord_names / field_names. Ignored when use_autograd=False.

lam class-attribute instance-attribute

lam: float = 0.0

Ridge lambda (0 = OLS).

maxit class-attribute instance-attribute

maxit: int = 10

Max steps of the inner per-candidate STRidge tolerance sweep (train_sweep in sga/train.py).

normalize class-attribute instance-attribute

normalize: int = 2

Column norm order for STRidge normalization.

num class-attribute instance-attribute

num: int = 20

Population size (number of PDE candidates).

p_cro class-attribute instance-attribute

p_cro: float = 0.5

Crossover probability between PDEs.

p_mute class-attribute instance-attribute

p_mute: float = 0.3

Mutation probability per node.

p_rep class-attribute instance-attribute

p_rep: float = 1.0

Replace probability (chance of replacing a term).

p_var class-attribute instance-attribute

p_var: float = 0.5

Probability that a node is a variable (vs. operator).

seed class-attribute instance-attribute

seed: int = 0

Random seed for reproducibility.

str_iters class-attribute instance-attribute

str_iters: int = 10

STRidge internal iterations per tolerance level.

use_autograd class-attribute instance-attribute

use_autograd: bool = False

If True, train (or reuse) a FieldModel surrogate and use AutogradProvider for Layer 2 terminals (u_x, u_t). Layer 1 (raw u leaf) and Layer 3 (tree d / d^2 operators) are unchanged.

width class-attribute instance-attribute

width: int = 5

Maximum number of terms per PDE.

DLGAConfig dataclass

DLGA Stage I (constant-coefficient) configuration.

add_rate class-attribute instance-attribute

add_rate: float = 0.4

Probability that a newly built random term is appended to a candidate, from 0 to 1. The term is added only if the candidate is below max_modules and does not already contain it.

auto_upgrade_threshold class-attribute instance-attribute

auto_upgrade_threshold: float

Reserved for the planned mode="auto" escalation: the best NMSE above which the search would hand over to an adaptive, variable-coefficient stage. It has no effect today, because "constant" is the only implemented mode, and the 1e-3 default is an untuned placeholder.

crossover_rate class-attribute instance-attribute

crossover_rate: float = 0.8

Probability that a pair of surviving candidates exchanges one term during crossover, from 0 to 1. Survivors are paired off in order, and each pair either swaps one randomly chosen term or passes through unchanged.

delete_rate class-attribute instance-attribute

delete_rate: float = 0.5

Probability that one term is dropped from a candidate, from 0 to 1. A candidate that is down to a single term is left unchanged. The draw is independent of add_rate, so one candidate can gain and lose a term in the same generation.

epsilon class-attribute instance-attribute

epsilon: float = 0.001

Complexity penalty in the genetic fitness NMSE + epsilon * length, where length is the total number of tokens across the candidate's terms. Raise it to push the search toward shorter equations; the useful value is problem- dependent, and the packaged presets span 1e-6 to 1e-3.

genes_prob class-attribute instance-attribute

genes_prob: float = 0.6

Probability, from 0 to 1, of adding one more term while a random candidate equation is built. Generation stops once the candidate reaches max_modules terms.

lhs_auto_select class-attribute instance-attribute

lhs_auto_select: bool = True

When True, every candidate is fitted against both the first time derivative (u_t) and the second (u_tt), and the branch with the lower NMSE is kept. When False, only u_t is built and used as the left-hand side.

library class-attribute instance-attribute

library: list[str]

Ordered vocabulary of tokens that candidate terms are built from, defaulting to ["u", "u_x", "u_xx", "u_xxx"]. Each term is a product of tokens drawn from this list, and the ordering matters: one of the mutation operators shifts a token to an adjacent entry.

max_module_length class-attribute instance-attribute

max_module_length: int = 5

Maximum number of tokens multiplied together inside a single term.

max_modules class-attribute instance-attribute

max_modules: int = 5

Maximum number of additive terms allowed in one candidate equation.

mode class-attribute instance-attribute

mode: Literal['constant', 'adaptive', 'auto']

Coefficient mode of the search; only "constant" (constant-coefficient equations) is implemented. The values "adaptive" and "auto" pass configuration validation but raise NotImplementedError when the algorithm is constructed.

mutation_rate class-attribute instance-attribute

mutation_rate: float = 0.4

Probability that a mutation shifts one factor of one term along library, from 0 to 1. The shift is to an adjacent entry, except for a factor sitting at the first entry, which is redrawn from the whole library.

partial_prob class-attribute instance-attribute

partial_prob: float = 0.6

Probability, from 0 to 1, of extending a randomly built term with one more factor. The term stops growing once it reaches max_module_length.

pop_size class-attribute instance-attribute

pop_size: int = 400

Number of candidate equations in each generation of the genetic search, which is also how many candidates the platform evaluates per iteration.

seed class-attribute instance-attribute

seed: int = 0

Random seed of the genetic search: it seeds the generator behind the initial population and every crossover, mutation, add and delete draw, and is also forwarded to the surrogate network's training. Runs differing only in this value explore different candidates.

solver class-attribute instance-attribute

solver: Literal['svd_null_space', 'ols'] = 'svd_null_space'

Solver used to fit each candidate's coefficients against the left-hand side: "svd_null_space" takes the null space of the augmented system (total least squares), "ols" uses ordinary least squares.

surrogate_activation class-attribute instance-attribute

surrogate_activation: Literal["tanh", "sin", "relu"] = "sin"

Activation applied after each hidden layer of the fitted network: tanh, sin, or relu. The default sin stays smooth under the repeated differentiation the search relies on, which relu does not.

surrogate_hidden_sizes class-attribute instance-attribute

surrogate_hidden_sizes: list[int]

Widths of the hidden layers in the neural network fitted to the field data, one hidden layer per entry (default five layers of 50 units). The search differentiates this network for the derivatives it scores, so its capacity bounds their accuracy.

surrogate_lr class-attribute instance-attribute

surrogate_lr: float = 0.001

Learning rate of the Adam optimizer used to fit the network to the field data.

surrogate_max_epochs class-attribute instance-attribute

surrogate_max_epochs: int = 50000

Maximum number of epochs to spend fitting the network, one full-batch Adam step per epoch. It trades run time against derivative accuracy: dropping the default 50000 to a few thousand finishes much sooner with coarser derivatives.

surrogate_patience class-attribute instance-attribute

surrogate_patience: int | None = None

Number of consecutive epochs without validation-loss improvement after which the fit stops early. None, the default, disables early stopping and runs the full surrogate_max_epochs budget; other values need surrogate_val_ratio above 0 to take effect.

surrogate_restore_best class-attribute instance-attribute

surrogate_restore_best: bool = True

If True, the weights from the epoch with the lowest validation loss are restored at the end of the fit instead of keeping the last epoch's weights. Has no effect when surrogate_val_ratio is 0, since there is no validation loss to rank epochs by.

surrogate_val_ratio class-attribute instance-attribute

surrogate_val_ratio: float = 0.2

Fraction of the samples held out to measure validation loss while fitting the network, from 0 up to but not including 1. Setting it to 0 trains on every sample and leaves surrogate_patience and surrogate_restore_best with no signal to act on.

target_lhs_order class-attribute instance-attribute

target_lhs_order: int = 1

Order of the time derivative this configuration targets as the left-hand side: 1 for u_t, 2 for u_tt. It must equal the dataset's own left-hand-side order or the fit is rejected before it starts, and order 2 additionally requires lhs_auto_select=True.

burgers_preset classmethod

burgers_preset(**overrides: Any) -> DLGAConfig

DLGAConfig for the Burgers equation (epsilon=1e-3).

chafee_preset classmethod

chafee_preset(**overrides: Any) -> DLGAConfig

DLGAConfig for Chafee-Infante (epsilon=1e-5).

kdv_preset classmethod

kdv_preset(**overrides: Any) -> DLGAConfig

DLGAConfig for the KdV equation (epsilon=1e-6).

kg_preset classmethod

kg_preset(**overrides: Any) -> DLGAConfig

DLGAConfig for the Klein-Gordon equation (u_tt LHS, epsilon=1e-3).

wave_preset classmethod

wave_preset(**overrides: Any) -> DLGAConfig

DLGAConfig for the wave equation (u_tt LHS, epsilon=1e-3).

DiscoverConfig dataclass

Configuration for a DISCOVER (RL + optional PINN) search run.

attention class-attribute instance-attribute

attention: bool = False

When True, the controller applies additive (Bahdanau) attention over a sliding window of its own recent outputs before producing token logits. The window length is attn_length.

attn_length class-attribute instance-attribute

attn_length: int = 10

Length of the attention window, in past controller steps. It has no effect when attention is False.

baseline class-attribute instance-attribute

baseline: str = 'R_e'

Value subtracted from the rewards in the policy-gradient loss. "R_e" (the default) uses the risk-seeking reward quantile itself, "ewma_R" a moving average of the mean kept reward, and "combined" the quantile plus a moving average of the gap between the two.

batch_size class-attribute instance-attribute

batch_size: int = 16

Number of candidate expressions sampled per search iteration, and the batch the policy-gradient update is computed from. Larger values give a steadier training signal at more compute per iteration.

diagnostic_scaffold class-attribute instance-attribute

diagnostic_scaffold: bool = False

Attach the diagnostic scaffold prior, which restricts sampling in the first search cycle to a root token from diagnostic_scaffold_root_tokens whose two branches draw on disjoint token sets. Off by default; True also requires DISCOVER_ENABLE_DIAGNOSTICS=1 in the environment, because the scaffold builds an assumed equation shape into the search.

diagnostic_scaffold_diffusion_tokens class-attribute instance-attribute

diagnostic_scaffold_diffusion_tokens: tuple[str, ...] = ()

Token names the scaffold keeps to the left branch of the root: each one is excluded from sampling while the right branch is filled. Read only when diagnostic_scaffold is True, and a name also listed as neutral is exempt.

diagnostic_scaffold_neutral_tokens class-attribute instance-attribute

diagnostic_scaffold_neutral_tokens: tuple[str, ...] = ()

Token names the scaffold never excludes, so they stay samplable in both branches even when they also appear in the diffusion or reaction list. Read only when diagnostic_scaffold is True; a name shared with diagnostic_scaffold_root_tokens is rejected.

diagnostic_scaffold_reaction_tokens class-attribute instance-attribute

diagnostic_scaffold_reaction_tokens: tuple[str, ...] = ()

Token names the scaffold keeps to the right branch of the root: each one is excluded from sampling while the left branch is filled. Read only when diagnostic_scaffold is True, and a name also listed as neutral is exempt.

diagnostic_scaffold_root_tokens class-attribute instance-attribute

diagnostic_scaffold_root_tokens: tuple[str, ...] = (
    "add",
    "sub",
)

Token names the scaffold allows at the root of a sampled expression; at the first sampling step every other token is excluded, so the tree starts from one of these. Defaults to ("add", "sub") and is read only when diagnostic_scaffold is True; a set in which no name exists in the token library fails when the search is built.

embedding_dim class-attribute instance-attribute

embedding_dim: int = 4

Width of the learned embedding used for each categorical observation channel. It has no effect unless use_embedding is True, which replaces the one-hot inputs with embeddings of this size.

entropy_gamma class-attribute instance-attribute

entropy_gamma: float = 1.0

Per-position decay of the entropy bonus: the entropy at position t of a sampled sequence is weighted by entropy_gamma ** t. The default 1.0 weights every position equally; values below 1 concentrate the exploration bonus on the first tokens.

entropy_weight class-attribute instance-attribute

entropy_weight: float = 0.005

Weight of the entropy bonus added to the policy-gradient loss, which rewards a less peaked sampling distribution. Must be non-negative; raise it when the controller commits to one expression family too early, set 0.0 to drop the bonus.

epsilon class-attribute instance-attribute

epsilon: float = 0.05

Risk-seeking quantile: the policy-gradient update keeps the batch rewards at or above the 1 - epsilon quantile (RSPGStrategy), so a smaller value is a greedier update off fewer samples. Ties at the quantile are all kept, so the retained share can exceed epsilon (an all-equal batch keeps everything). Must lie in (0, 1]. The packaged PDE presets use 0.01-0.02; the delta registry records the lineage of the 0.05 default in D-028.

gamma class-attribute instance-attribute

gamma: float = 0.5

Decay of the moving-average baseline: the running value keeps weight gamma and the new batch contributes 1 - gamma. In the range 0 to 1, and only read when baseline is "ewma_R" or "combined".

initializer class-attribute instance-attribute

initializer: Literal['xavier', 'zeros'] = 'xavier'

Parameter initialization scheme, either "xavier" or "zeros". "xavier" draws all parameters from a Xavier/uniform baseline; "zeros" also zeroes the LSTM cell parameters and the output bias, making the initial token distribution uniform.

learning_rate class-attribute instance-attribute

learning_rate: float = 0.001

Step size of the Adam optimizer that updates the controller network. A run resumed from a checkpoint adopts this value rather than the one saved with the checkpoint.

library class-attribute instance-attribute

library: LibraryConfig

Ordered vocabulary of tokens that candidate terms are built from, defaulting to ["u", "u_x", "u_xx", "u_xxx"]. Each term is a product of tokens drawn from this list, and the ordering matters: one of the mutation operators shifts a token to an adjacent entry.

magnitude_filter class-attribute instance-attribute

magnitude_filter: bool = False

When True, a fit whose active coefficients include any magnitude below 5e-5 or above 1e4 is marked invalid, so it scores zero reward and is dropped from controller training. Defaults to False, which accepts a fit at any coefficient magnitude.

max_diff_order class-attribute instance-attribute

max_diff_order: int | None = 4

Highest cumulative derivative order allowed in a sampled expression; candidates above it are rejected before evaluation. Orders accumulate along a chain, so diff2_x(diff_x(u)) counts as 3, and None disables the check.

max_length class-attribute instance-attribute

max_length: int = 15

Maximum number of tokens in a sampled sentence, counting the pinned start_words prefix; sampling stops there if no end token is drawn first. It must exceed len(start_words) and stay below the model's context length, and the default 49 is one below the pretrained context.

min_length class-attribute instance-attribute

min_length: int = 2

Minimum length of a sampled expression, in tokens. The sampler is forbidden from ending an expression before this many tokens, and any candidate that still comes out shorter is rejected before evaluation.

n_iterations class-attribute instance-attribute

n_iterations: int = 2000

Number of search iterations the standalone entry point runs, one controller batch per iteration. Ignored when the search is driven through kd.Model, where Model(generations=...) sets the loop length.

num_layers class-attribute instance-attribute

num_layers: int = 1

Number of stacked LSTM layers in the controller. Layers beyond the first take the previous layer's hidden state as their input.

num_units class-attribute instance-attribute

num_units: int = 16

Number of hidden units in each LSTM layer of the controller. It also sets the width of the attention projections when attention is enabled.

observe_action class-attribute instance-attribute

observe_action: bool = False

When True, the token sampled at the previous step is added to the controller input, as a one-hot vector or as an embedding when use_embedding is set.

observe_dangling class-attribute instance-attribute

observe_dangling: bool = False

When True, the count of unfilled argument slots in the partial expression tree is appended to the controller input as a single numeric value. This channel is always a raw count, so use_embedding does not apply to it.

observe_parent class-attribute instance-attribute

observe_parent: bool = True

When True, the parent token of the position about to be sampled is added to the controller input, as a one-hot vector or as an embedding when use_embedding is set. At least one of the four observation channels must be enabled.

observe_sibling class-attribute instance-attribute

observe_sibling: bool = True

When True, the left sibling token of the position about to be sampled is added to the controller input, as a one-hot vector or as an embedding when use_embedding is set. At least one of the four observation channels must be enabled.

pinn class-attribute instance-attribute

pinn: PINNConfig | None = None

Settings for the optional PINN surrogate, which alternates symbolic search with training a network on the data and takes derivatives from that trained network. None (the default) searches on finite-difference derivatives; kd.Model rejects a non-None value because it never runs the PINN cycle.

repeat_max class-attribute instance-attribute

repeat_max: int = 5

Maximum combined number of times the repeat_tokens may appear in one expression; on reaching the count those tokens are removed from the sampling distribution for the rest of that expression. Read only when use_repeat_prior is true.

repeat_tokens class-attribute instance-attribute

repeat_tokens: list[str]

Token names counted by the repeat limit, sharing one budget: their occurrences are pooled and compared against repeat_max. Read only when use_repeat_prior is true, and every name must exist in the token library.

reward_alpha class-attribute instance-attribute

reward_alpha: float = 0.01

Weight of the complexity penalty in the reward (1 - reward_alpha * complexity) / (1 + sqrt(nmse)). Larger values push the search toward shorter equations; since the reward is clipped at 0, a large value flattens long candidates to zero reward.

seed class-attribute instance-attribute

seed: int = 0

Random seed of the search: torch.manual_seed is called with this value when the algorithm is constructed and again before the engine is built, so it governs both the controller's weight initialization and every token sampled from it. It is the only seeding entry and overrides a torch.manual_seed the caller made beforehand.

soft_length_loc class-attribute instance-attribute

soft_length_loc: float | None = None

Target expression length in tokens: past position soft_length_loc the sampling logits of operator tokens are reduced by (t - soft_length_loc)**2 / (2 * soft_length_scale), so sampling tends to terminate near that length. None, the default, leaves the prior off.

soft_length_scale class-attribute instance-attribute

soft_length_scale: float = 5.0

Width of the length penalty past soft_length_loc, which is (t - soft_length_loc)**2 / (2 * soft_length_scale): larger values make the pull toward the target length gentler. Must be positive, and is read only when soft_length_loc is set.

stability_queue_capacity class-attribute instance-attribute

stability_queue_capacity: int = 10

Maximum number of distinct candidates kept in the reward-ordered per-cycle pool that stability selection draws from. Read only when stability_selection is greater than 0, and must be at least as large as it.

stability_selection class-attribute instance-attribute

stability_selection: int = 0

Number of distinct top-reward candidates from the final search cycle that enter bootstrap stability selection, which re-fits each candidate on resampled rows and keeps the one that wins the most resamples. 0 (the default) skips the step and keeps the best-reward candidate; only a run driven by the PINN surrogate applies it.

token_bias_tokens class-attribute instance-attribute

token_bias_tokens: tuple[str, ...] = ()

Token names whose sampling probability is shifted by token_bias_weight, identically at every step of every sampled expression. The bias applies only when this list is non-empty and token_bias_weight is not 0.0; a name absent from the token library is skipped.

token_bias_weight class-attribute instance-attribute

token_bias_weight: float = 0.0

Amount added to the log-probability of every token in token_bias_tokens, the same at each sampling step. Positive values make those tokens more likely and negative values less likely; 0.0 (the default) leaves the bias off.

use_diff_child_prior class-attribute instance-attribute

use_diff_child_prior: bool = True

If True, restrict the child of a derivative token to a state variable or another derivative token; coordinate variables and every other operator are forbidden in that position. This keeps constant terms such as diff_x(x) out of the search.

use_diff_descendant_prior class-attribute instance-attribute

use_diff_descendant_prior: bool = True

If True, forbid add and sub anywhere inside the subtree of a derivative token, so no sampled candidate differentiates a sum.

use_embedding class-attribute instance-attribute

use_embedding: bool = False

When True, the categorical observation channels enter the controller as learned embeddings of width embedding_dim instead of one-hot vectors. The dangling- slot count is unaffected and stays a single numeric input.

use_inverse_prior class-attribute instance-attribute

use_inverse_prior: bool = True

If True, forbid a unary token from being the direct child of its own inverse, so cancelling pairs such as exp(log(u)) and sqrt(n2(u)) are never sampled. Only pairs whose two tokens are both in the library are constrained.

use_repeat_prior class-attribute instance-attribute

use_repeat_prior: bool = True

If True, stop a token from being sampled again once it has already appeared repeat_max times in the expression being built. The tokens subject to the limit are named in repeat_tokens; with the defaults this caps add at five and so bounds the number of additive terms.

use_trig_prior class-attribute instance-attribute

use_trig_prior: bool = True

If True, forbid trigonometric and derivative tokens anywhere inside the subtree of another trigonometric or derivative token. This rules out compositions such as sin(cos(u)) and, because derivative tokens are included, nested derivatives such as diff_x(diff_x(u)).

burgers_preset classmethod

burgers_preset(**overrides: Any) -> DiscoverConfig

Config matching DISCOVER reference for the Burgers equation.

chafee_preset classmethod

chafee_preset(**overrides: Any) -> DiscoverConfig

Config matching DISCOVER reference for the Chafee-Infante equation.

EqGPTConfig dataclass

Static configuration for the EqGPT plugin.

asset_dir class-attribute instance-attribute

asset_dir: Path | None = None

Directory holding the pretrained GPT checkpoint at gpt_model/PDEGPT_wave_breaking.pt, consulted when weights_path is unset. With both unset the directory is read from the KD_EQGPT_ASSET_DIR environment variable; the weights are not distributed with the package, so a run with none of the three given raises FileNotFoundError.

case_filter class-attribute instance-attribute

case_filter: str | None = None

Substring matched against the wave-breaking case names: every case whose name contains it is scored, and a candidate's reward is the mean over the cases that could be scored. Setting it selects multi-case wave mode; None (default) keeps the single-case path.

coeff_points_per_window class-attribute instance-attribute

coeff_points_per_window: int = 100

Number of x sample points per camera window on the grid used for the final coefficient fits. This grid stays separate from the reward grid (reward_points_per_window): scoring runs on the reward grid, the reported coefficients are fitted on this one.

exploration_rate class-attribute instance-attribute

exploration_rate: float = 0.2

Probability of drawing the next token uniformly from the legal tokens instead of from the model's distribution, from 0 to 1. The draw is made independently at every token position.

finetune_lr class-attribute instance-attribute

finetune_lr: float = 1e-05

Learning rate of the Adam optimizer that fine-tunes the model on the pool of best candidates. A resumed run adopts the current value: the restored optimizer keeps its moment estimates but takes its learning rate from this field.

finetune_steps class-attribute instance-attribute

finetune_steps: int = 5

Number of gradient steps taken on the pool of best candidates after each iteration. Each step is one full pass over the pool, and the reported fine-tuning loss is the mean over the steps.

is_steady property

is_steady: bool

True when the plugin runs its homogeneous free-pivot path.

is_wave_multicase property

is_wave_multicase: bool

True when the plugin runs in multi-case wave mode.

masked_tokens class-attribute instance-attribute

masked_tokens: frozenset[int]

Extra vocabulary token ids the sampler must never emit. They are added to the masks the algorithm derives on its own from the declared axes, the derivative order the data supports, and the tokens the platform can represent, so this parameter only ever widens the mask.

max_length class-attribute instance-attribute

max_length: int = 49

Maximum number of tokens in a sampled sentence, counting the pinned start_words prefix; sampling stops there if no end token is drawn first. It must exceed len(start_words) and stay below the model's context length, and the default 49 is one below the pretrained context.

primary_case class-attribute instance-attribute

primary_case: str | None = None

Name of the case, among those case_filter selects, whose coefficient fit is reported as the run's final result. When None (default) the first selected case in sorted order is used; a name outside the selection, or a value given without case_filter, is rejected.

reward_points_per_window class-attribute instance-attribute

reward_points_per_window: int = 50

Number of x sample points per camera window on the grid used to score candidates. The grid covers three camera windows, so each time slice contributes three times this value; it must be a positive integer.

samples_per_epoch class-attribute instance-attribute

samples_per_epoch: int = 400

Number of candidate sentences drawn from the model per iteration; the platform uses it as the batch size for each search iteration. Sentences that cannot be converted into a valid expression are dropped, so fewer candidates may reach scoring.

seed class-attribute instance-attribute

seed: int = 0

Random seed of candidate sampling: it seeds the generator that hands every sampling call its own sub-seed, exploration draws included. A run resumed from a checkpoint restores the saved generator state instead, and falls back to this value only when the checkpoint carries none.

sparsity_alpha instance-attribute

sparsity_alpha: float

Weight of the term-count penalty in the reward: a candidate's R^2 is multiplied by 1 - sparsity_alpha * log10(number of distinct terms). It has no default because the value is problem-specific; the Burgers and wave presets pin 0.02 and the steady presets 1.0.

start_words class-attribute instance-attribute

start_words: tuple[str, ...] = ('S', 'ut', '+')

Vocabulary words pinned at the head of every sampled sentence, so generation always continues from the same prefix. The default ("S", "ut", "+") fixes the left-hand side to the time derivative, and the prefix is removed from the right- hand side the algorithm reports.

steady class-attribute instance-attribute

steady: bool = False

Run the time-independent EqGPT search, where each candidate is a homogeneous relation whose terms sum to zero rather than an equation with a fixed left-hand side. The first term's coefficient is pinned to 1 and the remaining coefficients are fitted by least squares on a surrogate network the algorithm trains itself; enabling it requires start_words=("S",) and steady_activation, and excludes case_filter.

steady_activation class-attribute instance-attribute

steady_activation: Literal['sin', 'rational'] | None = None

Activation function of the surrogate network trained in steady mode, either "sin" or "rational". The choice also selects that network's weight initialization; it is required when steady is True and must stay None otherwise.

steady_boundary_delete_num class-attribute instance-attribute

steady_boundary_delete_num: int | None = None

Width, in grid cells, of the border removed from the steady evaluation domain; None (the default) keeps every dataset point. A point survives only if it sits at least this many cells from every edge with a fully populated surrounding block, so the data must lie on a grid; it requires steady=True and excludes steady_polar_eval.

steady_constant_column class-attribute instance-attribute

steady_constant_column: bool = False

Add a constant column to the term matrix used to score and refit steady candidates, letting the recovered relation carry a constant offset. Requires steady=True.

steady_polar_eval class-attribute instance-attribute

steady_polar_eval: bool = False

Score steady candidates on a generated polar domain instead of the dataset's own points. The domain is 100 radii from 0.5 to 1.45 crossed with 100 angles over the full circle, converted to (x, y); it requires steady=True and excludes steady_boundary_delete_num.

steady_surrogate_seed class-attribute instance-attribute

steady_surrogate_seed: int = 525

Random seed for the steady surrogate; it fixes both the network's initial weights and the split of the data into training and validation points. It is separate from seed, which drives candidate sampling, and a value other than the default 525 requires steady=True.

steady_train_iters class-attribute instance-attribute

steady_train_iters: int = 50000

Number of optimizer iterations used to train the steady surrogate over the full training sample, 50000 by default. The whole budget runs unless the loss becomes non-finite, in which case training rolls back to the last finite weights and stops; a value other than the default requires steady=True.

steady_train_points class-attribute instance-attribute

steady_train_points: int = 10000

Number of dataset points sampled to train the steady surrogate network, 10000 by default. The sample is capped at one below the number of available points so a validation point remains; a value other than the default requires steady=True.

steady_validate_points class-attribute instance-attribute

steady_validate_points: int = 1000

Number of points held out from the training sample to validate the steady surrogate, 1000 by default. Training keeps the checkpoint with the lowest validation loss; the count is capped by whatever points steady_train_points leaves, and a value other than the default requires steady=True.

top_k class-attribute instance-attribute

top_k: int = 10

Maximum size of the running pool of best candidates, which is held sorted by reward and deduplicated by reward value. The same pool is the corpus the model is fine-tuned on after every iteration, so this sets both the pool cap and the fine- tuning batch.

v1_asset_dir class-attribute instance-attribute

v1_asset_dir: Path | None = None

Directory holding the pretrained per-case surrogate checkpoints used to evaluate candidate terms in multi-case wave mode; one checkpoint is loaded per selected case. When None (default), the directory is taken from the KD_V1_WAVE_ASSETS environment variable, and if neither is set preparation raises FileNotFoundError.

variables class-attribute instance-attribute

variables: tuple[str, ...] | None = None

Coordinate axis names the equation is allowed to mention; vocabulary tokens naming an axis outside this set are masked out of sampling. None (the default) takes the axes from the dataset, and an explicit value must match the dataset axes exactly or the run fails to start.

wave_pkl_path class-attribute instance-attribute

wave_pkl_path: Path | None = None

Path to the pickle file of wave-breaking cases that case_filter selects from. When None (default), it resolves to data/hf- knowledgediscover/WaveBreaking.pkl under the project root, and a missing file raises FileNotFoundError.

weights_path class-attribute instance-attribute

weights_path: Path | None = None

Path to the pretrained GPT checkpoint file, taking precedence over asset_dir and the KD_EQGPT_ASSET_DIR environment variable. When set, the file must exist: a missing path raises FileNotFoundError instead of falling back to the other two sources.

burgers_preset classmethod

burgers_preset(**overrides: Any) -> EqGPTConfig

EqGPTConfig for the Burgers equation (sparsity_alpha=0.02).

steady_preset classmethod

steady_preset(
    dataset: Literal["eitech", "smile", "disk"],
    **overrides: Any,
) -> EqGPTConfig

Build one of the three published steady EqGPT configurations.

wave_preset classmethod

wave_preset(**overrides: Any) -> EqGPTConfig

EqGPTConfig for the wave-breaking multi-case showcase.

Llm4edConfig dataclass

Static configuration for the LLM4ED plugin.

Attributes:

  • temperature (float) –

    LLM sampling temperature. Default 0.8 (EDL Burgers, NOT the generic 1.0). Packed into LLMParams per call.

  • max_tokens (int) –

    LLM max decode tokens. Default 1024 (kd-side pin; EDL does not fix a value).

  • stop_threshold (float) –

    is_done fires when best_reward >= stop_threshold. Default 0.995 (EDL); reward direction is max, range ~(0, 1].

  • reward_limit (float) –

    filter_score drops candidates with score <= reward_limit. Default 0.5 (EDL).

  • pool_size (int) –

    Elite pool capacity k (EDL PriorityQueue). Default 5.

  • init_num (int) –

    The number of equations the init PROMPT asks the LLM to generate (EDL optimzier_utils.py:108, prompt-text only). Does NOT change the returned batch size, which is n like every round (EDL GENERATION_NUM = args.N covers initialization).

  • samples_per_epoch (int) –

    Per-round proposal count -- the Runner's per-iteration batch size (EDL --N / GENERATION_NUM, Burgers script Num=8). Default 8. Read by the plugin's runner_batch_size property.

  • max_llm_calls_per_propose (int) –

    Plugin-owned upper bound on resample complete() calls within one propose. kd guardrail.

  • max_llm_calls_per_run (int) –

    Whole-run call budget fed to the default chain's BudgetedProvider. kd guardrail.

  • seed (int) –

    Base seed for the monotonic per-call LLM seed counter.

  • model (str) –

    LLM model id for the default OpenAICompatProvider (transport; unused when a provider is injected).

  • base_url (str | None) –

    Optional endpoint override for the default provider.

  • tape_record_path (str | None) –

    Optional JSONL path.

config property

config: dict[str, Any]

JSON-safe config dict prefixed {"algorithm": "llm4ed", ...}.

PySRConfig dataclass

Frozen configuration for a PySR symbolic-regression run.

Fields: - terms: the Theta library -- the candidate term columns (kd funcall IR) PySR regresses over. Must be non-empty. - seed: random seed forwarded to PySR's random_state. Weak reproducibility only: PySR upstream warns that random_state without deterministic=True and serial execution does not pin run-to-run results (observed in smoke), so under kd defaults the seed makes runs statistically similar, not bit-identical -- and the run manifest's seed inherits this weaker meaning for PySR runs. For full determinism pass extra_pysr_kwargs={"deterministic": True, "parallelism": "serial"}, at a significant speed cost. - niterations: number of PySR internal GP iterations (algebraic generations inside PySR); the facade generations parameter maps here. It controls only PySR's own evolutionary loop, never the kd runner loop. On a resume it is the number of FURTHER iterations the new segment runs from the archived populations (an increment, not a total). - population_size / populations / maxsize: PySR GP knobs (per-population members, number of populations, max expression size). - binary_operators / unary_operators: operator sets exposed to PySR. Defaults are the kd-IR-convertible subset; adding "^" or a custom operator may cause the downstream from_sympy conversion to fail hard. - extra_pysr_kwargs: a pass-through seam splatted into the underlying PySRRegressor constructor. The caller owns the JSON-safe (and PySR-valid) responsibility for whatever it puts here; defaults to None (never a shared mutable {}).

PySINDyConfig dataclass

Frozen configuration for a PySINDy STLSQ fit.

extra_optimizer_kwargs class-attribute instance-attribute

extra_optimizer_kwargs: dict[str, Any] | None = None

Extra keyword arguments forwarded to the underlying PySINDy optimizer for settings with no field of their own, such as the ridge parameter alpha. threshold, max_iter, normalize_columns and unbias are rejected here, because a shadowed value would leave the recorded configuration describing a fit that never ran. Set those fields directly instead.

max_iter class-attribute instance-attribute

max_iter: int = 20

Upper bound on the number of thresholding rounds the fit runs, in iterations; must be greater than 0. It caps the solver's own convergence loop rather than a search budget, so kd.Model(generations=...) leaves it unchanged and it can only be set here.

normalize_columns class-attribute instance-attribute

normalize_columns: bool = False

Whether the fit rescales the library columns to comparable magnitude before thresholding, so a term's units alone do not decide whether it survives. Turning it on moves the scale that threshold acts on, so the two are chosen together; reported coefficients are returned in the original units either way.

seed class-attribute instance-attribute

seed: int = 0

Random seed recorded in the run manifest next to the dataset fingerprint. This fit is deterministic and never draws on the value, so changing it alone does not change the result.

terms class-attribute instance-attribute

terms: tuple[str, ...] = ("u", "u_x", "u_xx", "mul(u, u_x)")

Ordered catalog of candidate right-hand-side terms; each entry becomes one column of the regression matrix, in the order given. The catalog must be non-empty and its entries must stay distinct once canonicalized; the fit reports the terms whose coefficients survive thresholding.

threshold class-attribute instance-attribute

threshold: float = 0.1

Coefficient magnitude below which a candidate term is dropped during the sequentially thresholded fit; must be finite and at least 0. A value too large for the data leaves nothing selected, which raises an error quoting the current threshold instead of returning an empty equation.

unbias class-attribute instance-attribute

unbias: bool = True

Whether the fit ends with an unregularized least-squares refit over the terms that survived thresholding, undoing the shrinkage the sparse fit introduces. The result reports the coefficients from that final refit, so this setting is visible in the published coefficient values.