Survey Driver¶
One driver runs the survey for every backend. It owns the checkpoint cadence, the halt rule and the monitor, and a backend owns the search.
The next chunk of work goes to the device before the monitor runs, so host work in a monitor overlaps device work. The map read and the tree read come first, because the next chunk changes the archive.
The halt_rule parameter selects one of two halt rules. The driver decides the
halt for every backend, so each parameter of each rule has one meaning on every
engine.
"qd_score", the default. At each checkpoint the driver records the sumS, the countNand the running minimummof the elite log-likelihoods. The survey halts when a doubling of effort multiplies the QD-scoreS - N mby2**qd_tauor less. The rule judges no checkpoint before2**HALT_QD_GUARD_DOUBLINGStimes the variations of the first checkpoint. The rule is inhifuku.halt. When the budget ends first, the driver issues aRuntimeWarningthat gives the growth exponent and three projections of the cost to reachqd_tau. A budget with too few checkpoints to pass the guard gives aRuntimeWarningbefore the run."rate". The survey halts when the trailing window ofrate_windowcheckpoints thatwindowed_ratesmeasures falls to or belowrate_coverage_epsandrate_precision_eps. A budget with fewer checkpoints thanrate_windowgives aRuntimeWarningbefore the run.
The run parameters page lists the parameters of each rule and their defaults.
Every checkpoint also records a landscape row, a move tally and its row of
(S, N, m), under either rule.
run_survey
¶
Run one survey on one backend and return the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
An object that obeys the :class: |
required | |
ctx
|
RunContext
|
The trees, alignment, model and chart geometry for this survey. It is also what an engine sizes the run against. |
required |
params
|
ArchiveParams
|
The resolved run parameters. A field left as |
required |
monitor
|
(callable, None or False)
|
A checkpoint callback. None selects the default reporter and False
turns reporting off. See :mod: |
None
|
task
|
SurveyTask
|
Passed to the monitor so that a caller can tell surveys apart. |
None
|
resume
|
RunSnapshot
|
Carry on a survey that stopped. The archive and the random state are restored in place of seeding, so the run continues rather than starting a similar one.
On both engines a resumed survey reaches the elites that an unbroken survey of the same total length reaches. This is true for a snapshot in hand and for a snapshot read back from a file. Both engines hold every tree they walk from in canonical form, so a restored archive has the numbering of the archive in the unbroken run. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The monitor names an unknown value, or a value this backend cannot serve. The check runs before any survey work starts. |
Source code in src/hifuku/driver.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 | |
ArchiveResult
dataclass
¶
A completed survey: the archive, its history, and the halt state.
history has one row per checkpoint of
(iteration, n_filled, best_logL, coverage_rate, precision_rate), after a
first row that records the seeded archive. The two rates are scale
invariant. See :func:windowed_rates. They are NaN until a full window of
checkpoints has run.
params is the shape the run actually had, which is not always the shape
the caller passed: a parameter left as "auto" is settled by the engine
against the memory it holds and the gene under survey. A caller that
records what a survey cost records these rather than its own.
Source code in src/hifuku/driver.py
windowed_rates
¶
Trailing-window coverage and precision rates for the halt.
Both rates are scale invariant in the size of the domain. coverage is
the growth of the filled set per checkpoint, as a fraction of the filled
count. precision is the mean per-niche elite gain per checkpoint, as a
fraction of the elite range.
The division by n_filled makes both rates settle toward zero whether the
domain holds tens of niches or tens of thousands. One pair of thresholds
therefore fits any cell size and any gate margin.
Both rates are NaN until rate_window checkpoints exist. A NaN compares
False against a threshold, so a short run does not halt by accident.
Source code in src/hifuku/driver.py
survey_converged
¶
Discovery saturation: both windowed rates at or below their thresholds.
Coverage is the crisp signal. Precision uses a loose threshold because refinement inside a niche never fully stops.