Skip to content

Run Parameters

Every value that controls a survey is a field of one of these two classes, one key of the plan file, and one command-line flag. The command-line surface is generated from dataclasses.fields(), so a new field reaches all three places.

ArchiveParams holds the values with the same meaning on every backend. GpuParams holds the values only a device backend can use. The two stay separate so that a device value on a host run is an error and not a setting with no effect.

A caller gives ordered override layers to resolve: the backend capability defaults, then the plan file, then the command-line flags. A later layer wins.

Halt parameters

halt_rule selects the rule that halts a survey. Each other halt parameter belongs to one rule.

Parameter Rule Default
halt_rule both "qd_score"; the other value is "rate"
qd_tau QD-score HALT_QD_TAU = 0.25
rate_window rate HALT_RATE_WINDOW = 10 checkpoints
rate_coverage_eps rate HALT_RATE_COVERAGE_EPS = 2.0e-4
rate_precision_eps rate HALT_RATE_PRECISION_EPS = 1.0e-4

converge and force_full_run have the same meaning under both rules. qd_tau must lie between 0 and 1, exclusive. A parameter of the rule not in use must keep its default value. Otherwise validation raises ValueError, and the message names the rule in use. The guard of the QD-score rule is the constant HALT_QD_GUARD_DOUBLINGS, not a parameter.

When checkpoint_every is auto and a halt is asked for, fitted caps the cadence so that the budget holds enough checkpoints for the rule. Under the QD-score rule the cap is n_iters // HALT_QD_MIN_CHECKPOINTS. Under the rate rule it is n_iters // rate_window.

Parameters of a stored record

The task digest of a record hashes the fields named in DIGESTED_FIELDS, with their stored values. A test holds DIGESTED_FIELDS equal to digested_fields(ArchiveParams), so a field added without a schema step stops the suite.

ArchiveParams.from_record rebuilds the parameters of a stored record. Verification and replay both rebuild parameters through it. A record of schema 15 written before 2026-11-25 stores two fields that no parameter set has any more, legacy_qd_halt in its parameters and legacy_binning in its device parameters, both as False. stored_fields leaves them out of a copy and does not change the stored mapping, so the seal of the record still holds. A retired field set to any other value is refused.

Classes

ArchiveParams dataclass

Survey parameters with the same meaning on every backend.

Every field is declared with :func:_asked or :func:_tuning, which says whether it decides what the survey is looking for or only how the engine goes about looking. :func:digested_fields reads that back, and the task digest covers the first group alone, so one batch keeps one identity wherever it runs.

Attributes:

Name Type Description
cell float or 'auto'

Niche side in barycentric units. The grid is unbounded. Two runs may set it differently inside one framework: it bins the plane the charts define rather than moving that plane, so a coarse sketch and a fine survey stay commensurable.

"auto" takes it from the chart and the gene, as the step one nearest-neighbor interchange makes across the chart. A cell wider than that step is a cell the survey cannot leave, and the width that satisfies it falls as one over the taxon count, so no fixed number serves trees of every size. A prune-regraft crosses many cells at once, so no width resolves both topological moves and this resolves the interchange. Unlike the walker count this is a function of the data and not of the machine, so the driver settles it and both engines get the same grid.

origin float

Grid origin on both axes. The niche lattice is anchored here, so zero puts the corner of niche (0, 0) on an anchor vertex. The reachable part of the chart is not centered on it, and the device extent covers the difference.

n_iters int

The survey budget cap in variations.

seed int

RNG seed.

sigma_slide, scale_width float

Proposal widths for the branch moves.

p_move_spr, p_move_nni, p_move_slide, p_move_scale float

How often a walk step takes each move: a prune-regraft, a nearest-neighbor interchange, a branch slide, and a branch scale. The four are one distribution over the moves and must sum to 1, which is checked and refused rather than corrected. Each carries at most three decimal places, and a finer one is refused as well, so the sum is checked in whole thousandths rather than against a tolerance. move_thresholds turns them into the bounds both engines test a draw against.

The two topological moves are what carry a walk across the chart, since the niche side is set to the step one interchange makes. The defaults are not measured. No measurement of the move mix is current.

logl_margin (float, optional)

Relative log-likelihood gate as a fixed number of nats below the best tree found. None leaves the gate to logl_margin_coeff.

logl_margin_coeff (float, optional)

Relative log-likelihood gate as this coefficient times the square root of the site count, used when logl_margin is None. None as well turns the gate off and leaves the budget as the only limit.

logl_floor (float, optional)

Absolute log-likelihood gate. Not permitted together with logl_margin.

converge bool

Halt by halt_rule when set.

force_full_run bool

Run the full budget and ignore the halt.

halt_rule str

The rule that decides when a survey halts: "qd_score" or "rate". The default is "qd_score". The QD-score rule halts when a doubling of effort multiplies the QD-score of the archive by 2**qd_tau or less, at a checkpoint and at its half checkpoint, so across two consecutive doublings. The rate rule halts when the windowed coverage and precision rates both fall to their thresholds. A parameter of the rule not in use must keep its default.

qd_tau float

The growth exponent at which a survey halts under the QD-score rule. It lies between 0 and 1, exclusive.

rate_window int

Trailing window in checkpoints for the halt rates. Used only under the rate rule.

rate_coverage_eps, rate_precision_eps float

Halt thresholds on the windowed coverage and precision rates. Used only under the rate rule.

checkpoint_every int or 'auto'

Variations between two checkpoints. This sets the halt granularity and the monitor resolution on both engines. "auto" leaves it to :meth:fitted, which sets it from the walker count.

n_walkers int or 'auto'

Parents drawn per pass. The GPU runs the walkers in parallel. The CPU runs them in a loop. "auto" leaves it to the engine, which sizes it to the memory the machine has and to the gene under survey.

walk_steps int

Moves each walker makes per pass. Each move writes one candidate.

Source code in src/hifuku/params.py
@dataclass(frozen=True)
class ArchiveParams:
    """Survey parameters with the same meaning on every backend.

    Every field is declared with :func:`_asked` or :func:`_tuning`, which says
    whether it decides what the survey is looking for or only how the engine
    goes about looking.  :func:`digested_fields` reads that back, and the task
    digest covers the first group alone, so one batch keeps one identity
    wherever it runs.

    Attributes
    ----------
    cell : float or "auto"
        Niche side in barycentric units.  The grid is unbounded.  Two runs may
        set it differently inside one framework: it bins the plane the charts
        define rather than moving that plane, so a coarse sketch and a fine
        survey stay commensurable.

        ``"auto"`` takes it from the chart and the gene, as the step one
        nearest-neighbor interchange makes across the chart.  A cell wider than
        that step is a cell the survey cannot leave, and the width that satisfies
        it falls as one over the taxon count, so no fixed number serves trees of
        every size.  A prune-regraft crosses many cells at once, so no width
        resolves both topological moves and this resolves the interchange.
        Unlike the walker count this is a function of the data and not of the
        machine, so the driver settles it and both engines get the same grid.
    origin : float
        Grid origin on both axes.  The niche lattice is anchored here, so zero
        puts the corner of niche ``(0, 0)`` on an anchor vertex.  The reachable
        part of the chart is not centered on it, and the device extent covers
        the difference.
    n_iters : int
        The survey budget cap in variations.
    seed : int
        RNG seed.
    sigma_slide, scale_width : float
        Proposal widths for the branch moves.
    p_move_spr, p_move_nni, p_move_slide, p_move_scale : float
        How often a walk step takes each move: a prune-regraft, a
        nearest-neighbor interchange, a branch slide, and a branch scale.  The
        four are one distribution over the moves and must sum to 1, which is
        checked and refused rather than corrected.  Each carries at most three
        decimal places, and a finer one is refused as well, so the sum is
        checked in whole thousandths rather than against a tolerance.
        ``move_thresholds`` turns them into the bounds both engines test a draw
        against.

        The two topological moves are what carry a walk across the chart, since
        the niche side is set to the step one interchange makes.  The defaults
        are not measured.  No measurement of the move mix is current.
    logl_margin : float, optional
        Relative log-likelihood gate as a fixed number of nats below the best
        tree found.  None leaves the gate to ``logl_margin_coeff``.
    logl_margin_coeff : float, optional
        Relative log-likelihood gate as this coefficient times the square root
        of the site count, used when ``logl_margin`` is None.  None as well
        turns the gate off and leaves the budget as the only limit.
    logl_floor : float, optional
        Absolute log-likelihood gate.  Not permitted together with
        ``logl_margin``.
    converge : bool
        Halt by ``halt_rule`` when set.
    force_full_run : bool
        Run the full budget and ignore the halt.
    halt_rule : str
        The rule that decides when a survey halts: ``"qd_score"`` or
        ``"rate"``.  The default is ``"qd_score"``.  The QD-score rule halts
        when a doubling of effort multiplies the QD-score of the archive by
        ``2**qd_tau`` or less, at a checkpoint and at its half checkpoint, so
        across two consecutive doublings.  The rate rule halts when the windowed
        coverage and precision rates both fall to their thresholds.  A
        parameter of the rule not in use must keep its default.
    qd_tau : float
        The growth exponent at which a survey halts under the QD-score rule.
        It lies between 0 and 1, exclusive.
    rate_window : int
        Trailing window in checkpoints for the halt rates.  Used only under
        the rate rule.
    rate_coverage_eps, rate_precision_eps : float
        Halt thresholds on the windowed coverage and precision rates.  Used
        only under the rate rule.
    checkpoint_every : int or "auto"
        Variations between two checkpoints.  This sets the halt granularity and
        the monitor resolution on both engines.  ``"auto"`` leaves it to
        :meth:`fitted`, which sets it from the walker count.
    n_walkers : int or "auto"
        Parents drawn per pass.  The GPU runs the walkers in parallel.  The CPU
        runs them in a loop.  ``"auto"`` leaves it to the engine, which sizes it
        to the memory the machine has and to the gene under survey.
    walk_steps : int
        Moves each walker makes per pass.  Each move writes one candidate.
    """

    cell: float | str = _asked(AUTO)
    origin: float = _asked(0.0)
    n_iters: int = _asked(ARCHIVE_N_ITERS)
    seed: int = _asked(0)
    sigma_slide: float = _asked(DEFAULT_SIGMA_SLIDE)
    scale_width: float = _asked(DEFAULT_SCALE_WIDTH)
    p_move_spr: float = _asked(P_MOVE_SPR)
    p_move_nni: float = _asked(P_MOVE_NNI)
    p_move_slide: float = _asked(P_MOVE_SLIDE)
    p_move_scale: float = _asked(P_MOVE_SCALE)
    logl_margin: float | None = _asked(None)
    logl_margin_coeff: float | None = _asked(ARCHIVE_LOGL_MARGIN_COEFF)
    logl_floor: float | None = _asked(None)
    converge: bool = _asked(True)
    force_full_run: bool = _asked(False)
    halt_rule: str = _asked(HALT_RULE_DEFAULT)
    qd_tau: float = _asked(HALT_QD_TAU)
    rate_window: int = _asked(HALT_RATE_WINDOW)
    rate_coverage_eps: float = _asked(HALT_RATE_COVERAGE_EPS)
    rate_precision_eps: float = _asked(HALT_RATE_PRECISION_EPS)
    checkpoint_every: int | str = _tuning(ARCHIVE_CHECKPOINT_EVERY)
    n_walkers: int | str = _tuning(ARCHIVE_WALK_M)
    walk_steps: int = _tuning(ARCHIVE_WALK_K)

    def __post_init__(self) -> None:
        if self.logl_margin is not None and self.logl_floor is not None:
            raise ValueError(
                "set logl_margin or logl_floor, not both; "
                "to use a floor, set logl_margin to None")
        for name in _POSITIVE:
            value = getattr(self, name)
            if value != AUTO and value < 1:
                raise ValueError(f"{name} must be 1 or more")
        freqs = [float(getattr(self, name)) for name in _MOVE_FREQUENCIES]
        for name, freq in zip(_MOVE_FREQUENCIES, freqs):
            if freq < 0.0:
                raise ValueError(
                    f"{name} is {freq}. A move frequency is how often a walk "
                    f"step takes that move, so it cannot be negative.")
            if round(freq, _MOVE_FREQUENCY_DECIMALS) != freq:
                raise ValueError(
                    f"{name} is {freq!r}, which is finer than the "
                    f"{_MOVE_FREQUENCY_DECIMALS} decimal places a move "
                    f"frequency carries. State it as "
                    f"{round(freq, _MOVE_FREQUENCY_DECIMALS)}. A thousandth is "
                    f"finer than any reason to prefer one mix to another, and "
                    f"capping the precision is what lets the four be checked "
                    f"against 1 exactly.")
        thousandths = [round(f * _MOVE_FREQUENCY_SCALE) for f in freqs]
        if sum(thousandths) != _MOVE_FREQUENCY_SCALE:
            stated = ", ".join(f"{n}={f}"
                               for n, f in zip(_MOVE_FREQUENCIES, freqs))
            raise ValueError(
                f"the move frequencies must sum to 1, but they sum to "
                f"{sum(thousandths) / _MOVE_FREQUENCY_SCALE}: {stated}. A walk "
                f"step draws one of these four moves, so the four are one "
                f"distribution over them. Set all four together.")
        if self.halt_rule not in HALT_RULES:
            raise ValueError(
                f"halt_rule is {self.halt_rule!r}; it must be one of "
                f"{', '.join(HALT_RULES)}")
        if not 0.0 < float(self.qd_tau) < 1.0:
            raise ValueError(
                f"qd_tau is {self.qd_tau}; the growth exponent at which a "
                f"survey halts lies between 0 and 1, exclusive")
        names = {"qd_score": "QD-score rule", "rate": "rate rule"}
        defaults = {f.name: f.default for f in fields(self)}
        for rule, owned in _RULE_FIELDS.items():
            if rule == self.halt_rule:
                continue
            changed = [n for n in owned if getattr(self, n) != defaults[n]]
            if changed:
                one = len(changed) == 1
                raise ValueError(
                    f"{', '.join(changed)} {'belongs' if one else 'belong'} "
                    f"to the {names[rule]}, and this survey runs the "
                    f"{names[self.halt_rule]}, so "
                    f"{'it has' if one else 'they have'} no effect.  Set "
                    f"halt_rule={rule!r} to use "
                    f"{'it' if one else 'them'}, or leave "
                    f"{'it at its default' if one else 'them at their defaults'}")

    @classmethod
    def from_record(cls, task_params: Mapping[str, Any]) -> "ArchiveParams":
        """Rebuild the parameters a stored record names.

        The retired fields are left out as :func:`stored_fields` says.
        """
        return cls(**stored_fields(task_params))

    @property
    def move_thresholds(self) -> tuple[float, float, float]:
        """The move frequencies as the bounds a single draw is tested against.

        The running total of the four, which is what turns one Uniform(0,1) draw
        into a move: below the first bound is a prune-regraft, below the second a
        nearest-neighbor interchange, below the third a branch slide, and at or
        above it a branch scale. The fourth bound is 1 and needs no test, so
        three are returned.

        Both engines read the mix here and nowhere else, so the host and the
        device cannot drift apart on what a walk step does.
        """
        spr = float(self.p_move_spr)
        nni = spr + float(self.p_move_nni)
        return spr, nni, nni + float(self.p_move_slide)

    @classmethod
    def resolve(cls, *layers: Mapping[str, Any]) -> "ArchiveParams":
        """Build the parameters from ordered override layers.

        A later layer wins over an earlier one.  Give the layers in this order:
        the backend capability defaults, the plan file, then the command-line
        flags.  An unknown field name raises ``ValueError``.
        """
        return cls(**_merge(cls, layers))

    @property
    def needs_fitting(self) -> bool:
        """True while a field is still the word ``"auto"``.

        The driver settles such a run before it starts, so a backend and a
        monitor never see parameters for which this is True.
        """
        return AUTO in (self.n_walkers, self.checkpoint_every, self.cell)

    @property
    def needs_a_cell(self) -> bool:
        """True while the cell is still the word ``"auto"``.

        The cell comes from the chart and the gene rather than from the engine,
        so the driver reads it off the run context and both engines are then
        given the same grid.  See :meth:`with_cell`.
        """
        return self.cell == AUTO

    def with_cell(self, cell: float) -> "ArchiveParams":
        """These parameters with the niche side settled.

        Returns them unchanged when the caller stated a cell of its own.
        """
        if not self.needs_a_cell:
            return self
        return replace(self, cell=float(cell))

    def _sized(self, name: str) -> int:
        """One shape field, or a refusal if the engine has yet to set it."""
        value = getattr(self, name)
        if value == AUTO:
            raise ValueError(
                f"{name} is {AUTO!r} and has not been sized yet, so the shape "
                f"of this run is not decided; call ArchiveParams.fitted with "
                f"the walker count the engine holds before reading it")
        return int(value)

    @property
    def variations_per_pass(self) -> int:
        """Candidates that one pass makes."""
        return self._sized("n_walkers") * self.walk_steps

    @property
    def passes_per_checkpoint(self) -> int:
        """Passes that run between two checkpoints.

        A backend submits this many passes and then lets the driver read the
        statistics.  The count is 1 or more, so a checkpoint cadence smaller
        than one pass still makes progress.
        """
        return max(1, self._sized("checkpoint_every") // self.variations_per_pass)

    @property
    def variation_budget(self) -> int:
        """Variations the full budget makes, counted as the driver runs them.

        ``n_iters`` is the budget a caller asks for.  What a run makes is a whole
        number of checkpoints of a whole number of passes, so the count lands on
        a multiple of the pass size and a short budget still buys one checkpoint.
        This reads that count rather than ``n_iters``, so that a caller sizing an
        allocation against it is never given a figure the run can pass.

        A halt can stop a survey early.  This is the budget, so it is an upper
        bound on the variations made and on the niches they can occupy.
        """
        per_checkpoint = self.passes_per_checkpoint * self.variations_per_pass
        return max(1, self.n_iters // per_checkpoint) * per_checkpoint

    def fitted(self, n_walkers: int) -> "ArchiveParams":
        """These parameters with the sizable fields settled on a walker count.

        ``n_walkers`` is what the engine measured that it holds.  It is taken
        only where the parameters asked for it: a layer that named a count keeps
        that count, because a stated shape is what the caller wanted and no
        measurement overrides it.

        The cadence follows the walkers.  It is set so that
        ``passes_per_checkpoint`` holds at
        ``DEVICE_PASSES_PER_CHECKPOINT`` whatever the walker count, which keeps
        a sized run the same distance from the point where too many device
        passes share one parent snapshot.  When a halt is asked for, the cadence
        is then capped.  Under the rate rule the cap makes the budget hold a
        full ``rate_window`` of checkpoints: the rate rule reads a trailing
        window, and a budget with fewer checkpoints than that can never fire
        it.  Under the QD-score rule the cap is ``n_iters`` divided by
        ``HALT_QD_MIN_CHECKPOINTS``, so that the budget holds the guard and
        several checkpoints after it.  The cap never takes the cadence below
        one pass, which would report a cadence no engine keeps.

        The grid is not settled here.  The cell and the origin come from the
        chart and the gene rather than from the machine, so the driver reads
        them off the run context with :meth:`on_grid` before it asks an engine
        for anything.

        Returns these parameters unchanged when nothing asked to be sized.
        """
        if not self.needs_fitting:
            return self

        walkers = (int(n_walkers) if self.n_walkers == AUTO
                   else int(self.n_walkers))
        cadence = self.checkpoint_every
        if cadence == AUTO:
            pass_size = walkers * self.walk_steps
            cadence = DEVICE_PASSES_PER_CHECKPOINT * pass_size
            if self.converge and not self.force_full_run:
                if self.halt_rule == "rate":
                    checkpoints = max(1, self.rate_window)
                else:
                    checkpoints = HALT_QD_MIN_CHECKPOINTS
                for_the_rule = self.n_iters // checkpoints
                cadence = max(pass_size, min(cadence, for_the_rule))
        return replace(self, n_walkers=walkers, checkpoint_every=int(cadence))

move_thresholds property

move_thresholds: tuple[float, float, float]

The move frequencies as the bounds a single draw is tested against.

The running total of the four, which is what turns one Uniform(0,1) draw into a move: below the first bound is a prune-regraft, below the second a nearest-neighbor interchange, below the third a branch slide, and at or above it a branch scale. The fourth bound is 1 and needs no test, so three are returned.

Both engines read the mix here and nowhere else, so the host and the device cannot drift apart on what a walk step does.

needs_fitting property

needs_fitting: bool

True while a field is still the word "auto".

The driver settles such a run before it starts, so a backend and a monitor never see parameters for which this is True.

needs_a_cell property

needs_a_cell: bool

True while the cell is still the word "auto".

The cell comes from the chart and the gene rather than from the engine, so the driver reads it off the run context and both engines are then given the same grid. See :meth:with_cell.

variations_per_pass property

variations_per_pass: int

Candidates that one pass makes.

passes_per_checkpoint property

passes_per_checkpoint: int

Passes that run between two checkpoints.

A backend submits this many passes and then lets the driver read the statistics. The count is 1 or more, so a checkpoint cadence smaller than one pass still makes progress.

variation_budget property

variation_budget: int

Variations the full budget makes, counted as the driver runs them.

n_iters is the budget a caller asks for. What a run makes is a whole number of checkpoints of a whole number of passes, so the count lands on a multiple of the pass size and a short budget still buys one checkpoint. This reads that count rather than n_iters, so that a caller sizing an allocation against it is never given a figure the run can pass.

A halt can stop a survey early. This is the budget, so it is an upper bound on the variations made and on the niches they can occupy.

from_record classmethod

from_record(task_params: Mapping[str, Any]) -> 'ArchiveParams'

Rebuild the parameters a stored record names.

The retired fields are left out as :func:stored_fields says.

Source code in src/hifuku/params.py
@classmethod
def from_record(cls, task_params: Mapping[str, Any]) -> "ArchiveParams":
    """Rebuild the parameters a stored record names.

    The retired fields are left out as :func:`stored_fields` says.
    """
    return cls(**stored_fields(task_params))

resolve classmethod

resolve(*layers: Mapping[str, Any]) -> 'ArchiveParams'

Build the parameters from ordered override layers.

A later layer wins over an earlier one. Give the layers in this order: the backend capability defaults, the plan file, then the command-line flags. An unknown field name raises ValueError.

Source code in src/hifuku/params.py
@classmethod
def resolve(cls, *layers: Mapping[str, Any]) -> "ArchiveParams":
    """Build the parameters from ordered override layers.

    A later layer wins over an earlier one.  Give the layers in this order:
    the backend capability defaults, the plan file, then the command-line
    flags.  An unknown field name raises ``ValueError``.
    """
    return cls(**_merge(cls, layers))

with_cell

with_cell(cell: float) -> 'ArchiveParams'

These parameters with the niche side settled.

Returns them unchanged when the caller stated a cell of its own.

Source code in src/hifuku/params.py
def with_cell(self, cell: float) -> "ArchiveParams":
    """These parameters with the niche side settled.

    Returns them unchanged when the caller stated a cell of its own.
    """
    if not self.needs_a_cell:
        return self
    return replace(self, cell=float(cell))

fitted

fitted(n_walkers: int) -> 'ArchiveParams'

These parameters with the sizable fields settled on a walker count.

n_walkers is what the engine measured that it holds. It is taken only where the parameters asked for it: a layer that named a count keeps that count, because a stated shape is what the caller wanted and no measurement overrides it.

The cadence follows the walkers. It is set so that passes_per_checkpoint holds at DEVICE_PASSES_PER_CHECKPOINT whatever the walker count, which keeps a sized run the same distance from the point where too many device passes share one parent snapshot. When a halt is asked for, the cadence is then capped. Under the rate rule the cap makes the budget hold a full rate_window of checkpoints: the rate rule reads a trailing window, and a budget with fewer checkpoints than that can never fire it. Under the QD-score rule the cap is n_iters divided by HALT_QD_MIN_CHECKPOINTS, so that the budget holds the guard and several checkpoints after it. The cap never takes the cadence below one pass, which would report a cadence no engine keeps.

The grid is not settled here. The cell and the origin come from the chart and the gene rather than from the machine, so the driver reads them off the run context with :meth:on_grid before it asks an engine for anything.

Returns these parameters unchanged when nothing asked to be sized.

Source code in src/hifuku/params.py
def fitted(self, n_walkers: int) -> "ArchiveParams":
    """These parameters with the sizable fields settled on a walker count.

    ``n_walkers`` is what the engine measured that it holds.  It is taken
    only where the parameters asked for it: a layer that named a count keeps
    that count, because a stated shape is what the caller wanted and no
    measurement overrides it.

    The cadence follows the walkers.  It is set so that
    ``passes_per_checkpoint`` holds at
    ``DEVICE_PASSES_PER_CHECKPOINT`` whatever the walker count, which keeps
    a sized run the same distance from the point where too many device
    passes share one parent snapshot.  When a halt is asked for, the cadence
    is then capped.  Under the rate rule the cap makes the budget hold a
    full ``rate_window`` of checkpoints: the rate rule reads a trailing
    window, and a budget with fewer checkpoints than that can never fire
    it.  Under the QD-score rule the cap is ``n_iters`` divided by
    ``HALT_QD_MIN_CHECKPOINTS``, so that the budget holds the guard and
    several checkpoints after it.  The cap never takes the cadence below
    one pass, which would report a cadence no engine keeps.

    The grid is not settled here.  The cell and the origin come from the
    chart and the gene rather than from the machine, so the driver reads
    them off the run context with :meth:`on_grid` before it asks an engine
    for anything.

    Returns these parameters unchanged when nothing asked to be sized.
    """
    if not self.needs_fitting:
        return self

    walkers = (int(n_walkers) if self.n_walkers == AUTO
               else int(self.n_walkers))
    cadence = self.checkpoint_every
    if cadence == AUTO:
        pass_size = walkers * self.walk_steps
        cadence = DEVICE_PASSES_PER_CHECKPOINT * pass_size
        if self.converge and not self.force_full_run:
            if self.halt_rule == "rate":
                checkpoints = max(1, self.rate_window)
            else:
                checkpoints = HALT_QD_MIN_CHECKPOINTS
            for_the_rule = self.n_iters // checkpoints
            cadence = max(pass_size, min(cadence, for_the_rule))
    return replace(self, n_walkers=walkers, checkpoint_every=int(cadence))

GpuParams dataclass

Survey parameters that only a device backend can use.

Attributes:

Name Type Description
extent float or 'auto'

Half-extent of the device niche allocation, measured from origin.

"auto" takes it from the chart, as the half-width of the part of the chart the metric can reach. Both terms of the metric lie in [0, 1], so no two trees are further apart than R = 1 and a barycentric coordinate is confined to [1 - R/h, R/h] about a midpoint of one half. A grid wider than that holds cells no survey can occupy.

A number instead is a memory bound and not a limit on the chart domain: a tree outside it is placed in the sink and dropped. The extent never changes which niche a tree is in.

Source code in src/hifuku/params.py
@dataclass(frozen=True)
class GpuParams:
    """Survey parameters that only a device backend can use.

    Attributes
    ----------
    extent : float or "auto"
        Half-extent of the device niche allocation, measured from ``origin``.

        ``"auto"`` takes it from the chart, as the half-width of the part of the
        chart the metric can reach.  Both terms of the metric lie in [0, 1], so
        no two trees are further apart than ``R = 1`` and a barycentric
        coordinate is confined to ``[1 - R/h, R/h]`` about a midpoint of one
        half.  A grid wider than that holds cells no survey can occupy.

        A number instead is a memory bound and not a limit on the chart domain:
        a tree outside it is placed in the sink and dropped.  The extent never
        changes which niche a tree is in.
    """

    extent: float | str = AUTO

    @classmethod
    def resolve(cls, *layers: Mapping[str, Any]) -> "GpuParams":
        """Build the parameters from ordered override layers.

        A later layer wins over an earlier one.  An unknown field name raises
        ``ValueError``.
        """
        return cls(**_merge(cls, layers))

resolve classmethod

resolve(*layers: Mapping[str, Any]) -> 'GpuParams'

Build the parameters from ordered override layers.

A later layer wins over an earlier one. An unknown field name raises ValueError.

Source code in src/hifuku/params.py
@classmethod
def resolve(cls, *layers: Mapping[str, Any]) -> "GpuParams":
    """Build the parameters from ordered override layers.

    A later layer wins over an earlier one.  An unknown field name raises
    ``ValueError``.
    """
    return cls(**_merge(cls, layers))