8000 feat(science): Flow-native typed symbolic PDE DAG with RK1/RK2/RK4 by godofecht · Pull Request #1703 · flooooooooooow/flow · GitHub
[go: up one dir, main page]

Skip to content

feat(science): Flow-native typed symbolic PDE DAG with RK1/RK2/RK4 - #1703

Draft
godofecht wants to merge 17 commits into
mainfrom
feat/sofia-symbolic-pde-ir-rk4
Draft

godofecht wants to merge 17 commits into
mainfrom
feat/sofia-symbolic-pde-ir-rk4

Conversation

@godofecht
@godofecht godofecht commented Nov 16, 2026 •
Copy link
Copy Markdown
Contributor

Goal

Start the missing Flow-only symbolic PDE engine for #1650 using a reversible experimental library builder rather than new compiler grammar. This is option 3 as an experiment under the still-open API/DSL decision in docs/project/Questions.md, not an assertion of public API stability.

Implementation

  • lib/stdlib/science/sofia_ir.flow: unit-aware ordered expression DAG for one scalar field; dimensioned constants; add/sub/multiply; centered first/second derivatives, and RHS unit verification.
  • Portable, allocation-free CPU interpreter, periodic and Dirichlet boundaries, explicit Euler, midpoint RK2 and classical RK4 using distinct caller-provided scratch buffers.
  • tests/lang/test_sofia_ir_diffusion.flow: compare Euler and RK4 to the exact semi-discrete Fourier eigenmode of the 1D Laplacian; mass-conservation checks; advection-diffusion equation composition.
  • tests/lang/test_sofia_ir_boundary_units.flow: fixed boundary steady state; invalid dt/method/BC; reject dimensionally incorrect PDEs.
  • Runnable examples/science/sofia/symbolic_diffusion.flow, scope documentation and generated library docs + coverage.

Intended verification

./flow run tests/lang/test_sofia_ir_diffusion.flow
./flow run tests/lang/test_sofia_ir_boundary_units.flow
./flow run examples/science/sofia/symbolic_diffusion.flow
./flow tool gen_stdlib_docs --check
./flow tool doc_coverage
./flow test-lang

Verification update (16 November 2026): the Flow Linux language-test job explicitly passed both new test_sofia_ir_*.flow cases and 329/329 language tests (initial head 7761ce1). The first native-tools run exposed 13 new LSP completion symbols; the expected and reviewed-diff transcripts were regenerated using the actual CI output at head d3af70d. On that rerun, the Flow language tests, Doc links, Doc examples, FLOW tier-2, Wiki, WASM demos, Tier 1 Linux/macOS, and native LSP tool-transcript step passed. Whole-CI MLIR parity and remaining native-tool jobs are still running. No full showcase-parity claim is made. Keep draft until all altered surfaces pass. This does not implement actual Sofia solver-IR parity, heterogeneous fields, tensor calculus, arbitrary boundary conditions, GPU lowering or any of the 3 full showcase reproductions (#1651 #1652 #1653). It is a controlled numerical/typing foundation for those tasks.

Risks

The explicit recursion-based interpreter is for correctness/reference and not production speed. Syntax/semantic/field-owner decisions remain open. Unit exponents are symbolic integers with no unit conversion. Buffer aliasing beyond a few source/output guards is a caller precondition.

Copy link
Copy Markdown
Contributor Author

Verification checkpoint (2026-11-16): queried GitHub Actions for head d3af70d1a951c1434dffc9b7f9075fba343c8e1a. CI, Tier 1 platform qualification, Documentation examples (ratchet), Live WASM demos, Wiki, Attribution Guard, and Agent sandbox boundary are all completed / success. Prepare release PR is skipped (not a failure). This confirms workflow-level green status for this head, not independent production browser validation. PR remains draft intentionally: #1650 API/DSL design decision and actual Sofia showcase/GPU parity are not resolved. Do not interpret green CI as full Sofia parity or merge readiness.

Copy link
Copy Markdown
Contributor Author

Focused safety correction on this existing draft PR: commits 3d42f2e and 9d5bca0 add four regression cases and reject all 21 exact-pointer-alias pairs among u, out, k1, k2, k3, k4, tmp in sofia_ir_step_1d. The original documented distinct-buffer precondition was only checked for five pairs; reuse of k1/k2, out/k4, k4/tmp or k3/k4 could silently corrupt RK4 output. The negative tests now require the existing error code 18. This remains a library-local correction, with no new grammar, public solver API, or stability declaration.

Limit: equal-pointer checks do not establish that partially overlapping pointer ranges are disjoint; the documented caller obligation still applies. Exact final-head language tests and the wider CI are pending; this is not yet claimed verified. Keep the PR draft until its independent API/DSL decision is resolved.

Copy link
Copy Markdown
Contributor Author

Verification / rebase blocker (17 Nov 2026): current main is 00e1aff3521e9a76b34f4326e46a2da696c37452 (protected merge of #1722). This draft's exact head 34ddbdc9657b93ee276cc28ab955954c28dc34e1 is reported mergeable=false. Its CI, Tier 1, Wiki, documentation examples, attribution and sandbox checks passed, but Live WASM demos run https://github.com/flooooooooooow/flow/actions/runs/44005618851 failed only Chromium docs, playground and tutorials: 4/5 docs browser scenarios passed; Shift+Tab in the share modal left focus on #shareUrl. All four Chromium live-demo shards passed. The draft carries older playground content (blob 8a6685e0638dc921b5d8157e3e545c56fbcba3fa) than current main (blob 2001b88fedb5ae7bddcbb0032d10f6432ca76c06), even though this PR does not change playground paths. Refresh against current main without overwriting its newer focus fix, then rerun exact-head browser and compiler checks. Keep draft pending the #1650 public API/DSL decision; green language tests alone are not public API approval. Production Pages was not verified: direct HTTPS requests failed DNS resolution from this runtime.

Copy link
Copy Markdown
Contributor Author

Exact-head recheck, 2026-11-17: 34ddbdc9657b93ee276cc28ab955954c28dc34e1 now has all completed/success reported workflows: CI 44005618867, Tier 1 44005618792, Wiki 44005618759, documentation examples 44005618719, Attribution Guard 44005618837, Agent sandbox 44005618732 and Live WASM demos 44005618851. The latter's retry passed Chromium docs, playground and tutorials plus all four Chromium live-demo shards and manifest/assets. Earlier browser failure is not current on this exact head. The PR remains a draft and must not merge solely on these checks: its experimental public SofiaIr* and sofia_ir_* API still needs explicit design review, and the head is behind current main (00e1aff3521e9a76b34f4326e46a2da696c37452). Compare main...head shows nine changed files, with no playground file changes in this PR. Please preserve the existing numerical/negative tests and rerun exact-head checks after any update/rebase. Production Pages still cannot be verified from the available environment (GitHub Pages DNS resolution failure).

Copy link
Copy Markdown
Contributor Author

Current-main integration review (21 Nov, main f831c91; PR head 34ddbdc): branch is 15 ahead / 22 behind, still draft. Before marking ready, regenerate docs/library/stdlib-api.md, docs/coverage.json, and LSP completion goldens against the reconciled exact head (GPU #1743 changed generated stdlib/LSP surfaces), then rerun language, doc generator/check, native tools, WASM and Tier 1 jobs. One concrete numerical validation gap in sofia_ir_rhs_1d / sofia_ir_step_1d: dx <= 0.0 and dt <= 0.0 do not reject NaN, so non-finite inputs can propagate into output buffers while returning success. Please add negative tests for NaN (and decide/document infinity policy) before claiming robust parameter validation. Keep the experimental public API explicitly provisional pending the Sofia DSL decision; no merge approval implied.

This branch has not been deployed

No deployments
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

0