Skip to content

Move microcosm's QRF to quantile-forest 1.5.0 #1691

Open

Description

@anth-volk

Why

#1682 pins quantile-forest==1.4.2 exactly, because _InPlaceLeafQRF in packages/microcosm-fit/src/microcosm/fit/qrf.py overrides a private 1.4.2 method. That pin keeps two 1.4.2 bugs that quantile-forest 1.5.0 (released 2026-11-07) fixes:

  • Rows kept in a capped leaf can depend on the CPU (zillow/quantile-forest#181). 1.4.2's group_indices_by_value (_utils.pyx) groups each tree's bootstrap draws by leaf with np.argsort's default sort. That sort does not keep tied values in their original order, and NumPy's SIMD sorts order ties differently on different CPU instruction sets. When a leaf holds more rows than max_samples_leaf, its rows are shuffled with a seeded generator and truncated, so the same data and seed can keep different rows on different machines. microcosm sets max_samples_leaf to 4,096 for targets with 2 to 32 distinct values (_DISCRETE_Y_LEAF_BOUND), and _fill_tree_leaves calls the same group_indices_by_value.
  • Weighted-quantile search (zillow/quantile-forest#171). calc_weighted_quantile, which predict uses by default when max_samples_leaf is not 1, started its search at zero-weight inputs and rounded positions across exact ranks. microcosm predicts with the default weighted quantiles and linear interpolation over _QUANTILE_GRID, which runs from just above 0 to just below 1. The upstream PR says linear results with fractional weights are unchanged for quantiles strictly between 0 and 1. Whether the fix changes any microcosm draw has not been checked.

Not checked either: whether the first bug explains any of the cross-platform QRF differences recorded in docs/graph-qrf-cross-platform.md.

What moving to 1.5.0 involves

  • scikit-learn 1.9. 1.5.0 requires scikit-learn 1.9 or later, and uv.lock has 1.8.0.
  • Predictions change. The default interpolation becomes "averaged_inverted_cdf", and leaf samples are weighted by their sample weights. _fit_forest passes no sample_weight, so only the interpolation default and the two fixes above would reach microcosm's draws. Passing interpolation="linear" would keep the current quantile definition; that is a choice to make in this issue.
  • _InPlaceLeafQRF is retired. 1.5.0 stores each leaf's training samples without padding (zillow/quantile-forest#201), which removes the memory problem the subclass works around. Its version check and the byte comparisons against 1.4.2 in test_qrf_leaf_array.py go with it, and tools/measure_qrf_leaf_memory.py would need to compare against 1.4.2 differently or be removed.
  • Recorded outputs move. Draws change, so the per-platform digests in test_us_qrf_target_release.py, the fit.qrf parity fixture's direct.csv, and the hash pins that cover qrf.py and uv.lock all need re-recording. The US build memory work required byte-identical outputs, so this step needs its own approval.
  • Pickles. Models pickled by 1.5.0 cannot be loaded by earlier versions. 1.5.0 loads models pickled by earlier versions, but _Forest refuses a model that is not _InPlaceLeafQRF, so that refusal changes with the class.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions