Repository navigation
Port tools, wasm, benchmarks and challenges Python to Flow - #965
Merged
Merged
Conversation
build_tool.sh, lib/json.flow and lib/text.flow, byte-identical to the copies on port/doc-checkers-to-flow so the two ports share one toolkit.
scripts/tools/ held stale copies of several tools/ scripts whose
parents[2] root lookup broke in the move, so the working tools/ copy is
kept and the scripts/tools/ duplicate goes:
scripts/tools/audio (plot_lattice_allpass, lattice_allpass_audio_demo)
scripts/tools/doc (flow_doc, flow_know)
Retired outright, with nothing outside their own directory using them:
tools/ and scripts/tools/backlog_sorter: keyword-voting ROADMAP
sorters and their generated reports.
tools/ and scripts/tools/euclid: one-shot generators for
examples/verify/euclid. Book I has been hand-edited since, so a
rerun would destroy content. The TOC generator keys pointed at
paths that no longer existed.
tools/ and scripts/tools/jit, simd: superseded by ./flow jit;
simd_check's default input tests/test_simd_saxpy.flow is gone.
tools/ and scripts/tools/debug: superseded by ./flow debug.
tools/audio/srir_viewer.py: pygame viewer, referenced only from an
archived structure doc.
wasm/demo_wasm_build.py: every input it builds is gone.
wasm/wasm_build_system.py: batch driver for the legacy converter,
superseded by scripts/build_wasm_gallery.py.
wasm/flow_wasm.py: superseded by ./flow wasm.
benchmarks/benchmark_aosoa.py: hardcoded /app/build sandbox path.
benchmarks/benchmark_gemm_cutlass_evaluation.py: numpy-only estimate,
its output stays in cutlass_benchmark_results.txt.
tests/benchmarks/*.py: byte-identical copies of the benchmarks/
baselines, an empty run_benchmarks.py and an older run_publish.py.
Also fixes ./flow know and ./flow doc, which pointed at tools/flow_*.py
paths that did not exist, and clears the dash tells in the docs touched.
challenges/flow-specific/check.sh builds scripts/tools/challenge_check with the Stage-A compiler and runs it. It replaces check.py and test_check.py. The catalog rules are Python regular expressions, so this adds scripts/tools/lib/regex.flow: a backtracking matcher over code points for the subset the catalog uses (classes, \s \w \d \b, groups, alternation, greedy and lazy bounded repeats, MULTILINE and DOTALL). The submission is run with fork/execvp and a polled waitpid timeout. Parity with the Python checker: - check.sh scan over all 2,227 tracked .flow files x 36 challenges: 80,172 verdicts, byte-identical to check.py's check_patterns. - list, --syntax-only passes and failures, unknown id, missing file, wrong suffix, directory argument: identical stdout, stderr and exit code (program name aside). - Full runs and --timeout 0: same lines and exit codes. Output order follows program order, as check.py does on a terminal. - check.sh self-test carries the three test_check.py cases and 43 re.search verdicts recorded from CPython.
scripts/tools/grad/main.flow replaces flow_grad_c.py and flow_grad_flow.py (both the tools/ and scripts/tools/ copies). The Python versions leaned on src/flow's parser; the port carries its own lexer and precedence-climbing parser for the subset they accept. scripts/tools/grad/grad.sh c <file.flow> <function> scripts/tools/grad/grad.sh flow <file.flow> <function> Parity: 18 cases, identical stdout, stderr and exit code against the Python generators, covering every op, literal forms (2.0, 3.0e1, 1e-3), double negation, unused parameters, inlined multi-argument helpers, and the error paths (non-f32 literal, unknown call in C mode, missing function). grad.sh flow regenerates lib/stdlib/nn_xor_loss_clean_grad.flow and nn_xor_loss_params_grad.flow byte for byte. scripts/tools/grad/demo.flow replaces the examples/grad_tool_demo.flow input the autodiff doc named but which no longer existed.
scripts/tools/measure_size/measure_size.sh replaces tools/size/measure_size.py. The Flow program runs ./flow compile, size(1) and strip itself through system() and popen(), and formats the same Markdown table. Parity: with FLOW_HOST=python (the host the Python tool hardcoded), stdout and the --out report are byte-identical to measure_size.py for the three default programs. The port takes the host from FLOW_HOST and defaults to flowc, the ./flow default.
wasm/crossings.sh runs scripts/tools/wasm_crossings, which replaces flow_wasm_threads.py, flow_wasm_sockets.py, flow_wasm_python.py, flow_wasm_fs.py and flow_wasm_crossings.py. ./flow wasm --threads and --fs now call it. The page f-strings moved to wasm/crossing_assets/pages/*.html with @@field@@ slots, extracted mechanically from the Python sources. scripts/tools/lib/proc.flow adds shell quoting, command capture and Path.resolve() for the tools. The GPU crossing (flow_wasm_gpu.py) and crossing_common.py stay: the WGSL comes from src/flow's WgslCodegen and ModuleResolver, called in process. Flow sources still reach C through python3 -m flow.transpiler, the compiler these pages were built with. Parity against the Python builders: - --no-build for threads, sockets, python, fs and the index: every page and asset byte-identical, stdout identical. - Full emcc builds of all four crossings plus a single-program fs --fs idbfs --preload build: every .js, .wasm and .data identical (fs_preload.js embeds its own output path; identical once that is normalised), and the echoed emcc command lines identical. - ./flow wasm fs_counter.flow --fs idbfs and ./flow wasm parallel_sum.flow --threads both build through the port.
Replaces every mention of the retired flow_wasm_*.py builders and regenerates the five affected site/wasm-crossings pages with wasm/crossings.sh --no-build. The page diffs are the builder names only. Also clears the dash and contrast tells in wasm-crossings.md.
benchmarks/baselines/run_baselines.sh runs scripts/tools/bench_baselines, which replaces run_baselines.py. scripts/tools/lib/bench.flow adds wall timing (clock_gettime), a fork/execvp runner that times from spawn to reap like subprocess.run, median/min/max, and Python's float repr for the JSON output. Parity: run back to back with run_baselines.py, stdout, baseline_results.md and baseline_results.json are identical once timing values are masked; metadata and every result value match exactly. bn_py_repr and the .2f/.4f/.6f formats agree with CPython on 5,021 values, edge cases included (5e-324, 1e16, 1.7976931348623157e308). The committed result files are left as they were.
benchmarks/run_publish.sh now runs scripts/tools/bench_publish, which replaces run_publish.py: compile each benchmark in C, Flow, Rust and Python, run a warmup plus N timed repetitions, check the results agree, and write benchmarks/RESULTS.md (or print one line per run with --quick). The two hand-written notes sections of the report live in scripts/tools/bench_publish/notes.md, extracted verbatim. Parity, run back to back on the same machine with --reps 1 and with --quick: stdout and RESULTS.md are identical to run_publish.py once the timing values are masked, including the environment block, every result value and the agreement check. On macOS both harnesses stop at the first clang call, because the publish C sources define _POSIX_C_SOURCE and so hide clock_gettime_nsec_np. The parity runs used a clang wrapper adding -D_DARWIN_C_SOURCE for both; the sources are left as they were and the bug is filed separately.
godofecht
force-pushed
the
port/tools-to-flow
branch
from
September 27, 2026 20:34
83dc868 to
1f551c9
Compare
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
The README names the flow-lsp launcher, since there is no flow lsp subcommand. Reproducible-build docs point at the test that exists. The mathlib TOC drops the Euclid generators removed in #965, and the tests inventory drops a Python test that tests/lang now covers.
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
godofecht
added a commit
that referenced
this pull request
Sep 29, 2026
The README names the flow-lsp launcher, since there is no flow lsp subcommand. Reproducible-build docs point at the test that exists. The mathlib TOC drops the Euclid generators removed in #965, and the tests inventory drops a Python test that tests/lang now covers.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Removes Python from tools/, scripts/tools/, wasm/, benchmarks/, tests/benchmarks/ and challenges/. 89 .py files deleted, 10 ported to Flow with parity checks, and the rest listed below with the reason each one stays. Every ported tool builds with the Stage-A compiler from the checked-in bootstrap C (
scripts/tools/build_tool.sh), so building the tools needs onlycc.scripts/tools/build_tool.sh,lib/json.flowandlib/text.floware byte-identical copies of the ones onport/doc-checkers-to-flow, so the two ports share one toolkit. This PR addslib/regex.flow,lib/proc.flowandlib/bench.flow.Ported (Python deleted in the same PR)
challenges/flow-specific/check.py,test_check.pychallenges/flow-specific/check.sh->scripts/tools/challenge_checkcheck.sh scanover all 2,227 tracked.flowfiles x 36 challenges: 80,172 verdicts byte-identical tocheck_patterns.list,--syntax-onlypass and fail, unknown id, missing file, wrong suffix and directory argument: identical stdout, stderr and exit code. Full runs and--timeout 0: same lines and exit codes.check.sh self-testcarries the threetest_check.pycases plus 43re.searchverdicts recorded from CPython.tools/grad/flow_grad_c.py,flow_grad_flow.py(andscripts/tools/grad/copies)scripts/tools/grad/grad.sh {c,flow}grad.sh flowregenerateslib/stdlib/nn_xor_loss_clean_grad.flowandnn_xor_loss_params_grad.flowbyte for byte.tools/size/measure_size.pyscripts/tools/measure_size/measure_size.shFLOW_HOST=python(the host the Python tool hardcoded), stdout and the--outreport are byte-identical.wasm/flow_wasm_threads.py,flow_wasm_sockets.py,flow_wasm_python.py,flow_wasm_fs.py,flow_wasm_crossings.pywasm/crossings.sh->scripts/tools/wasm_crossings; page text inwasm/crossing_assets/pages/*.html--no-build: every page and asset byte-identical, stdout identical. Full emcc builds of all four crossings plus a single-programfs --fs idbfs --preloadbuild: every.js,.wasmand.dataidentical (fs_preload.jsembeds its own output path; identical once normalised), and the echoed emcc command lines identical../flow wasm --threadsand--fsnow go through it.benchmarks/baselines/run_baselines.pybenchmarks/baselines/run_baselines.sh->scripts/tools/bench_baselinesbaseline_results.mdand.jsonidentical with timing values masked; metadata and results match exactly. The float repr and.2f/.4f/.6fformatting agree with CPython on 5,021 values.benchmarks/run_publish.pybenchmarks/run_publish.sh->scripts/tools/bench_publish--reps 1and--quick: stdout andRESULTS.mdidentical with timings masked, environment block and result values included.The page and docs follow-up commit regenerates the five affected
site/wasm-crossingspages with the new builder names../flow knowand./flow docwere pointing attools/flow_*.pypaths that did not exist; they now point attools/doc/.Deleted without a port
scripts/tools/audio/plot_lattice_allpass.py,lattice_allpass_audio_demo.py,srir_viewer.pytools/audio/. The scripts/tools copies computed the repo root asscripts/, so they were broken.scripts/tools/doc/flow_doc.py,flow_know.pytools/doc/with a broken root.tools/andscripts/tools/backlog_sorter/(15 .py each, plus generated reports)tools/andscripts/tools/euclid/generate_euclid_book_{i..vi}.pyexamples/verify/euclid/. Book I has been hand-edited since, so a rerun destroys content. The TOCgenerator:keys pointed at paths that did not exist; removed.tools/andscripts/tools/jit/flow_jit_pipeline.py,flow_jit_opt.py,simd/simd_check.py./flow jit.simd_check's default inputtests/test_simd_saxpy.flowno longer exists. Only a CHANGELOG line mentioned them.tools/andscripts/tools/debug/flow_debug.py./flow debug(covered bytests/unit/test_debug_info.py).tools/audio/srir_viewer.pydocs/project/archive/.wasm/demo_wasm_build.pyexamples/fibonacci.flowetc.) is gone.wasm/wasm_build_system.pyscripts/build_wasm_gallery.py; referenced only by a README tree.wasm/flow_wasm.py./flow wasm;demos/index.htmlanddocs/language/wasm.mdupdated.benchmarks/benchmark_aosoa.py/app/build/aosoasandbox path; unreferenced.benchmarks/benchmark_gemm_cutlass_evaluation.pycutlass_benchmark_results.txt.tests/benchmarks/publish/python/*,suite/python/*,standardized/record/record_numpy.pybenchmarks/baselines.tests/benchmarks/suite/run_benchmarks.shnow points at thebenchmarks/copies.tests/benchmarks/run_benchmarks.py,run_publish.py,run_publish.shStays in Python, and why
benchmarks/suite/python/*,benchmarks/publish/python/*,benchmarks/cross_harness/**/*.py,benchmarks/standardized/record/record_numpy.pybenchmarks/run_benchmarks.pytests/unit/test_benchmarks.pyimports it (tests/unit is out of scope here).benchmarks/cross_harness/compiler/fusion_benchmark.py,micro/shape_specialization_benchmark.py,micro/transform_tuning_benchmark.py,mlir_pipelining/benchmark.py,gpu/gpu_microbenchmark.py,crossover/calibrate.py,crossover/test_crossover.pyMLIRJIT,MLIROptimizer,cost_model,gpu_runtime,flow.run). They move when those modules do.wasm/flow_wasm_gpu.py,wasm/crossing_common.pysrc/flow'sWgslCodegenandModuleResolver, called in process.crossing_common.pynow serves only this script.wasm/flow_to_wasm.py,wasm/flow_webgpu_shader.py./flow wasm --legacyand the vgpu WGSL preview; both are thin fronts over src/flow's C and WGSL generators.tools/doc/flow_doc.py,flow_know.py./flow docand./flow know; thin CLIs oversrc/flow/know.py,proof_document.pyandproof_kernel.py.tools/audio/plot_lattice_allpass.py,lattice_allpass_audio_demo.pytools/discord-welcome/*.pyNote that the ported WASM, baseline and publish tools still call
python3 -m flow.transpilerto turn Flow into C, as the originals did. That is the src/flow migration's lane.Issues opened
return not <expr>does not parse #963 Stage-A:return not <expr>does not parseAlso hit while porting, already filed: #958 (extern prototypes clash with libc headers:
realpath,strtoll) and #957 (string + string as pointer addition).Not done
docs/language/mathlib-equivalence-toc.mdstill names the retired Euclid generators as plans. Every edit to that file has to clear 38 existing dash tells first, so it is left for a docs pass.docs/library/stdlib-api.mdis generated; itsnn_autogenline updates on the nextgen_stdlib_docs.pyrun (the source comment is updated here).scripts/wasm/holds older copies of the removed wasm helpers; it was outside this PR's scope.