-
Notifications
You must be signed in to change notification settings - Fork 78
migrate to ValueMesh accumulator #1486
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
Open
shayne-fletcher
wants to merge
7
commits into
meta-pytorch:main
Choose a base branch
from
shayne-fletcher:export-D84318425
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
migrate to ValueMesh accumulator #1486
shayne-fletcher
wants to merge
7
commits into
meta-pytorch:main
from
shayne-fletcher:export-D84318425
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
@shayne-fletcher has exported this pull request. If you are a Meta employee, you can view the originating Diff in D84318425. |
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 10, 2025
Summary: Pull Request resolved: meta-pytorch#1486 his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
2526a5b
to
216826b
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 10, 2025
Summary: Pull Request resolved: meta-pytorch#1486 his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 10, 2025
Summary: Pull Request resolved: meta-pytorch#1486 his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
9ec49d8
to
a43ea95
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 10, 2025
Summary: Pull Request resolved: meta-pytorch#1486 his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
a43ea95
to
400e71e
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 10, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
400e71e
to
0a0b1b3
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 12, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
0a0b1b3
to
8607788
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 12, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Differential Revision: D84318425
8607788
to
a62204d
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 13, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Reviewed By: pablorfb-meta Differential Revision: D84318425
a62204d
to
7dc5120
Compare
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 13, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Reviewed By: pablorfb-meta Differential Revision: D84318425
Summary: this diff introduces a v0 basic run-length-encoded (RLE) internal representation for `ValueMesh<T>` and updates all APIs to operate transparently over either dense or compressed data. the compression support is purely additive. public semantics are unchanged: a mesh still represents a complete mapping from rank -> value, and iteration, slicing, and region order behave identically (note: complexity of `get()` is O(log k) in compressed mode vs O(1) dense). the compressed form is lossless and idempotent. compression is manual in rust because automatic detection isn't possible in a fully generic type. i originally considered doing it automatically, but rust provides no specialization or reflection to determine whether a given `T` has meaningful equality semantics. for many types (e.g. futures, closures) equality doesn't even exist. because of that, compression must be explicitly invoked via `compress_adjacent_in_place()` or `compress_adjacent_in_place_by(pred)` when the caller knows adjacent elements can be merged. in python, compression happens automatically on construction. for `Py<PyAny>`, equality is defined by pointer identity (`a.as_ptr() == b.as_ptr()`), so adjacent references to the same python object are coalesced into RLE runs. this will produce savings for sentinel-rich, categorical, or boolean data (e.g. repeated `None`, booleans, cpython-interned small integers and strings) but will have little effect for freshly allocated numbers or dynamic objects. Differential Revision: D84169361
Summary: this change enables serde serialization and deserialization for `ValueMesh<T>` and its internal representations. it introduces a stable wire format for run-length encoded (RLE) meshes by defining a `Run` struct (`u64` bounds, `u32` id) to avoid platform-dependent `usize` encoding. both dense and compressed representations serialize deterministically and retain their form on round trips Reviewed By: dulinriley Differential Revision: D84197759
Summary: add a set of `ValueMesh` constructors equivalent to the `RankedValues` initialization paths. `from_single` and `from_default` create compressed single-run meshes without allocating a dense vector, `from_ranges_with_default` builds a compact RLE mesh from sparse overrides on a default value, and `from_dense` constructs from a dense vector and compresses adjacent equal elements. includes tests for correctness, edge cases, and internal structure. completes the construction half of the `ValueMesh` parity plan before adding `ValueOverlay` and merge support. Differential Revision: D84259628
Summary: introduces `ValueOverlay`, a sparse representation of `(Range<usize>, T) `runs for assembling or patching `ValueMesh` instances without materializing per-rank data. includes structural validation (`EmptyRange`, `OverlappingRanges`), coalescing of equal-adjacent runs, and construction helpers (`push_run`, `try_from_runs`, `normalize`). adds unit tests covering append, coalescing, overlap detection, unsorted inserts, and empty overlays. no behavior change to `ValueMesh`; merge support will follow in the next diff. Differential Revision: D84266477
Summary: this change factors out RLE and merge logic into a new `rle` module and ports the merge algorithm from `RankedValues::merge_from` into a general `merge_value_runs` that operates over normalized `(Range, T)` lists. the function implements last-writer-wins semantics and handles equal-value coalescing, disjoint runs, and arbitrary overlap spans. `ValueMesh` now uses these primitives for compression (`rle_from_dense`, `rle_from_value_runs`) and sparse overlay updates via `merge_from_overlay,` with `materialized_runs()` added for inspection. comprehensive tests cover dense compression, value-run merging, and overlay application, including multidimensional regions. Differential Revision: D84285073
Summary: adds an accumulator and reducer for `ValueOverlay<T>` with right-wins merge semantics via merge_value_runs. `ValueOverlay<T>` now derives `Named` and `Default`, and `BuildError` implements `Display` and `std::error::Error`. registers a reducer factory for `ValueOverlay<Status>` to enable accumulation of sparse updates into `ValueMesh<Status>`. defines `StatusMesh` and `StatusOverlay` type aliases for per-rank lifecycle tracking. Differential Revision: D84301230
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Reviewed By: pablorfb-meta Differential Revision: D84318425
shayne-fletcher
added a commit
to shayne-fletcher/monarch-1
that referenced
this pull request
Oct 15, 2025
Summary: his change replaces the old `RankedValues<Status>` path with `ValueOverlay<Status>` updates reduced into a `ValueMesh<Status>` snapshot. `GetRankStatus.reply` now carries overlays; the comm reducer merges them (right-wins) and the accumulator applies them into a full `StatusMesh`, seeded to `NotExist` via the accumulator template (`StatusMesh::from_single(region, NotExist)`) and `ValueMesh::default()` + first-update install. agents emit a single-rank overlay (or an empty overlay when the rank is unknown). `wait()` consumes snapshots, declares completion when no `NotExist` remain for the target ranks, and on timeout returns the last snapshot (falling back to the seed if nothing arrived). termination detection now checks `values().any(is_terminating)`. legacy shims convert `StatusMesh` back to `RankedValues` only where error types still require it. removed the `RankedValues` accumulator/reducer and its registration. Reviewed By: pablorfb-meta Differential Revision: D84318425
e30964b
to
e96bd6e
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Summary: this change replaces the old
RankedValues<Status>
path withValueOverlay<Status>
updates applied into aValueMesh<Status>
snapshot.GetRankStatus.reply
now carries overlays, the comm reducer merges overlays, and the accumulator applies them into a fullStatusMesh
(seeded toNotExist
via a template andValueMesh::default()
+ first-update install). agents emit a single-rank overlay (or empty when rank unknown).wait()
consumes snapshots and checks completion againstNotExist
. legacy shims convertStatusMesh
back toRankedValues
only where error types still demand it. removed theRankedValues
accumulator/reducer and its registration. the oldRankedValues
accumulator and reducer definitions are removed.Differential Revision: D84318425