Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions atom/compass/spec/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,15 @@
can never ask that condition however the document was built, and the same spec
is refused as a `Merge` and clear as a document. That is not a wrong number,
but it must be visible, because a caller that holds only the document cannot
ask it. A `validate` verb over a machine file -- `compass spec validate
machine.yaml` -- is not built yet: no entry point names it, and nothing in this
package reads a spec file. This module is what it would call. `CONDITIONS` is
what a count of reach is a count of; a condition added to the check set and not
to it is one no result can report on.
ask it. Merging the document again does not recover the pin: a merge whose
fragments disagree on a method states `mixed`, so a `Merge` holding the saved
document reports the transfer as not asked too, or as asked only in part when
another fragment states a transfer and a stack pin resolved. A `validate` verb
over a machine file -- `compass spec validate machine.yaml` -- is not built
yet: no entry point names it, and nothing in this package reads a spec file.
This module is what it would call. `CONDITIONS` is what a count of reach is a
count of; a condition added to the check set and not to it is one no result
can report on.

**The reach of a document is `ASKABLE_OF_A_DOCUMENT`, which is a value and not
a sentence.** Writing the number down in prose here puts a person between the
Expand Down Expand Up @@ -264,8 +268,22 @@ def reached(condition: str, reads: Sequence[str]) -> None:
"pin is in no field of one; ask this of the `Merge` while the "
"fragments are still in hand"
)
elif merged.transfers:
reached(TRANSFERS, STACK_PINS)
else:
if merged.transfers:
reached(TRANSFERS, STACK_PINS)
# Where a transfer is stated and a pin did not resolve, `reached` has
# already reported the condition once.
hidden = [repr(f.source) for f in merged.fragments if f.method == "mixed"]
if hidden and not any(c.startswith(TRANSFERS) for c in unasked + partial):
why = (
f"{TRANSFERS} -- method `mixed` in {', '.join(hidden)} does not "
"say whether a transfer went into it, and a transfer's source "
"pin is in no field of a document"
)
if merged.transfers:
partial.append(f"{why}; it was asked of the transfers stated")
else:
unasked.append(why)
return tuple(unasked), tuple(partial)


Expand Down
40 changes: 40 additions & 0 deletions tests/compass/test_spec_verbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,46 @@ def test_the_transfer_condition_names_itself_as_unaskable_of_a_document():
assert "in no field" in str(as_document)


def test_a_saved_document_merged_again_does_not_claim_to_have_asked_the_transfer():
# Validating the first `Merge` is refused. Its document keeps the transfer's
# source pin out and says only `method: mixed`, so a `Merge` of the saved
# document has no transfer to ask the condition of. A re-merged all-`probed`
# document is the control.
carried = copy.deepcopy(TIER2)
carried["device"]["software_pinned_to"] = dict(STACK, rocm="7.0.2")
transfer = fragment("tier2", carried, method="transferred-from:mi300x-8gpu")
combination = merge(fragments()[:2] + [transfer, fragment("links", LINKS)])
asked = {"tp_widths": (1, 2, 4, 8), "observed_stack": STACK}
first = validate(combination, **asked)
assert [refusal.rule for refusal in first.refusals] == [Rule.PINNED_STACK]
bare = validate(combination.document, **asked)
assert bare.ok and [c.split(" -- ")[0] for c in bare.not_asked] == [TRANSFERS_ASKED]
saved = Fragment.from_mapping(combination.document, "machine.yaml")
again = validate(merge([saved]), **asked)
assert again.ok and again.asked_in_part == ()
assert [c.split(" -- ")[0] for c in again.not_asked] == [TRANSFERS_ASKED]
assert "method `mixed` in 'machine.yaml'" in again.not_asked[0]
# A transfer stated beside the saved document is asked, and only in part.
beside = validate(merge([saved, transfer]), **asked)
assert [refusal.rule for refusal in beside.refusals] == [Rule.PINNED_STACK]
assert [c.split(" -- ")[0] for c in beside.asked_in_part] == [TRANSFERS_ASKED]
# With some stack pins resolved it was asked in part, and says so once.
thin = copy.deepcopy(combination.document)
del thin["device"]["software_pinned_to"]["rccl"]
thin = Fragment.from_mapping(thin, "machine.yaml")
partly = validate(merge([thin, transfer]), **asked)
assert sum(c.startswith(TRANSFERS_ASKED) for c in partly.asked_in_part) == 1
# With no stack pin resolved it was not asked at all, and says so once.
unpinned = copy.deepcopy(combination.document)
del unpinned["device"]["software_pinned_to"]
unpinned = Fragment.from_mapping(unpinned, "machine.yaml")
nowhere = validate(merge([unpinned, transfer]), **asked)
assert sum(c.startswith(TRANSFERS_ASKED) for c in nowhere.not_asked) == 1
assert nowhere.asked_in_part == ()
control = Fragment.from_mapping(merged().document, "machine.yaml")
assert validate(merge([control]), **asked).not_asked == ()


def test_a_desk_fix_refusal_does_not_hide_the_expensive_one():
# The phase-one refusal here is a derate an author types in at a desk; the
# width table behind it is present and schema-valid, and the width nobody
Expand Down