Skip to content

lrr cluster by field#14

Merged
cboulay merged 3 commits into
devfrom
llr-bank-aware
Jul 2, 2026
Merged

lrr cluster by field#14
cboulay merged 3 commits into
devfrom
llr-bank-aware

Conversation

@kylmcgr

@kylmcgr kylmcgr commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary

LRR can now derive its per-bank regression blocks from a structured channel-axis
field instead of relying on positional block_size.

  • Adds cluster_by_field to SelfSupervisedRegressionSettings (inherited by
    LRR). When set (e.g. "bank") and no explicit channel_clusters are given,
    clusters are derived from that field via
    ezmsg.sigproc.util.channels.channel_clusters_from_field, cached at
    _reset_state (so the message-less _get_channel_clusters — also called
    externally — can return them).
  • Precedence: explicit channel_clusters > cluster_by_field > block_size

    single cluster. Default None preserves current behavior.

  • _hash_message folds the field's bytes into the hash so derived clusters
    re-derive when the field changes (mirrors the sigproc fix).

Tests

TestClusterByField in test_ssr.py: bank-derived weights byte-identical to
explicit per-bank channel_clusters, explicit-clusters precedence, fallback to
block_size, and re-derive on bank change. 21 pass.

⚠️ Before merge

  • Depends on the sigproc helper — land the ezmsg-sigproc car-bank-aware PR
    first.
  • pyproject.toml currently pins ezmsg-sigproc to the car-bank-aware branch
    in [tool.uv.sources] for local testing.

@kylmcgr kylmcgr requested a review from cboulay June 30, 2026 19:22
@kylmcgr kylmcgr self-assigned this Jun 30, 2026
cboulay added 2 commits July 2, 2026 00:33
_hash_message runs on every message. Folding the whole channel-axis
field's bytes is O(channels) and scales with channel count on the hot
path. Fold only an O(1) boolean for whether the axis carries the target
structured field, matching the ezmsg-sigproc CommonRereference hash this
mirrors (which moved to a presence boolean).

Concession: a change in the field's *values* while the axis stays
structured and the channel count is unchanged is no longer detected --
safe for real acquisition streams, whose channel->field map is static for
the stream's life; a genuine remap arrives with a new key or channel
count, both already in the hash.

Invert the re-derive test accordingly: it now asserts the live-remap
value change is deliberately NOT re-derived, and that a new key (the
escape hatch) forces re-derivation.
@cboulay cboulay merged commit d7594f9 into dev Jul 2, 2026
8 checks passed
@cboulay cboulay deleted the llr-bank-aware branch July 2, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants