From 39ef72fd6077d31adc17b3f3a5f42dba8cfb8a9a Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Fri, 24 Jul 2026 11:12:49 -0700 Subject: [PATCH 1/7] Update Realm to main as of 2026-07-01. --- .flake/pkgs/realm.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.flake/pkgs/realm.nix b/.flake/pkgs/realm.nix index 336b1c050c..f66da107df 100644 --- a/.flake/pkgs/realm.nix +++ b/.flake/pkgs/realm.nix @@ -13,13 +13,13 @@ in stdenv.mkDerivation rec { pname = "realm"; - version = "2026-02-24"; + version = "2026-07-01"; src = fetchFromGitHub { owner = "StanfordLegion"; repo = "realm"; - rev = "42f7484a80e0bdacaf47d9a758822f5327348dd0"; - sha256 = "sha256-IHiokPmTjEV5df3fr1Xubuyt2N1CFI2fA7Q2TsbxS3Y="; + rev = "dba83452d4a211e3a0c0e5d4849c26ce7b56bba3"; + sha256 = "sha256-dLGmUgupDX0dDErZbuP5ipj2Cwf+rOhVGC/+angRyBY="; }; nativeBuildInputs = [ From 92d462d247007d31274e65f17c0997785f73ebf1 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Sun, 26 Jul 2026 09:06:38 -0700 Subject: [PATCH 2/7] Some initial work on updating Nix. --- .flake/patches/doctest-template-test.patch | 50 ---------------------- .flake/pkgs/fccf/default.nix | 1 + .flake/pkgs/fccf/fix-cstdint-include.patch | 10 +++++ .flake/pkgs/hpp2plantuml.nix | 8 +++- flake.lock | 48 +++++++-------------- flake.nix | 18 ++------ 6 files changed, 37 insertions(+), 98 deletions(-) delete mode 100644 .flake/patches/doctest-template-test.patch create mode 100644 .flake/pkgs/fccf/fix-cstdint-include.patch diff --git a/.flake/patches/doctest-template-test.patch b/.flake/patches/doctest-template-test.patch deleted file mode 100644 index ca4d0d9a18..0000000000 --- a/.flake/patches/doctest-template-test.patch +++ /dev/null @@ -1,50 +0,0 @@ -diff --git a/scripts/cmake/doctestAddTests.cmake b/scripts/cmake/doctestAddTests.cmake -index 3b25485..d3ba906 100644 ---- a/scripts/cmake/doctestAddTests.cmake -+++ b/scripts/cmake/doctestAddTests.cmake -@@ -56,12 +56,14 @@ foreach(line ${output}) - if("${line}" STREQUAL "===============================================================================" OR "${line}" MATCHES [==[^\[doctest\] ]==]) - continue() - endif() -- set(test ${line}) -+ set(unescaped_test ${line}) -+ # use escape commas to handle properly test cases with commas inside the name -+ string(REPLACE "," "\\," escaped_test ${unescaped_test}) - set(labels "") - if(${add_labels}) - # get test suite that test belongs to - execute_process( -- COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${test} --list-test-suites -+ COMMAND ${TEST_EXECUTOR} "${TEST_EXECUTABLE}" --test-case=${escaped_test} --list-test-suites - OUTPUT_VARIABLE labeloutput - RESULT_VARIABLE labelresult - WORKING_DIRECTORY "${TEST_WORKING_DIR}" -@@ -85,24 +87,22 @@ foreach(line ${output}) - - if(NOT "${junit_output_dir}" STREQUAL "") - # turn testname into a valid filename by replacing all special characters with "-" -- string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${test}") -+ string(REGEX REPLACE "[/\\:\"|<>]" "-" test_filename "${unescaped_test}") - set(TEST_JUNIT_OUTPUT_PARAM "--reporters=junit" "--out=${junit_output_dir}/${prefix}${test_filename}${suffix}.xml") - else() - unset(TEST_JUNIT_OUTPUT_PARAM) - endif() -- # use escape commas to handle properly test cases with commas inside the name -- string(REPLACE "," "\\," test_name ${test}) - # ...and add to script - add_command(add_test -- "${prefix}${test}${suffix}" -+ "${prefix}${unescaped_test}${suffix}" - ${TEST_EXECUTOR} - "${TEST_EXECUTABLE}" -- "--test-case=${test_name}" -+ "--test-case=${escaped_test}" - "${TEST_JUNIT_OUTPUT_PARAM}" - ${extra_args} - ) - add_command(set_tests_properties -- "${prefix}${test}${suffix}" -+ "${prefix}${unescaped_test}${suffix}" - PROPERTIES - WORKING_DIRECTORY "${TEST_WORKING_DIR}" - ${properties} diff --git a/.flake/pkgs/fccf/default.nix b/.flake/pkgs/fccf/default.nix index f792b8606c..8196b436c4 100644 --- a/.flake/pkgs/fccf/default.nix +++ b/.flake/pkgs/fccf/default.nix @@ -39,6 +39,7 @@ stdenv.mkDerivation rec { patches = [ ./json-package-name.patch ./fix-argparse-include.patch + ./fix-cstdint-include.patch ]; cmakeFlags = [ diff --git a/.flake/pkgs/fccf/fix-cstdint-include.patch b/.flake/pkgs/fccf/fix-cstdint-include.patch new file mode 100644 index 0000000000..c7a6a41574 --- /dev/null +++ b/.flake/pkgs/fccf/fix-cstdint-include.patch @@ -0,0 +1,10 @@ +diff --git a/source/sse2_strstr.cpp b/source/sse2_strstr.cpp +index 44441ea..347cafd 100644 +--- a/source/sse2_strstr.cpp ++++ b/source/sse2_strstr.cpp +@@ -1,4 +1,5 @@ + #include ++#include + #include + + #include diff --git a/.flake/pkgs/hpp2plantuml.nix b/.flake/pkgs/hpp2plantuml.nix index d5aba814f1..41d7ef81b1 100644 --- a/.flake/pkgs/hpp2plantuml.nix +++ b/.flake/pkgs/hpp2plantuml.nix @@ -1,4 +1,10 @@ -{buildPythonPackage, fetchPypi}: +{ buildPythonPackage +, fetchPypi +, argparse +, jinja2 +#, robotpy-cppheaderparser +, sphinx +}: buildPythonPackage rec { pname = "hpp2plantuml"; diff --git a/flake.lock b/flake.lock index 233e2265e2..df7727a70d 100644 --- a/flake.lock +++ b/flake.lock @@ -43,16 +43,15 @@ }, "nixpkgs": { "locked": { - "lastModified": 1710162809, - "narHash": "sha256-i2R2bcnQp+85de67yjgZVvJhd6rRnJbSYNpGmB6Leb8=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "ddcd7598b2184008c97e6c9c6a21c5f37590b8d2", - "type": "github" + "lastModified": 315532800, + "narHash": "sha256-DUedXhD2Rg8q4Xyd07Sb90eZGy4gg6W+Vl/WbLNwAZo=", + "rev": "b3fe9581c9061c749abef42b6d4ee7b7c05c33fa", + "type": "tarball", + "url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.5845.b3fe9581c906/nixexprs.tar.xz?lastModified=1784707089" }, "original": { "id": "nixpkgs", - "ref": "nixos-23.11", + "ref": "nixos-26.05", "type": "indirect" } }, @@ -63,37 +62,22 @@ ], "nixpkgs": [ "nixpkgs" - ], - "python38-nixpkgs": "python38-nixpkgs" + ] }, "locked": { - "lastModified": 1781917763, - "narHash": "sha256-Qd8CW+G/orxU9Ne6fNqKAbJL404WeV7/kdY/9TNJ5Lw=", - "ref": "refs/heads/master", - "rev": "f2bdddab299b98fb67612e3c04136949b2339d74", - "revCount": 161, + "lastModified": 1785081061, + "narHash": "sha256-Neapvd+ky7n61Ygk94prCvoOD24vHDx+ndfS55yUWlQ=", + "ref": "refs/heads/update-nix", + "rev": "095474d22a73d8f1dc246a999f848d053e788c1d", + "revCount": 166, "type": "git", - "url": "https://git.sr.ht/~lockshaw/proj" + "url": "https://github.com/elliottslaughter/proj.git" }, "original": { + "ref": "refs/heads/update-nix", + "rev": "095474d22a73d8f1dc246a999f848d053e788c1d", "type": "git", - "url": "https://git.sr.ht/~lockshaw/proj" - } - }, - "python38-nixpkgs": { - "locked": { - "lastModified": 1645131486, - "narHash": "sha256-AuWJe0TiqHD6L7Vzcar4QOblMGubKHsuVs3YFMCRYl0=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "7592790b9e02f7f99ddcb1bd33fd44ff8df6a9a7", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "rev": "7592790b9e02f7f99ddcb1bd33fd44ff8df6a9a7", - "type": "github" + "url": "https://github.com/elliottslaughter/proj.git" } }, "root": { diff --git a/flake.nix b/flake.nix index ad71cbefb4..c92bca9ff1 100644 --- a/flake.nix +++ b/flake.nix @@ -14,11 +14,11 @@ }; inputs = { - nixpkgs.url = "nixpkgs/nixos-23.11"; + nixpkgs.url = "nixpkgs/nixos-26.05"; flake-utils.url = "github:numtide/flake-utils"; proj-repo = { - url = "git+https://git.sr.ht/~lockshaw/proj"; + url = "git+https://github.com/elliottslaughter/proj.git?ref=refs/heads/update-nix&rev=095474d22a73d8f1dc246a999f848d053e788c1d"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; @@ -64,18 +64,6 @@ name = "rapidcheckFull"; paths = (with pkgs; [ rapidcheck.out rapidcheck.dev ]); }; - doctest = pkgs.doctest.overrideAttrs ( old: rec { - version = "2.4.9"; - src = pkgs.fetchFromGitHub { - owner = "doctest"; - repo = "doctest"; - rev = "v${version}"; - sha256 = "sha256-ugmkeX2PN4xzxAZpWgswl4zd2u125Q/ADSKzqTfnd94="; - }; - patches = [ - ./.flake/patches/doctest-template-test.patch - ]; - }); }; devShells = rec { @@ -102,6 +90,7 @@ cudaPackages.nccl cudaPackages.libcublas cudaPackages.cuda_cudart + doctest tl-expected doxygen lcov # for code coverage @@ -118,7 +107,6 @@ libassert realm rapidcheckFull - doctest ]) ]; }; From 0ee3795ea4cb9d17acfb0acc9f0f480b8e501ff3 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Sun, 26 Jul 2026 13:35:49 -0700 Subject: [PATCH 3/7] Checkpoint working CPU-only build. --- .flake/pkgs/bencher-cli.nix | 2 +- .flake/pkgs/hpp2plantuml.nix | 15 +++++- .flake/pkgs/robotpy-cppheaderparser.nix | 22 +++++++++ contributing.dox | 2 +- flake.lock | 10 ++-- flake.nix | 48 +++++++++++++++++-- lib/op-attrs/include/op-attrs/parallel_dim.h | 3 +- lib/op-attrs/src/op-attrs/parallel_dim.cc | 4 +- lib/utils/include/utils/containers/filter.h | 1 + .../include/utils/containers/inplace_filter.h | 3 ++ .../utils/containers/unordered_set_of.h | 2 +- .../kwarg_dataflow_input.dtg.toml | 1 + .../kwarg_dataflow_output.dtg.toml | 1 + .../utils/containers/merge_disjoint_maps.cc | 4 +- .../merge_maps_with_right_dominating.cc | 4 +- ...ge_unordered_maps_with_right_dominating.cc | 5 +- 16 files changed, 103 insertions(+), 24 deletions(-) create mode 100644 .flake/pkgs/robotpy-cppheaderparser.nix diff --git a/.flake/pkgs/bencher-cli.nix b/.flake/pkgs/bencher-cli.nix index bd7b908786..a920da6329 100644 --- a/.flake/pkgs/bencher-cli.nix +++ b/.flake/pkgs/bencher-cli.nix @@ -1,7 +1,7 @@ { stdenv , lib , fetchurl -, alsaLib +, alsa-lib , openssl , zlib , pulseaudio diff --git a/.flake/pkgs/hpp2plantuml.nix b/.flake/pkgs/hpp2plantuml.nix index 41d7ef81b1..46ee0eef76 100644 --- a/.flake/pkgs/hpp2plantuml.nix +++ b/.flake/pkgs/hpp2plantuml.nix @@ -1,8 +1,7 @@ { buildPythonPackage , fetchPypi -, argparse , jinja2 -#, robotpy-cppheaderparser +, robotpy-cppheaderparser , sphinx }: @@ -14,4 +13,16 @@ buildPythonPackage rec { inherit pname version format; sha256 = "sha256-PfTJmBypI21AAK3sMojygQfrhnRqcMmVCW4dxGfDfQg="; }; + + # argparse is part of the python 3 standard library, so there is no + # corresponding nixpkgs package to depend on. + pythonRemoveDeps = [ "argparse" ]; + + dependencies = [ + jinja2 + robotpy-cppheaderparser + sphinx + ]; + + pythonImportsCheck = [ "hpp2plantuml" ]; } diff --git a/.flake/pkgs/robotpy-cppheaderparser.nix b/.flake/pkgs/robotpy-cppheaderparser.nix new file mode 100644 index 0000000000..e574205be7 --- /dev/null +++ b/.flake/pkgs/robotpy-cppheaderparser.nix @@ -0,0 +1,22 @@ +{ buildPythonPackage +, fetchPypi +, setuptools +, ply +}: + +buildPythonPackage rec { + pname = "robotpy-cppheaderparser"; + version = "5.1.2"; + pyproject = true; + + src = fetchPypi { + inherit pname version; + sha256 = "sha256-FdNQs5NYtFzbH+E4r578zg5jLBtYgwoboboJihdSaYs="; + }; + + build-system = [ setuptools ]; + + dependencies = [ ply ]; + + pythonImportsCheck = [ "CppHeaderParser" ]; +} diff --git a/contributing.dox b/contributing.dox index b86be494c5..7595cfaa61 100644 --- a/contributing.dox +++ b/contributing.dox @@ -189,7 +189,7 @@ We actively welcome your pull requests. Note that we may already be working on t The steps for getting changes merged into %FlexFlow are relatively standard: 1. [Fork the repo](https://github.com/flexflow/flexflow-train/fork) and either create a new branch based on `master`, or just modify `master` directly. -2. If you've added code that should be tested, add tests. The process for adding tests for code under `lib` is documented [here](./lib/README.md#tests). Adding tests for other parts of the code is currently undocumented, so you will \ref contributing-contact-us "contact us" for information on how to do it. +2. If you've added code that should be tested, add tests. The process for adding tests is currently undocumented, so you will \ref contributing-contact-us "contact us" for information on how to do it. 3. Ensure the code builds (i.e., run `proj build`). 4. Ensure the test suite passes (i.e., run `proj test`). 5. Format the code (i.e., run `proj format`). diff --git a/flake.lock b/flake.lock index df7727a70d..96ed16b784 100644 --- a/flake.lock +++ b/flake.lock @@ -65,17 +65,17 @@ ] }, "locked": { - "lastModified": 1785081061, - "narHash": "sha256-Neapvd+ky7n61Ygk94prCvoOD24vHDx+ndfS55yUWlQ=", + "lastModified": 1785092161, + "narHash": "sha256-ie84PqMqUQNxAknPBdzKSWIInSS4ZSTCJ0JbISEZTAU=", "ref": "refs/heads/update-nix", - "rev": "095474d22a73d8f1dc246a999f848d053e788c1d", - "revCount": 166, + "rev": "6221d815035398e8fce12a55b79fd7bd7d077965", + "revCount": 162, "type": "git", "url": "https://github.com/elliottslaughter/proj.git" }, "original": { "ref": "refs/heads/update-nix", - "rev": "095474d22a73d8f1dc246a999f848d053e788c1d", + "rev": "6221d815035398e8fce12a55b79fd7bd7d077965", "type": "git", "url": "https://github.com/elliottslaughter/proj.git" } diff --git a/flake.nix b/flake.nix index c92bca9ff1..b72577660e 100644 --- a/flake.nix +++ b/flake.nix @@ -18,7 +18,7 @@ flake-utils.url = "github:numtide/flake-utils"; proj-repo = { - url = "git+https://github.com/elliottslaughter/proj.git?ref=refs/heads/update-nix&rev=095474d22a73d8f1dc246a999f848d053e788c1d"; + url = "git+https://github.com/elliottslaughter/proj.git?ref=refs/heads/update-nix&rev=6221d815035398e8fce12a55b79fd7bd7d077965"; inputs.nixpkgs.follows = "nixpkgs"; inputs.flake-utils.follows = "flake-utils"; }; @@ -58,7 +58,8 @@ realm = pkgs.callPackage ./.flake/pkgs/realm.nix { }; bencher-cli = pkgs.callPackage ./.flake/pkgs/bencher-cli.nix { }; ffdb = pkgs.callPackage ./.flake/pkgs/ffdb { inherit proj; }; - hpp2plantuml = pkgs.python3Packages.callPackage ./.flake/pkgs/hpp2plantuml.nix { }; + robotpy-cppheaderparser = pkgs.python3Packages.callPackage ./.flake/pkgs/robotpy-cppheaderparser.nix { }; + hpp2plantuml = pkgs.python3Packages.callPackage ./.flake/pkgs/hpp2plantuml.nix { inherit robotpy-cppheaderparser; }; fccf = pkgs.callPackage ./.flake/pkgs/fccf { }; rapidcheckFull = pkgs.symlinkJoin { name = "rapidcheckFull"; @@ -70,6 +71,41 @@ ci = mkShell { shellHook = '' export RC_PARAMS="max_discard_ratio=100" + + # nix passes dependency include paths through NIX_CFLAGS_COMPILE + # rather than on the compiler command line, so ccache cannot see + # them change. its manifests reference store paths that are still + # present and unmodified, so bumping a dependency (e.g. fmt) yields + # false cache hits that return objects built against the old + # headers. folding the flags into the hash invalidates those. + # -frandom-seed is a per-derivation nonce, so it is dropped to keep + # unrelated devshell edits from invalidating the whole cache. + # the flags are reduced to a digest and combined with "%compiler% -v" + # so that the compiler's own identity keeps being hashed too -- + # setting a plain "string:" check would drop it, and a gcc bump that + # left the include paths untouched would then go unnoticed. + ccache_flag_id="$( + printf '%s' "$NIX_CFLAGS_COMPILE" \ + | tr ' ' '\n' \ + | grep -v '^-frandom-seed=' \ + | sha256sum \ + | cut -d' ' -f1 + )" + export CCACHE_COMPILERCHECK="%compiler% -v; echo $ccache_flag_id" + unset ccache_flag_id + + # cudaPackages.backendStdenv pins gcc to a version cuda accepts, + # but the wrapper still puts the default stdenv gcc's library + # directory ahead of it, so -lgcov resolves to a libgcov whose + # format does not match the instrumentation the pinned gcc emits + # and every coverage run dies with "Version mismatch". this + # directory holds only static archives (libgcc, libgcov) and crt + # objects, so preferring it does not affect libstdc++ resolution. + gcc_static_lib_dir="$(dirname "$(''${CXX:-g++} -print-file-name=libgcov.a)")" + case "$gcc_static_lib_dir" in + /*) export NIX_CFLAGS_LINK="-L$gcc_static_lib_dir $NIX_CFLAGS_LINK" ;; + esac + unset gcc_static_lib_dir ''; buildInputs = builtins.concatLists [ @@ -77,9 +113,13 @@ zlib boost nlohmann_json - spdlog + # nixpkgs' spdlog is built against the default fmt, so it has to + # be rebuilt to match the fmt we actually use. + (spdlog.override { fmt = fmt_10; }) range-v3 - fmt + # fmt 11 removed fmt::detail::has_format_as, which lib/utils/fmt/* + # relies on to avoid ambiguity with fmt's own formatters. + fmt_10 cmakeCurses ccache pkg-config diff --git a/lib/op-attrs/include/op-attrs/parallel_dim.h b/lib/op-attrs/include/op-attrs/parallel_dim.h index a12951dec9..ec56dd4f26 100644 --- a/lib/op-attrs/include/op-attrs/parallel_dim.h +++ b/lib/op-attrs/include/op-attrs/parallel_dim.h @@ -2,6 +2,7 @@ #define _FLEXFLOW_OP_ATTRS_INCLUDE_OP_ATTRS_PARALLEL_DIM_H #include "op-attrs/parallel_dim.dtg.h" +#include "utils/positive_int/positive_int.h" namespace FlexFlow { @@ -11,7 +12,7 @@ bool is_replica_dim(ParallelDim const &); ParallelDim with_size_set_to(ParallelDim const &, size_t); ParallelDim with_degree_set_to(ParallelDim const &, int); ParallelDim with_is_replica_set_to(ParallelDim const &, bool); -int get_degree(ParallelDim const &); +positive_int get_degree(ParallelDim const &); } // namespace FlexFlow diff --git a/lib/op-attrs/src/op-attrs/parallel_dim.cc b/lib/op-attrs/src/op-attrs/parallel_dim.cc index 26ba2b3fa1..116d72e5be 100644 --- a/lib/op-attrs/src/op-attrs/parallel_dim.cc +++ b/lib/op-attrs/src/op-attrs/parallel_dim.cc @@ -3,8 +3,8 @@ namespace FlexFlow { -int get_degree(ParallelDim const &dim) { - return dim.visit(overload{ +positive_int get_degree(ParallelDim const &dim) { + return dim.visit(overload{ [](ShardParallelDim const &shard_dim) { return shard_dim.degree; }, [](ReplicaParallelDim const &replica_dim) { return replica_dim.degree; diff --git a/lib/utils/include/utils/containers/filter.h b/lib/utils/include/utils/containers/filter.h index 85a413c2c7..1b39dec2cd 100644 --- a/lib/utils/include/utils/containers/filter.h +++ b/lib/utils/include/utils/containers/filter.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include diff --git a/lib/utils/include/utils/containers/inplace_filter.h b/lib/utils/include/utils/containers/inplace_filter.h index dc0491773f..2e696613ec 100644 --- a/lib/utils/include/utils/containers/inplace_filter.h +++ b/lib/utils/include/utils/containers/inplace_filter.h @@ -3,6 +3,9 @@ #include "utils/containers/filter.h" #include +#include +#include +#include #include #include diff --git a/lib/utils/include/utils/containers/unordered_set_of.h b/lib/utils/include/utils/containers/unordered_set_of.h index 5a8dcd9f55..011ecb515d 100644 --- a/lib/utils/include/utils/containers/unordered_set_of.h +++ b/lib/utils/include/utils/containers/unordered_set_of.h @@ -9,7 +9,7 @@ namespace FlexFlow { template std::unordered_set unordered_set_of(C const &c) { - return std::unordered_set{c.cbegin(), c.cend()}; + return std::unordered_set{c.cbegin(), c.cend()}; } template diff --git a/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_input.dtg.toml b/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_input.dtg.toml index 5f092f0540..3278ebda48 100644 --- a/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_input.dtg.toml +++ b/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_input.dtg.toml @@ -13,6 +13,7 @@ template_params = [ ] includes = [ + "utils/fmt/optional.h", "utils/graph/node/node.dtg.h", ] diff --git a/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_output.dtg.toml b/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_output.dtg.toml index 9a58e2f686..88a90ba00b 100644 --- a/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_output.dtg.toml +++ b/lib/utils/include/utils/graph/kwarg_dataflow_graph/kwarg_dataflow_output.dtg.toml @@ -14,6 +14,7 @@ template_params = [ ] includes = [ + "utils/fmt/optional.h", "utils/graph/node/node.dtg.h", "utils/nonnegative_int/nonnegative_int.h", ] diff --git a/lib/utils/src/utils/containers/merge_disjoint_maps.cc b/lib/utils/src/utils/containers/merge_disjoint_maps.cc index cf2d0fd3ec..0adc2896d6 100644 --- a/lib/utils/src/utils/containers/merge_disjoint_maps.cc +++ b/lib/utils/src/utils/containers/merge_disjoint_maps.cc @@ -6,8 +6,8 @@ namespace FlexFlow { using K = ordered_value_type<0>; using V = value_type<1>; -using C = std::vector>; -template std::map merge_disjoint_maps(C const &); +template std::map + merge_disjoint_maps(std::vector> const &); } // namespace FlexFlow diff --git a/lib/utils/src/utils/containers/merge_maps_with_right_dominating.cc b/lib/utils/src/utils/containers/merge_maps_with_right_dominating.cc index dff4708c81..032b8cdaf3 100644 --- a/lib/utils/src/utils/containers/merge_maps_with_right_dominating.cc +++ b/lib/utils/src/utils/containers/merge_maps_with_right_dominating.cc @@ -6,8 +6,8 @@ namespace FlexFlow { using K = ordered_value_type<0>; using V = value_type<1>; -using C = std::vector>; -template std::map merge_maps_with_right_dominating(C const &); +template std::map + merge_maps_with_right_dominating(std::vector> const &); } // namespace FlexFlow diff --git a/lib/utils/src/utils/containers/merge_unordered_maps_with_right_dominating.cc b/lib/utils/src/utils/containers/merge_unordered_maps_with_right_dominating.cc index 9208df8f6a..408beca434 100644 --- a/lib/utils/src/utils/containers/merge_unordered_maps_with_right_dominating.cc +++ b/lib/utils/src/utils/containers/merge_unordered_maps_with_right_dominating.cc @@ -5,9 +5,8 @@ namespace FlexFlow { using K = value_type<0>; using V = value_type<1>; -using C = std::vector>; -template std::unordered_map - merge_unordered_maps_with_right_dominating(C const &); +template std::unordered_map merge_unordered_maps_with_right_dominating( + std::vector> const &); } // namespace FlexFlow From 466e9cb4787870de33b5aefdccc013debc41fe43 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Mon, 27 Jul 2026 07:14:54 -0700 Subject: [PATCH 4/7] Checkpoint working GPU build. --- .../patches/nixgl-drop-kernel-override.patch | 21 ++++++++++++ flake.nix | 33 ++++++++++++++++--- .../test/src/realm-execution/test_e2e.cc | 2 +- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 .flake/patches/nixgl-drop-kernel-override.patch diff --git a/.flake/patches/nixgl-drop-kernel-override.patch b/.flake/patches/nixgl-drop-kernel-override.patch new file mode 100644 index 0000000000..92af0cad61 --- /dev/null +++ b/.flake/patches/nixgl-drop-kernel-override.patch @@ -0,0 +1,21 @@ +nixGL overrides nvidia_x11 with `kernel = null` to ask for a userspace-only +build. As of nixpkgs 25.11 the nvidia-x11 generic no longer takes a `kernel` +argument, so the override fails to evaluate with: + + error: function 'anonymous lambda' called with unexpected argument 'kernel' + +`libsOnly = true` already suppresses the kernel module, so the argument was +redundant even before it was removed. + +Reported upstream as of nixGL b6105297e6f0 (still present on master). + +--- a/nixGL.nix ++++ b/nixGL.nix +@@ -86,7 +86,6 @@ + + nvidiaLibsOnly = nvidiaDrivers.override { + libsOnly = true; +- kernel = null; + }; + + nixGLNvidiaBumblebee = writeExecutable { diff --git a/flake.nix b/flake.nix index b72577660e..51243e03e1 100644 --- a/flake.nix +++ b/flake.nix @@ -49,6 +49,17 @@ }); proj = proj-repo.packages.${system}.proj; + + # nixGL's own flake output cannot be used as-is: it overrides nvidia_x11 + # with an argument nixpkgs no longer accepts. its default.nix takes the + # package set to build against, so instantiate it from patched sources. + nixgl = import (pkgs.applyPatches { + name = "nixGL-patched-source"; + src = nixGL; + patches = [ ./.flake/patches/nixgl-drop-kernel-override.patch ]; + }) { + inherit pkgs; + }; in { packages = rec { @@ -56,6 +67,20 @@ cpptrace = pkgs.callPackage ./.flake/pkgs/cpptrace.nix { inherit libdwarf-lite; }; libassert = pkgs.callPackage ./.flake/pkgs/libassert.nix { inherit cpptrace; }; realm = pkgs.callPackage ./.flake/pkgs/realm.nix { }; + + # cuDNN 9.11 dropped every compute capability below 7.5, which excludes + # the pascal (sm_60) cards we develop on -- the ops/adv/cnn sublibraries + # simply carry no sm_60 kernels, so calls fail at runtime with + # CUDNN_STATUS_EXECUTION_FAILED_CUDART. 9.10.2 is the last release that + # still ships them, and its sm_70 cubins remain binary compatible with + # the turing cards CI runs on. + cudnn = pkgs.cudaPackages.cudnn.overrideAttrs (finalAttrs: _: { + version = "9.10.2.21"; + src = pkgs.fetchurl { + url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${finalAttrs.version}_cuda12-archive.tar.xz"; + hash = "sha256-0N78vExtrXEf9Mtm0lQDajAMkHGwfHtkGZqsq1NDE8E="; + }; + }); bencher-cli = pkgs.callPackage ./.flake/pkgs/bencher-cli.nix { }; ffdb = pkgs.callPackage ./.flake/pkgs/ffdb { inherit proj; }; robotpy-cppheaderparser = pkgs.python3Packages.callPackage ./.flake/pkgs/robotpy-cppheaderparser.nix { }; @@ -126,7 +151,6 @@ python3 cudatoolkit cudaPackages.cuda_nvcc - cudaPackages.cudnn cudaPackages.nccl cudaPackages.libcublas cudaPackages.cuda_cudart @@ -144,6 +168,7 @@ proj ]) (with self.packages.${system}; [ + cudnn libassert realm rapidcheckFull @@ -156,9 +181,9 @@ hardeningDisable = [ "all" ]; buildInputs = builtins.concatLists [ - (with nixGL.packages.${system}; [ - nixGLDefault - ]) + [ + nixgl.auto.nixGLDefault + ] ]; }; diff --git a/lib/realm-execution/test/src/realm-execution/test_e2e.cc b/lib/realm-execution/test/src/realm-execution/test_e2e.cc index 9ba4886b4b..2c72da44a1 100644 --- a/lib/realm-execution/test/src/realm-execution/test_e2e.cc +++ b/lib/realm-execution/test/src/realm-execution/test_e2e.cc @@ -545,7 +545,7 @@ TEST_SUITE(FF_CUDA_TEST_SUITE) { //! [realm-execution example] std::vector fake_args = - make_fake_realm_args(/*num_cpus=*/1_p, /*num_gpus=*/1_n); + make_fake_realm_args(/*num_cpus=*/1_p, /*num_gpus=*/2_n); int fake_argc = fake_args.size(); char **fake_argv = fake_args.data(); From 103f8765a89179708529448cffa70164a3f59c40 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Mon, 27 Jul 2026 08:41:53 -0700 Subject: [PATCH 5/7] Refactoring. --- .../patches/nixgl-drop-kernel-override.patch | 21 --------------- .flake/pkgs/cudnn.nix | 13 ++++++++++ .flake/pkgs/nixgl/default.nix | 18 +++++++++++++ .flake/pkgs/nixgl/drop-kernel-override.patch | 16 ++++++++++++ flake.nix | 26 ++----------------- 5 files changed, 49 insertions(+), 45 deletions(-) delete mode 100644 .flake/patches/nixgl-drop-kernel-override.patch create mode 100644 .flake/pkgs/cudnn.nix create mode 100644 .flake/pkgs/nixgl/default.nix create mode 100644 .flake/pkgs/nixgl/drop-kernel-override.patch diff --git a/.flake/patches/nixgl-drop-kernel-override.patch b/.flake/patches/nixgl-drop-kernel-override.patch deleted file mode 100644 index 92af0cad61..0000000000 --- a/.flake/patches/nixgl-drop-kernel-override.patch +++ /dev/null @@ -1,21 +0,0 @@ -nixGL overrides nvidia_x11 with `kernel = null` to ask for a userspace-only -build. As of nixpkgs 25.11 the nvidia-x11 generic no longer takes a `kernel` -argument, so the override fails to evaluate with: - - error: function 'anonymous lambda' called with unexpected argument 'kernel' - -`libsOnly = true` already suppresses the kernel module, so the argument was -redundant even before it was removed. - -Reported upstream as of nixGL b6105297e6f0 (still present on master). - ---- a/nixGL.nix -+++ b/nixGL.nix -@@ -86,7 +86,6 @@ - - nvidiaLibsOnly = nvidiaDrivers.override { - libsOnly = true; -- kernel = null; - }; - - nixGLNvidiaBumblebee = writeExecutable { diff --git a/.flake/pkgs/cudnn.nix b/.flake/pkgs/cudnn.nix new file mode 100644 index 0000000000..3c36e19041 --- /dev/null +++ b/.flake/pkgs/cudnn.nix @@ -0,0 +1,13 @@ +{ cudaPackages +, fetchurl +}: + +# Pin the latest cuDNN version with support for NVIDIA Pascal GPUs. +cudaPackages.cudnn.overrideAttrs (finalAttrs: _: { + version = "9.10.2.21"; + + src = fetchurl { + url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${finalAttrs.version}_cuda12-archive.tar.xz"; + hash = "sha256-0N78vExtrXEf9Mtm0lQDajAMkHGwfHtkGZqsq1NDE8E="; + }; +}) diff --git a/.flake/pkgs/nixgl/default.nix b/.flake/pkgs/nixgl/default.nix new file mode 100644 index 0000000000..429b3c2481 --- /dev/null +++ b/.flake/pkgs/nixgl/default.nix @@ -0,0 +1,18 @@ +{ applyPatches +, pkgs +, src +}: + +# Need a not-yet-merged PR for nixGL compatibility with NixOS 26.05. +# +# This evaluates to nixGL's package set, not a derivation, so it belongs in a +# let binding rather than in the flake's `packages` output. +import + (applyPatches { + name = "nixGL-patched-source"; + inherit src; + patches = [ ./drop-kernel-override.patch ]; + }) + { + inherit pkgs; + } diff --git a/.flake/pkgs/nixgl/drop-kernel-override.patch b/.flake/pkgs/nixgl/drop-kernel-override.patch new file mode 100644 index 0000000000..e57e07a25a --- /dev/null +++ b/.flake/pkgs/nixgl/drop-kernel-override.patch @@ -0,0 +1,16 @@ +`kernel` parameter is gone as of https://github.com/NixOS/nixpkgs/pull/498612 + +Matching PR for nixGL in https://github.com/nix-community/nixGL/pull/223 +(among other things, not relevant to our use case) +and has not been merged as of 2026-07-27. + +--- a/nixGL.nix ++++ b/nixGL.nix +@@ -86,7 +86,6 @@ + + nvidiaLibsOnly = nvidiaDrivers.override { + libsOnly = true; +- kernel = null; + }; + + nixGLNvidiaBumblebee = writeExecutable { diff --git a/flake.nix b/flake.nix index 51243e03e1..c3518f5e2c 100644 --- a/flake.nix +++ b/flake.nix @@ -50,16 +50,7 @@ proj = proj-repo.packages.${system}.proj; - # nixGL's own flake output cannot be used as-is: it overrides nvidia_x11 - # with an argument nixpkgs no longer accepts. its default.nix takes the - # package set to build against, so instantiate it from patched sources. - nixgl = import (pkgs.applyPatches { - name = "nixGL-patched-source"; - src = nixGL; - patches = [ ./.flake/patches/nixgl-drop-kernel-override.patch ]; - }) { - inherit pkgs; - }; + nixgl = pkgs.callPackage ./.flake/pkgs/nixgl { inherit pkgs; src = nixGL; }; in { packages = rec { @@ -67,20 +58,7 @@ cpptrace = pkgs.callPackage ./.flake/pkgs/cpptrace.nix { inherit libdwarf-lite; }; libassert = pkgs.callPackage ./.flake/pkgs/libassert.nix { inherit cpptrace; }; realm = pkgs.callPackage ./.flake/pkgs/realm.nix { }; - - # cuDNN 9.11 dropped every compute capability below 7.5, which excludes - # the pascal (sm_60) cards we develop on -- the ops/adv/cnn sublibraries - # simply carry no sm_60 kernels, so calls fail at runtime with - # CUDNN_STATUS_EXECUTION_FAILED_CUDART. 9.10.2 is the last release that - # still ships them, and its sm_70 cubins remain binary compatible with - # the turing cards CI runs on. - cudnn = pkgs.cudaPackages.cudnn.overrideAttrs (finalAttrs: _: { - version = "9.10.2.21"; - src = pkgs.fetchurl { - url = "https://developer.download.nvidia.com/compute/cudnn/redist/cudnn/linux-x86_64/cudnn-linux-x86_64-${finalAttrs.version}_cuda12-archive.tar.xz"; - hash = "sha256-0N78vExtrXEf9Mtm0lQDajAMkHGwfHtkGZqsq1NDE8E="; - }; - }); + cudnn = pkgs.callPackage ./.flake/pkgs/cudnn.nix { }; bencher-cli = pkgs.callPackage ./.flake/pkgs/bencher-cli.nix { }; ffdb = pkgs.callPackage ./.flake/pkgs/ffdb { inherit proj; }; robotpy-cppheaderparser = pkgs.python3Packages.callPackage ./.flake/pkgs/robotpy-cppheaderparser.nix { }; From 938919dccf124e0a0d69972d85b691cb23557d87 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Mon, 27 Jul 2026 09:48:04 -0700 Subject: [PATCH 6/7] Cleanup. --- flake.nix | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/flake.nix b/flake.nix index c3518f5e2c..341b5e1c8c 100644 --- a/flake.nix +++ b/flake.nix @@ -74,41 +74,6 @@ ci = mkShell { shellHook = '' export RC_PARAMS="max_discard_ratio=100" - - # nix passes dependency include paths through NIX_CFLAGS_COMPILE - # rather than on the compiler command line, so ccache cannot see - # them change. its manifests reference store paths that are still - # present and unmodified, so bumping a dependency (e.g. fmt) yields - # false cache hits that return objects built against the old - # headers. folding the flags into the hash invalidates those. - # -frandom-seed is a per-derivation nonce, so it is dropped to keep - # unrelated devshell edits from invalidating the whole cache. - # the flags are reduced to a digest and combined with "%compiler% -v" - # so that the compiler's own identity keeps being hashed too -- - # setting a plain "string:" check would drop it, and a gcc bump that - # left the include paths untouched would then go unnoticed. - ccache_flag_id="$( - printf '%s' "$NIX_CFLAGS_COMPILE" \ - | tr ' ' '\n' \ - | grep -v '^-frandom-seed=' \ - | sha256sum \ - | cut -d' ' -f1 - )" - export CCACHE_COMPILERCHECK="%compiler% -v; echo $ccache_flag_id" - unset ccache_flag_id - - # cudaPackages.backendStdenv pins gcc to a version cuda accepts, - # but the wrapper still puts the default stdenv gcc's library - # directory ahead of it, so -lgcov resolves to a libgcov whose - # format does not match the instrumentation the pinned gcc emits - # and every coverage run dies with "Version mismatch". this - # directory holds only static archives (libgcc, libgcov) and crt - # objects, so preferring it does not affect libstdc++ resolution. - gcc_static_lib_dir="$(dirname "$(''${CXX:-g++} -print-file-name=libgcov.a)")" - case "$gcc_static_lib_dir" in - /*) export NIX_CFLAGS_LINK="-L$gcc_static_lib_dir $NIX_CFLAGS_LINK" ;; - esac - unset gcc_static_lib_dir ''; buildInputs = builtins.concatLists [ @@ -116,12 +81,8 @@ zlib boost nlohmann_json - # nixpkgs' spdlog is built against the default fmt, so it has to - # be rebuilt to match the fmt we actually use. (spdlog.override { fmt = fmt_10; }) range-v3 - # fmt 11 removed fmt::detail::has_format_as, which lib/utils/fmt/* - # relies on to avoid ambiguity with fmt's own formatters. fmt_10 cmakeCurses ccache From 543336407dea0268bd23a16f3c3c8c692dfad310 Mon Sep 17 00:00:00 2001 From: Elliott Slaughter Date: Mon, 27 Jul 2026 16:42:56 -0700 Subject: [PATCH 7/7] Claude's fix to restore code coverage. --- .github/workflows/tests.yml | 31 ++++++++++++++++++++++++++++++- flake.nix | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 799e3069a9..a22b0f631e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,11 +43,40 @@ jobs: run: | proj check cpu-ci + - name: Generate code coverage + run: | + # A toolchain mismatch between the instrumentation and libgcov makes + # every test abort profiling without writing anything, which would + # otherwise surface as a silent 0% report rather than a failure. + gcda_count="$(find build/coverage -name '*.gcda' | wc -l)" + echo "found $gcda_count .gcda files" + if [ "$gcda_count" -eq 0 ]; then + echo "::error::no coverage data was produced by the test run" >&2 + exit 1 + fi + # lcov 2.x treats several classes of gcov disagreement as hard + # errors; gcc emits them routinely for templates, so downgrade them. + lcov_opts=( + --rc geninfo_unexecuted_blocks=1 + --ignore-errors "inconsistent,mismatch,unused,negative,source,empty" + -j "$(nproc)" + ) + lcov "${lcov_opts[@]}" --capture --directory build/coverage --output-file coverage-all.info + # Paths recorded by geninfo are absolute, so anchor on $PWD rather + # than a bare 'lib/*'. + lcov "${lcov_opts[@]}" --extract coverage-all.info "$PWD/lib/*" --output-file coverage-lib.info + lcov "${lcov_opts[@]}" --remove coverage-lib.info '*.dtg.h' '*.dtg.cc' --output-file main_coverage.info + lcov "${lcov_opts[@]}" --list main_coverage.info + - name: Upload code coverage uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} - file: main_coverage.info + files: main_coverage.info + # We hand codecov the one report we generated above; without these it + # searches the tree and runs its gcov plugin over the whole build. + disable_search: true + plugins: noop flags: unittests name: codecov-umbrella fail_ci_if_error: false diff --git a/flake.nix b/flake.nix index 341b5e1c8c..4dce6ac943 100644 --- a/flake.nix +++ b/flake.nix @@ -74,6 +74,42 @@ ci = mkShell { shellHook = '' export RC_PARAMS="max_discard_ratio=100" + + # Nix passes dependency include paths through NIX_CFLAGS_COMPILE + # rather than on the compiler command line, so ccache cannot see + # them change. Its manifests reference store paths that are still + # present and unmodified, so bumping a dependency (e.g. fmt) yields + # false cache hits that return objects built against the old + # headers. Folding the flags into the hash invalidates those. + # -frandom-seed is a per-derivation nonce, so it is dropped to keep + # unrelated devshell edits from invalidating the whole cache. + # The flags are reduced to a digest and combined with "%compiler% -v" + # so that the compiler's own identity keeps being hashed too -- + # setting a plain "string:" check would drop it, and a gcc bump that + # left the include paths untouched would then go unnoticed. + ccache_flag_id="$( + printf '%s' "$NIX_CFLAGS_COMPILE" \ + | tr ' ' '\n' \ + | grep -v '^-frandom-seed=' \ + | sha256sum \ + | cut -d' ' -f1 + )" + export CCACHE_COMPILERCHECK="%compiler% -v; echo $ccache_flag_id" + unset ccache_flag_id + + # cudaPackages.backendStdenv pins gcc to a version cuda accepts, + # but the wrapper still puts the default stdenv gcc's library + # directory ahead of it, so -lgcov resolves to a libgcov whose + # format does not match the instrumentation the pinned gcc emits. + # Every coverage run then dies with "Version mismatch" and writes + # no .gcda at all. This directory holds only static archives + # (libgcc, libgcov) and crt objects, so preferring it does not + # affect libstdc++ resolution. + gcc_static_lib_dir="$(dirname "$(''${CXX:-g++} -print-file-name=libgcov.a)")" + case "$gcc_static_lib_dir" in + /*) export NIX_CFLAGS_LINK="-L$gcc_static_lib_dir $NIX_CFLAGS_LINK" ;; + esac + unset gcc_static_lib_dir ''; buildInputs = builtins.concatLists [