Repository navigation
compass(memory): rename ModelTerms.declared_for_m1 to declared, and let the guard enforce milestone labels #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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.declared( | ||||||||||||
| 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" | ||||||||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking (principle 6): near variants of the removed form escape. They pass silently, not loudly. The named result holds for the exact forms:
Nothing else in the suite notices either. Ask: a regex cannot close all of these without taking more of ATOM's own names with it (see the next comment). So I am not asking for a wider pattern. Instead, state the escapes beside the benign list, the way the deleted
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recorded in If someone later widens the pattern to catch one of them, this assertion fails. That forces them to update the record, instead of the record going stale. |
||||||||||||
| 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,7 @@ 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. | ||||||||||||
|
|
||||||||||||
| `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. | ||||||||||||
| """ | ||||||||||||
| 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. | ||||||||||||
| def test_the_widths_and_dtypes_that_share_the_shape_are_not_swept(): | ||||||||||||
| """The pattern is not a bare letter-and-digit, and this is why.""" | ||||||||||||
| for benign in ("TP1", "w1_base_bytes", "fp8", "int8", "bf16"): | ||||||||||||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking (principle 8): this list claims to cover what shares the pattern's shape, but ATOM's own model names are not in it, and both new alternatives match them. Measured over the merged tree (
This package sizes model memory, so a sentence or a key naming one of ATOM's supported models is plausible here. The next developer to write one will be refused, and the obvious reaction is to add an exemption back. Ask: say it where the next reader looks. Either:
Either way the docstring's claim then matches its assertions. I measured the lookbehind on node 18:
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recorded in The record also holds the pattern. On mutE, which puts back the tip's |
||||||||||||
| assert not _TAGS.search(benign), benign | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking (principle 4):
declaredis already a query in this package, and this makes it a constructor too.At
306b9b7e8, three classes inatom/compass/memory/have a member calleddeclared. Measured on node 18 withinspect.getattr_staticagainst the merged tree:readings.DeviceReadings.declared(this file,:219)propertytuple[str, ...], the names of terms still on a declared basisterms.Reading.declared(terms.py:159)propertytuple[str, ...], the same question for one readingreadings.ModelTerms.declared(here)classmethodModelTermsSo
x.declaredasks "which terms are declared?" on two classes and means "build me declared terms" on the third. On aModelTermsinstance,.declaredis a bound method:tuple(model_terms.declared)raisesTypeError: 'method' object is not iterable, where the same expression on either sibling returns names.The two meanings already sit side by side in the same files:
readings.py:224iteratesreading.declared, 113 lines below this definition.test_memory_readings.pycallsModelTerms.declared(...)nine times, and at:324asserts onreadings.peak_torch.declared.The old name did not collide. This PR is a naming change, so the name is the deliverable.
Fix: use an alternate-constructor name that no query in the package uses. The brief's own example,
from_declared_config, works, and so doesdeclared_from_config. That is 11 mechanical sites: this definition, the prose at:42, nine intest_memory_readings.pyand one intest_memory_compare.py. Neither name trips_TAGS.Deleting the method stays wrong, for the reason the dev record gives: 10 test sites would each rebuild three
Terms by hand. Keeping it with no production caller is justified. Only the name needs to change.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in
40ae3faad. The method is renamed toModelTerms.from_declared_config, the brief's own example, at all 11 sites: the definition, the module docstring at:42, nine calls intest_memory_readings.pyand one intest_memory_compare.py.DeviceReadings.declared(:219) andReading.declared(terms.py:159) are untouched, sodeclaredis now only ever the query.AST check, tip
2565b5f57against head40ae3faad, withdeclared_for_m1normalised tofrom_declared_config, run on node 18:test_memory_readings.pyis identical.readings.pyandgraph_pool.pyare identical once docstrings are masked.Re-run of mutA with the new name's line (
26f1d89a3):`from_declared_config`at:42becomes`declared_for_m1`.test_no_module_in_the_package_carries_a_design_reference[readings.py]fails, withreadings.py carries design references: ['declared_for_m1']."def declared_for_m1("stays in the driven list.