Skip to content

compiler: SO-3 — the MegaMoE producer consumes inferred dependence edges - #625

Merged
gstoner merged 5 commits into
mainfrom
agent/so3-megamoe-inferred-edges
Aug 25, 2026
Merged

gstoner merged 5 commits into
mainfrom
agent/so3-megamoe-inferred-edges

Conversation

@gstoner

@gstoner gstoner commented Aug 25, 2026

Copy link
Copy Markdown
Owner

Queue order 3 (SO-3 + W5.2e-PRODUCER-1), first producer adoption: the collective/MoE producer stops executing hand-written edges.

What changed

  • megamoe_graph_function represents the chunk pipeline as Graph IR using registered semantics — dispatch/combine are the registered ordered collectives, expert compute is pure tessera.matmul over its own chunk's dispatch result. No edges are written here.
  • megamoe_inferred_composition derives the production edges via infer_action_dag (W2.1 dataflow + W2.2 effects).
  • The hand DAG becomes the declared coverage oracle (Apple GPU: Gumbel-max inference sampler (#18-safe, reproducible) #31): generated edges must cover every hand edge or construction fails closed — a generation regression can never silently weaken the executed schedule. Extra conservative edges (the ordered-collective total order) are reported separately, exactly as the SO-3 acceptance asks.
  • The candidate carries the content-addressed ScheduleObject built from inferred edges; digest is deterministic.
  • composition_candidate_for_megamoe_plan keeps its signature, so prune_megamoe_overlap_plans and all existing consumers are unchanged at the call site.

Tests

test_megamoe_inferred_dag.py — deterministic topological order (with the overlap property visible in the order itself); registered-collective semantics; oracle coverage with extras reported; deterministic digest; a generation-regression control that strips the collective semantics and must fail closed; plus the pre-existing total-evidence guard.

Evidence

MegaMoE + composition + schedule-object suites 71 pass; x86/gfx1151/CPU composition conformance lanes 42 pass (numerics unchanged — the SO-3 acceptance clause); mypy 0; ruff clean; dashboards regenerated.

Coordination note (please read)

A concurrent session is editing this same worktree — it has scheduled_spectral.py, test_spectral_inferred_dag.py, and the pipeline-stage passes modified, i.e. the spectral half of this very queue row. This PR is therefore path-limited to the MegaMoE slice, and I deliberately do not report a whole-suite figure (the ~23 spectral/matmul/fp8 failures in my runs are that session's in-progress work, not this change). The targeted lanes above are this PR's evidence.

Remaining on order 3 after this: the spectral producer (in flight elsewhere), digest stamping through the physical lowering seam, and the scalar-pipeline-reconstruction deletion.

🤖 Generated with Claude Code

Queue order 3's first producer adoption. Before this, the R3 composition
candidate executed MegaMoE's hand-written `_action_dependencies` edges
directly. Now:

* `megamoe_graph_function` represents the chunk pipeline as Graph IR
  using REGISTERED semantics — dispatch/combine are the registered
  ordered collectives (`tessera.moe_dispatch`/`moe_combine`), expert
  compute is pure `tessera.matmul` over its own chunk's dispatch result.
  No edges are written here.
* `megamoe_inferred_composition` derives the production edges through
  `infer_action_dag` (W2.1 dataflow + W2.2 effects) and returns the
  candidate, the inferred DAG, and the parity result.
* The hand-authored plan DAG becomes the declared coverage ORACLE (#31):
  `compare_inferred_action_dag` must show generated edges cover every
  hand edge or construction fails closed, so a generation regression can
  never silently weaken the executed schedule. Additional conservative
  edges (the ordered-collective total order) report separately, per the
  SO-3 acceptance clause.
* The candidate carries the content-addressed `ScheduleObject` built
  from the inferred edges; its digest is deterministic across
  constructions.
* `megamoe_issue_order` is the one deterministic topological order every
  consumer indexes (Kahn + (chunk, phase) tie-break).

`composition_candidate_for_megamoe_plan` keeps its signature and now
routes through the inferred path, so `prune_megamoe_overlap_plans` and
every existing consumer are unchanged at the call site.

Tests (test_megamoe_inferred_dag.py): deterministic topological order
with the overlap property visible; registered-collective semantics in
the Graph representation; coverage of the hand oracle with extras
reported; deterministic ScheduleObject digest; a generation-regression
control that drops the collective semantics and must fail closed; and
the pre-existing total-evidence guard.

Gates: MegaMoE + composition + schedule-object suites 65 pass; the
x86/gfx1151/CPU composition conformance lanes 42 pass (numerics
unchanged, per the SO-3 acceptance); mypy 0; ruff clean; dashboards
regenerated.

Note: a concurrent session is editing this worktree (the spectral half
of SO-3 plus pipeline-stage work), so this commit is path-limited to the
MegaMoE slice and the whole-suite figure is not reported here — the
targeted lanes above are the evidence.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92385f9fe5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread python/tessera/compiler/megamoe_overlap.py
Comment thread python/tessera/compiler/megamoe_overlap.py
Comment thread docs/audit/compiler/INTEGRATED_COMPILER_PLAN.md Outdated
gstoner and others added 4 commits August 24, 2026 23:48
# Conflicts:
#	docs/audit/compiler/INTEGRATED_COMPILER_PLAN.md
…an identity, record cross-backend

P1 (overlap erased) — CONFIRMED and worse than reported. A 12-action
MegaMoE plan inferred all 66 edges of the complete order, so R3 would
estimate and prune overlap plans as sequential pipelines. Measured three
distinct over-conservatisms in the SHARED inference, each fixed with the
sound rule:

1. ordered collectives serialized against every surrounding op. They
   constrain the order OF COLLECTIVES (all ranks issue them in the same
   relative order), not unrelated local work — data through a collective
   is still ordered by SSA/alias/memory edges. Now collective-to-
   collective only.
2. a registered op declaring `aliasing="none"` had its declaration
   discarded whenever it was effectful, so every collective result was
   assumed to alias hidden state and `unknown_alias_fact` became an
   all-pairs barrier. A declared fact now has its consumer (#29/#30).
3. `has_memory_dependence` returned top for ANY effectful pair. A
   registered pure op touches no hidden state, so with a disjoint alias
   set it cannot depend through memory; two pure ops sharing a read-only
   operand (the weights every expert reads) likewise get no alias edge.

Result: 66 → 36 edges, still covering every hand-oracle edge, with the
extras now collective-ordering only. `combine:0 -> compute:1` and
`compute:0 -> compute:1` are gone; `dispatch:0 -> dispatch:1` and
`combine:0 -> combine:1` remain.

An existing test asserted the old blanket rule for collectives; it is
deliberately replaced by an explicit ordering test (positive: collectives
keep relative order; negative: independent local work floats) plus an
alias-gated memory-dependence test. The other three barrier classes keep
their all-pairs assertion unchanged.

P2 (digest identity) — CONFIRMED: action ids and graph shape are functions
of the chunk COUNT, so plans differing in capacities/buffers/token
ranges/in-flight limit content-addressed identically. The schedule object
now binds `plan.artifact_digest`, which already addresses exactly those
fields; `candidate_id` stays the plan id so pruning keys are unchanged.

P1 (cross-backend) — sync key SO3-INFER-EDGES-2026-08-24 in all four
queues: rocm/x86 parity validated (analysis is prune/rank-only; no
generated code or numerics change), nvidia/apple not-applicable-today with
the inherited-on-adoption reason.

Also resolves the merge conflict with #624 by keeping both queue rows.

Gates: composition-cost + graph-dataflow + MegaMoE suites 71 pass; mypy 0;
ruff clean; generated docs in sync.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…' into tmp/so3-merge

# Conflicts:
#	docs/audit/compiler/INTEGRATED_COMPILER_PLAN.md
@gstoner
gstoner merged commit 5670ae6 into main Aug 25, 2026
17 checks passed
@gstoner
gstoner deleted the agent/so3-megamoe-inferred-edges branch August 25, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant