diff --git a/atom/compass/memory/graph_pool.py b/atom/compass/memory/graph_pool.py index 3468ee883f1..5cce39ec41c 100644 --- a/atom/compass/memory/graph_pool.py +++ b/atom/compass/memory/graph_pool.py @@ -132,8 +132,8 @@ def reserves( inferring it from an engine it is not allowed to import. **Two of ATOM's own adjustments inside those branches are not mirrored - here, and they pull in opposite directions.** Neither fires at M1 -- no - drafter, one data-parallel rank -- and both are named because the cut that + here, and they pull in opposite directions.** Neither fires with no + drafter and one data-parallel rank, and both are named because the cut that wires this into `get_num_blocks` under a block-count gate would otherwise read "nothing else" as fidelity: diff --git a/atom/compass/memory/readings.py b/atom/compass/memory/readings.py index 0d5ddcb66ec..a95d830ce5e 100644 --- a/atom/compass/memory/readings.py +++ b/atom/compass/memory/readings.py @@ -39,8 +39,8 @@ tree, which needs the engine, which this tier does not import; and there is no recording of a card nobody has run. So `ModelTerms` takes those two terms rather than deriving them, with no default -- the same shape as the spec's "a runtime -constant has no default" rule, and for the same reason. `declared_for_m1` fills -all three with declared formulas for M1 and labels every one of them. For the +constant has no default" rule, and for the same reason. `from_declared_config` +fills all three with declared formulas and labels every one of them. For the activation term a declared formula is the only answer while no op graph exists; this module gives the other two the same treatment, visibly. """ @@ -108,7 +108,7 @@ class ModelTerms: activations: Term @classmethod - def declared_for_m1( + def from_declared_config( cls, config, *, @@ -119,7 +119,7 @@ def declared_for_m1( ) -> ModelTerms: """All three from geometry and declared coefficients, each labelled. - For M1, with fake models, a declared formula suffices and must say so. + With fake models, a declared formula suffices and must say so. Every term below is `Basis.DECLARED` and every one names its successor, because none of the three is its eventual source: weights are owed a meta build, buffers a recording, and @@ -128,7 +128,7 @@ def declared_for_m1( with no law behind it. The measured spread that makes it load-bearing is 0.1 KB/token on the 0.6B against 39.6 KB/token on the 27B, the difference between -35.0% and +3.4% held out. A formula does not - stand in for that past M1. + stand in for that on a real model. """ if tp_size < 1: raise ValueError(f"tensor-parallel width is at least 1: {tp_size}") diff --git a/tests/compass/test_memory_compare.py b/tests/compass/test_memory_compare.py index ab0687dc9e7..b842902bd90 100644 --- a/tests/compass/test_memory_compare.py +++ b/tests/compass/test_memory_compare.py @@ -450,7 +450,7 @@ def live_readings(spec, qwen, tp_width=1): return device_readings( spec, tp_width=tp_width, - model=ModelTerms.declared_for_m1( + model=ModelTerms.from_declared_config( qwen, parameter_count=PARAMETERS, tp_size=tp_width, @@ -1035,19 +1035,15 @@ def test_the_footprint_is_peak_torch_and_non_torch_and_nothing_else(spec, qwen): #: lets the guard below read the file it is written in if it is ever widened. #: `P\d+\.\d+` is in the banned list by name; the two-to-four letter form with #: a dash is every task label, not just the one this cut happened to leave. +#: A milestone label is `M1` in prose and `_m1` as an identifier suffix; a bare +#: letter-and-digit is not matched, because it would take `TP1`, `w1` and +#: every dtype width in this package with it. No group captures, so a failure +#: prints the forms it found. _TAGS = re.compile( - r"\b[DTW]\d+(\.\d+)?\b|\bP\d+\.\d+\b|\b[A-Z]{2,4}-\d+\b" + r"\b[DTW]\d+(?:\.\d+)?\b|\bP\d+\.\d+\b|\b[A-Z]{2,4}-\d+\b|\bM\d+\b|\w*_m\d+\b" r"|principles? \d+|Gate \d+|`\d{2}`|#\d+" ) -#: What this pattern deliberately does not catch, and why, because an absence -#: nobody explained is the same defect one level up. `M1` is a milestone that -#: the public `ModelTerms.declared_for_m1` is named after: it says when a -#: declared term stops being allowed, which is what the code does, and it -#: points at no document. Matching a bare letter-and-digit would also take -#: `TP1`, `w1` and every dtype width in this package with it. -KEPT = ("M1", "declared_for_m1") - #: The package as the suite imported it, never a walk up from this file: if #: `atom` resolves from another root, a path-derived location would scan one #: tree while every other test here imports another, and pass. @@ -1070,7 +1066,7 @@ def test_no_module_in_the_package_carries_a_design_reference(module): `test_memory_readings.py`, and for the same reason. """ found = _TAGS.findall((PACKAGE / module).read_text()) - assert not found, f"{module} carries {len(found)} design references" + assert not found, f"{module} carries design references: {found}" def test_the_guard_catches_the_forms_that_were_actually_removed(): @@ -1090,6 +1086,8 @@ def test_the_guard_catches_the_forms_that_were_actually_removed(): "an open owner ruling (**#87**)", "proving it is MEM-2's", "`16` row W2.2", + "For M1, with fake models, a declared formula suffices", + "def declared_for_m1(", ] # Two forms this package never carried, driven anyway because a guard is # worth what it catches rather than what it happened to meet. `P0.4` is @@ -1105,19 +1103,25 @@ def test_the_guard_catches_the_forms_that_were_actually_removed(): assert not _TAGS.search(replacement) -def test_the_kept_forms_are_kept_on_purpose_and_stay_readable(): - """An absence with a stated reason is a decision; without one it is a gap. +def test_what_the_pattern_matches_beside_its_targets_is_on_record(): + """The pattern's reach past the forms it targets, both ways, stated here. - `M1` is the one letter-and-digit form this package keeps. It names the - milestone at which a declared term stops being allowed -- which is what - the code does, not a pointer into a document -- and the public - `ModelTerms.declared_for_m1` is named after it, so removing it would - rename an API to satisfy a pattern. + It is not a bare letter-and-digit, so widths and dtypes stay clear. It does + match some of ATOM's own names, none of which this package carries; a hit + fails loudly, and rewording the line is the fix, not an exemption. And it + misses forms one step from the removed ones, because a pattern wide enough + to take them would take more of ATOM's names with it. """ - assert all(not _TAGS.search(kept) for kept in KEPT) - sources = "".join((PACKAGE / p.name).read_text() for p in PACKAGE.glob("*.py")) - assert "declared_for_m1" in sources - # And the widened pattern does not sweep up the widths and dtypes that - # share its shape, which is why it is not a bare letter-and-digit. for benign in ("TP1", "w1_base_bytes", "fp8", "int8", "bf16"): assert not _TAGS.search(benign), benign + for collision in ( + "MiniMax-M3", + "minimax_m3", + "M128", + "tile_m128", + "seq_len_m1", + "fp8_m3", + ): + assert _TAGS.search(collision), collision + for escape in ("declared_for_m1_terms", "At m1", "M1a", "declared_for_M1"): + assert not _TAGS.search(escape), escape diff --git a/tests/compass/test_memory_readings.py b/tests/compass/test_memory_readings.py index 5c3b227c05a..2294d528aaf 100644 --- a/tests/compass/test_memory_readings.py +++ b/tests/compass/test_memory_readings.py @@ -228,7 +228,7 @@ def readings_at(spec, qwen, tp_width): return device_readings( spec, tp_width=tp_width, - model=ModelTerms.declared_for_m1( + model=ModelTerms.from_declared_config( qwen, parameter_count=PARAMETERS, tp_size=tp_width, @@ -376,7 +376,7 @@ def test_a_configuration_that_does_not_fit_refuses_rather_than_clamping(spec, qw device_readings( spec, tp_width=1, - model=ModelTerms.declared_for_m1( + model=ModelTerms.from_declared_config( qwen, parameter_count=400_000_000_000, tp_size=1, @@ -397,7 +397,7 @@ def test_the_predicting_function_cannot_be_spent_as_the_reserving_one(spec, qwen device_readings( spec, tp_width=1, - model=ModelTerms.declared_for_m1( + model=ModelTerms.from_declared_config( qwen, parameter_count=PARAMETERS, tp_size=1, @@ -492,10 +492,10 @@ def test_an_absent_partial_rotary_factor_says_so_in_the_table(qwen): # row must not look the same as a config that states 1.0. full = copy.deepcopy(qwen) del full.partial_rotary_factor - stated = ModelTerms.declared_for_m1( + stated = ModelTerms.from_declared_config( qwen, parameter_count=PARAMETERS, tp_size=1, warmup_tokens=WARMUP_TOKENS ) - assumed = ModelTerms.declared_for_m1( + assumed = ModelTerms.from_declared_config( full, parameter_count=PARAMETERS, tp_size=1, warmup_tokens=WARMUP_TOKENS ) assert "absent from config, assumed" in assumed.buffers.source @@ -507,7 +507,7 @@ def test_the_model_dtype_sizes_the_model_terms(qwen): # Read off the config, not a module constant: a term sized in fp32 where # the tensors are resident in bf16 is twice what the model holds. assert str(qwen.dtype).endswith("bfloat16") - terms = ModelTerms.declared_for_m1( + terms = ModelTerms.from_declared_config( qwen, parameter_count=PARAMETERS, tp_size=1, warmup_tokens=WARMUP_TOKENS ) assert terms.buffers.nbytes == 262_144 * 64 * 2 @@ -530,7 +530,7 @@ def test_a_config_with_no_dtype_refuses_rather_than_assuming_one(qwen): nameless = copy.deepcopy(qwen) del nameless.dtype with pytest.raises(MemoryRefusal, match="states no `dtype`, and every byte"): - ModelTerms.declared_for_m1( + ModelTerms.from_declared_config( nameless, parameter_count=PARAMETERS, tp_size=1, @@ -545,7 +545,7 @@ def test_a_config_missing_a_geometry_field_refuses_naming_that_field(qwen, field shapeless = copy.deepcopy(qwen) delattr(shapeless, field) with pytest.raises(MemoryRefusal) as refusal: - ModelTerms.declared_for_m1( + ModelTerms.from_declared_config( shapeless, parameter_count=PARAMETERS, tp_size=1, @@ -564,7 +564,7 @@ def test_the_negative_box_refusal_carries_its_decomposition(spec, qwen): device_readings( spec, tp_width=1, - model=ModelTerms.declared_for_m1( + model=ModelTerms.from_declared_config( qwen, parameter_count=400_000_000_000, tp_size=1,