Fix bulk-id generation in analyze_traps and enforce MP-edge diagnostics#396
Open
charlesmartin14 wants to merge 3 commits intomasterfrom
Open
Fix bulk-id generation in analyze_traps and enforce MP-edge diagnostics#396charlesmartin14 wants to merge 3 commits intomasterfrom
charlesmartin14 wants to merge 3 commits intomasterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
analyze_traps(..., return_bulk_ids=True, bulk_only=True)was returning zero bulk rows because the MP upper edge (mp_bulk_max) was not being read/wired into the bulk-row builder, causing the MP membership test to fail and silently drop all bulk modes.Description
_extract_mp_bulk_edges(...)to read MP edge candidates fromlayer_state, per-rowdetails, orbulk_statsand return(mp_bulk_min, mp_bulk_max).layer_stateandbulk_statsbefore building bulk rows and persistevalsandsingular_valuesthere, so bulk eligibility sees the real edges and spectrum (layer_state['mp_bulk_min'],layer_state['mp_bulk_max'],layer_state['evals'],layer_state['singular_values']).mp_bulk_min <= eval <= mp_bulk_maxwhen edges are present; assign 1-basedbulk_id-> internalsvd_mode_indexmappings inlayer_state['bulk_id_to_svd_index']and keep trap/bulk fields separate in returned rows.ValueErrorwhenreturn_bulk_ids=Trueon a nondegenerate layer and no eligible bulk modes are found, and exposeallow_bulk_without_mp_edges(defaultFalse) to permit controlled fallback to non-trap finite modes.mp_bulk_min,mp_bulk_max,mp_bulk_*fields andbulk_quantile, and forward the newallow_bulk_without_mp_edgesoption throughWeightWatcher.analyze_traps.Testing
tests/test_bulk_mode_ids.py::test_bulk_only_has_mp_edges_and_nonemptythat assertsbulk_only=Truereturns non-empty bulk rows and thatout_state['layers'][..]contains finitemp_bulk_min/mp_bulk_maxand non-emptybulk_svd_indices.pytest -q tests/test_bulk_mode_ids.pyin this environment; the run was skipped becausetorchis unavailable (output:1 skipped)._build_trap_bulk_rows, MP edge extraction, and bulk id mapping (no other automated test failures observed in the scoped run).Codex Task