artdag: Phase 5 optimization — DCE + CSE + adjacent-op fusion + 18 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 57s
optimize.sx adds three result-preserving passes: dce (keep outputs + ancestors, preserve ids), cse (==build; structural sharing is free from content addressing), and fuse (collapse 1-to-1 fusible unary chains into an artdag/pipeline node fed by the chain head's input; leaves/fan-out/non-fusible ops never fuse). fusing-runner replays pipeline stages, output-equivalent to the unfused dag. optimize 18/18, total 87/87. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,7 @@ edges.
|
||||
|
||||
## Status (rolling)
|
||||
|
||||
`bash lib/artdag/conformance.sh` → **69/69** (4 suites: dag, analyze, plan, execute)
|
||||
`bash lib/artdag/conformance.sh` → **87/87** (5 suites: dag, analyze, plan, execute, optimize)
|
||||
|
||||
## Ground rules
|
||||
|
||||
@@ -116,12 +116,12 @@ lib/artdag/optimize.sx lib/artdag/federation.sx
|
||||
|
||||
## Phase 5 — Effect-pipeline optimization
|
||||
|
||||
- [ ] `lib/artdag/optimize.sx` — rewrite the DAG before execution: dead-node
|
||||
- [x] `lib/artdag/optimize.sx` — rewrite the DAG before execution: dead-node
|
||||
elimination (unreachable from outputs), common-subexpression sharing (free from
|
||||
content ids), adjacent-op fusion
|
||||
- [ ] optimizations are content-id-preserving where semantically identical; assert
|
||||
- [x] optimizations are content-id-preserving where semantically identical; assert
|
||||
the optimized DAG produces identical results
|
||||
- [ ] `lib/artdag/tests/optimize.sx` — DCE, CSE dedup, fusion equivalence
|
||||
- [x] `lib/artdag/tests/optimize.sx` — DCE, CSE dedup, fusion equivalence
|
||||
- [ ] (optional/later) rule-based optimization via `maude-on-sx`'s rewriting engine —
|
||||
flag the integration point, don't block on it
|
||||
|
||||
@@ -136,6 +136,19 @@ lib/artdag/optimize.sx lib/artdag/federation.sx
|
||||
|
||||
## Progress log
|
||||
|
||||
- **Phase 5 — Effect-pipeline optimization** (optimize suite 18/18, total 87/87).
|
||||
`lib/artdag/optimize.sx`: `artdag/dce dag outputs` keeps only the outputs plus
|
||||
their transitive ancestors (via analyze), preserving surviving content-ids.
|
||||
`artdag/cse` == build — structural sharing is inherent to content addressing, so
|
||||
identical subexpressions collapse to one node/id and execute once (verified).
|
||||
`artdag/fuse entries fusible?` rewrites entries: a maximal 1-to-1 chain of fusible
|
||||
unary ops (predecessor used only by its single consumer, both fusible) collapses
|
||||
into one `artdag/pipeline` node carrying ordered `{:op :params}` stages, fed by the
|
||||
chain head's external input; leaves, fan-out nodes, and non-fusible ops never fuse.
|
||||
`artdag/fusing-runner` wraps a base runner to replay pipeline stages — output
|
||||
equivalent to the unfused DAG (asserted). Note: CSE auto-dedup means test fixtures
|
||||
intended as distinct nodes must use distinct op/params.
|
||||
|
||||
- **Phase 4 — Execute (incremental + memoized)** (execute suite 15/15, total 69/69).
|
||||
`lib/artdag/execute.sx`: `artdag/execute` folds a plan, computing each node via an
|
||||
injected `runner (op params input-results)` (production = `perform` to JAX/IPFS
|
||||
|
||||
Reference in New Issue
Block a user