Skip to content

Separate concretization of build dependencies (coupled)#38447

Merged
tgamblin merged 44 commits intospack:developfrom
alalazo:solver/separate_concretization_together
Aug 15, 2023
Merged

Separate concretization of build dependencies (coupled)#38447
tgamblin merged 44 commits intospack:developfrom
alalazo:solver/separate_concretization_together

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Jun 16, 2023

closes #35739
closes #34889
closes #27835
closes #38587

⚠️ Attempt to get separate concretization of build dependencies by using a more complex ASP encoding ⚠️

Tasks

  • Mark all the rules that are associated with packages (1e8ff49)
  • Introduce node(ID, Package) nested facts, but still allow only for ID==0 (a87e2a7)
  • Add choice rules to allow clingo to generate nodes, and introduce "unification sets"
  • Allow different concretization modes for separate concretization
  • Allow multiple nodes per package
  • Make sure that conflicts refer to direct dependency or self only
  • Add a vendors directive for cases where a package conflicts with a random other because it exposes its own internal version of it

@spackbot-app spackbot-app bot added conflicts core PR affects Spack core functionality dependencies tests General test capability(ies) labels Jun 16, 2023
@alalazo alalazo force-pushed the solver/separate_concretization_together branch 2 times, most recently from da038b6 to 8669f3e Compare June 19, 2023 13:01
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 19, 2023

Comparing the transformation of the encoding to prepare for the introduction of separate concretization of build dependencies:

develop: 7dc485d
PR: 8669f3e

radiuss.8669f3e3f153de172329bc3394991b64f530665c.csv
radiuss.develop.csv
radiuss.txt

radiuss

Table details
Spec solved Total time [develop, secs.] Total time [PR, secs.] Speedup [%]
aluminum 17.5607 19.7323 -12.3665
ascent 36.1886 39.304 -8.60879
axom 34.9225 39.4993 -13.1058
blt 16.1301 18.0389 -11.8335
caliper 17.4336 20.0213 -14.8432
care 18.0698 21.0498 -16.4921
chai 17.3742 20.0581 -15.4472
conduit 17.8551 20.7511 -16.2189
dihydrogen 19.4309 21.2052 -9.13093
flux-core 17.9489 20.7459 -15.5829
flux-sched 20.5557 20.9913 -2.11928
flux-security 15.8155 19.1619 -21.1594
glvis 32.9164 40.886 -24.2118
hydrogen 17.4141 20.4855 -17.6374
hypre 18.8567 22.0955 -17.1758
lbann 34.8106 43.0737 -23.7372
lvarray 22.4491 25.1766 -12.1496
mfem 31.527 36.5541 -15.9453
py-hatchet 20.7295 27.4639 -32.487
py-maestrowf 17.9352 20.6887 -15.3526
py-merlin 18.8993 23.417 -23.9041
py-shroud 15.7452 18.3862 -16.7737
raja 16.5619 19.5622 -18.1154
samrai 16.1204 19.3522 -20.0475
scr 18.0463 21.1855 -17.395
sundials 27.277 32.502 -19.1554
umpire 16.1656 18.6915 -15.6253
visit 34.2725 44.3729 -29.4709
xbraid 16.4195 19.0473 -16.0039
zfp 15.7581 18.427 -16.9365

So far only a single node is allowed, and the runtime is expected further slow-downs as we introduce separate concretization of build dependencies.1

Benchmark done with:

  • Spack: 0.21.0.dev0 (8669f3e)
  • Python: 3.8.10
  • Platform: linux-ubuntu20.04-icelake
  • Concretizer: clingo

Footnotes

  1. Note, this new encoding hasn't been heavily optimized yet, so we might still speed it up by a few %

@alalazo alalazo force-pushed the solver/separate_concretization_together branch from 1fcd454 to d761d92 Compare June 21, 2023 18:38
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 21, 2023

This is a plot of the slow-down due to the more complex encoding in 9742a8e and 4285810 to map nodes to packages.

Both plots have been obtained allowing a single nodes per package, and they reflect the effect of the added complexity in the encoding.

develop: 4285810
PR: d761d92

radiuss.d761d926a82e8ed7a23c54d8ce608760da764f71.csv
radiuss.develop.csv
radiuss.txt

radiuss

Table details
Spec solved Total time [develop, secs.] Total time [PR, secs.] Speedup [%]
aluminum 16.7819 40.5285 -141.502
ascent 35.1049 86.5947 -146.674
axom 34.0034 82.5838 -142.869
blt 15.6801 26.2905 -67.6682
caliper 16.8628 40.4477 -139.863
care 18.0986 29.5529 -63.2886
chai 17.1099 32.3305 -88.958
conduit 17.8418 33.1957 -86.056
dihydrogen 18.1802 41.8569 -130.233
flux-core 17.4456 35.2627 -102.13
flux-sched 17.1557 44.0192 -156.586
flux-security 15.7154 19.9079 -26.6774
glvis 33.0898 60.752 -83.5972
hydrogen 17.2905 44.5871 -157.87
hypre 18.5722 59.2684 -219.125
lbann 35.1247 82.9198 -136.073
lvarray 22.7947 35.4677 -55.5963
mfem 31.6893 65.859 -107.827
py-hatchet 21.0032 52.8454 -151.607
py-maestrowf 17.6902 27.2252 -53.9002
py-merlin 19.3176 50.8648 -163.308
py-shroud 16.1795 24.5725 -51.8748
raja 16.3333 29.1512 -78.4773
samrai 16.0283 36.7549 -129.313
scr 18.1403 38.4019 -111.694
sundials 27.5532 68.381 -148.178
umpire 16.6091 27.3682 -64.7778
visit 34.2922 68.782 -100.576
xbraid 16.1758 49.976 -208.956
zfp 15.8366 25.6672 -62.0758

The encoding passed a first sanity check, i.e. it passes the unit tests under the same conditions of the previous encoding. Now we need to recover performance. Three possible step forward:

  1. Tune the heuristic for this new encoding
  2. Deduplicate conditions and impositions from the directives
  3. Reduce the number of "possible dependencies" in a build

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 23, 2023

Compared to #38447 (comment), this is the effect of the following optimizations:

  1. 10129b4 (remove the optimization on literals if we know we have to solve for all of them)
  2. 8499bc1 (deduplicate condition triggers and effects)
  3. fa060e5 (use cycle detection in ASP only as a fall-back)
  4. 8b845bd (reduce the number of unification sets)

As before, I am testing against develop under the same conditions, so I allow just one node per package.

develop: 4285810
PR: 8b845bd

radiuss.8b845bd4b157a0f03eb46313b98ef15977960417.csv
radiuss.txt
radiuss.develop.csv

radiuss

Table details
Spec solved Total time [develop, secs.] Total time [PR, secs.] Speedup [%]
aluminum 16.7819 16.585 1.17332
ascent 35.1049 47.5708 -35.5103
axom 34.0034 40.6636 -19.5869
blt 15.6801 14.3235 8.65187
caliper 16.8628 16.9906 -0.757584
care 18.0986 17.7029 2.18631
chai 17.1099 16.7097 2.33893
conduit 17.8418 17.506 1.88211
dihydrogen 18.1802 19.1285 -5.21596
flux-core 17.4456 15.1445 13.1902
flux-sched 17.1557 15.8922 7.36511
flux-security 15.7154 14.0325 10.7084
glvis 33.0898 39.1442 -18.2968
hydrogen 17.2905 17.8254 -3.09342
hypre 18.5722 18.8423 -1.45477
lbann 35.1247 40.7819 -16.1061
lvarray 22.7947 21.4851 5.74509
mfem 31.6893 40.8205 -28.8147
py-hatchet 21.0032 19.0041 9.5177
py-maestrowf 17.6902 16.3678 7.47527
py-merlin 19.3176 17.3405 10.2349
py-shroud 16.1795 14.9685 7.48437
raja 16.3333 15.5686 4.68189
samrai 16.0283 15.7052 2.016
scr 18.1403 17.2927 4.67249
sundials 27.5532 37.3038 -35.3884
umpire 16.6091 15.5887 6.14373
visit 34.2922 62.791 -83.1058
xbraid 16.1758 14.747 8.83266
zfp 15.8366 15.0807 4.77325

Notes

  • The optimizations done here also apply to develop, at least conceptually.
  • visit is still slower, because it falls back to using cycle detection - since the optimal solution without the integrity constraint has cycles1
  • Removing cycle detection is a huge win in solving time (now), and an enabler for grounding with multiple nodes

Footnotes

  1. In my opinion this is fine, since the issue can be worked around in either spec literals or in package defaults. Also, we can try to do a multi-solve later on as an optimization. Basically the idea is that we'll add a constraint on top of information that was already grounded, so we can just ground cycle detection and do a second solve.

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 28, 2023

Latest commit is a step towards getting full separation:

  • 6779636 allows each software tagged "build-tools " and used as a build dependency to have its own unification set. This keeps the number of unification sets low, but serves the purpose of separating over e.g. cmake, gamke, py-setuptools etc.
  • d340ba6 encodes a couple of rules differently, to enable enforcing different targets and / or compilers for specs in the "root" unification set vs. other unification sets

develop: 78f33bc
PR: d340ba6

radiuss.d340ba67cb3650a78b2f14fcab4f5c6bb89be244.csv
radiuss.develop.csv
radiuss.txt

radiuss

Table details
Spec solved Total time [develop, secs.] Total time [PR, secs.] Speedup [%]
aluminum 16.3646 16.3962 -0.193358
ascent 34.6264 45.9924 -32.8246
axom 33.1618 41.8434 -26.1795
blt 15.2374 15.0361 1.32114
caliper 16.4263 16.8609 -2.64528
care 17.7088 18.1668 -2.58636
chai 16.774 17.2125 -2.61438
conduit 17.3509 18.4839 -6.52994
dihydrogen 17.6146 18.8824 -7.19764
flux-core 16.7112 15.9129 4.77745
flux-sched 17.0186 16.3693 3.81521
flux-security 15.6706 14.1482 9.71494
glvis 32.2706 39.172 -21.3861
hydrogen 16.8953 17.442 -3.23545
hypre 18.4006 20.379 -10.7517
lbann 33.9559 41.896 -23.3838
lvarray 22.0815 22.0366 0.203414
mfem 30.562 40.4265 -32.2768
py-hatchet 20.717 18.8091 9.2092
py-maestrowf 17.1667 15.5794 9.24636
py-merlin 18.6637 18.1155 2.93725
py-shroud 15.6657 14.472 7.61973
raja 16.1789 16.0032 1.08627
samrai 15.7881 16.0464 -1.6363
scr 18.062 17.0265 5.73296
sundials 27.449 37.6311 -37.0946
umpire 15.8718 15.8215 0.317381
visit 33.6443 56.999 -69.4164
xbraid 16.1397 16.0133 0.783393
zfp 15.5562 14.5621 6.39015

@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 30, 2023

Adding these rules to a solve (by inserting them in display.lp):

attr("node_target_set", PackageNode, "x86_64_v4") :- unification_set("root", PackageNode), attr("node", PackageNode).
attr("node_target_set", PackageNode, "x86_64_v2") :- unification_set(SetID, PackageNode), attr("node", PackageNode), SetID != "root".
attr("node_compiler_version_set", PackageNode, "oneapi", "2023.1.0") :- unification_set("root", PackageNode), attr("node", PackageNode).
attr("node_compiler_version_set", PackageNode, "gcc", "9.4.0") :- unification_set(SetID, PackageNode), attr("node", PackageNode), SetID != "root".
:- provider(node(_, Package), node(_, "mpi")), Package != "openmpi".

and making the default dependency just link, I was able to get a "full separation" of build dependencies wrt link-run dependencies, and obtained the following DAG for trilinos:
trilinos

@alalazo alalazo marked this pull request as ready for review June 30, 2023 13:56
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jun 30, 2023

Latest results:

develop: 78f33bc
PR: 69371ae

radiuss.develop.csv
radiuss.69371aee145027cfbf07c8b4a3e0fa6e340c4fa5.csv
radiuss.txt

radiuss

Table details
Spec solved Total time [develop, secs.] Total time [PR, secs.] Speedup [%]
aluminum 16.3646 13.5913 16.9472
ascent 34.6264 35.1772 -1.59076
axom 33.1618 33.1865 -0.0745219
blt 15.2374 12.3033 19.256
caliper 16.4263 13.641 16.9563
care 17.7088 15.4588 12.7055
chai 16.774 13.8608 17.3673
conduit 17.3509 14.5047 16.4039
dihydrogen 17.6146 15.0503 14.5578
flux-core 16.7112 12.7888 23.4721
flux-sched 17.0186 13.1836 22.5345
flux-security 15.6706 12.1072 22.7397
glvis 32.2706 30.5924 5.20021
hydrogen 16.8953 14.2023 15.9395
hypre 18.4006 15.834 13.9485
lbann 33.9559 32.9092 3.0824
lvarray 22.0815 18.0809 18.1173
mfem 30.562 33.1487 -8.46383
py-hatchet 20.717 15.2254 26.5076
py-maestrowf 17.1667 13.5857 20.8602
py-merlin 18.6637 14.2717 23.5321
py-shroud 15.6657 12.4527 20.5102
raja 16.1789 13.1257 18.8713
samrai 15.7881 12.6943 19.5954
scr 18.062 13.7979 23.6078
sundials 27.449 27.1293 1.16484
umpire 15.8718 13.1134 17.3797
visit 33.6443 80.375 -138.896
xbraid 16.1397 13.1302 18.6468
zfp 15.5562 12.0939 22.257

@tgamblin @becker33 With the exception of visit, which takes twice as much as before due to cycle detection, many other specs are ~20% faster in this branch than on develop - when we allow a single node per package.

I am able to solve #38447 (comment) in a "fully separate way" in ~15 seconds by adding the 5 rules you see in the comment (to help looking for a solution). Grounding doesn't seem to be an issue anymore, as long as we select what we allow to fork with a finer granularity than what we tried before.

I think this PR is ready for a review, to merge concretize.lp in develop and have a common base for further changes in the model. There is still (a lot of?) space for further optimizations, but I would leave them for future PRs.

@alalazo alalazo force-pushed the solver/separate_concretization_together branch from 69371ae to 96748e0 Compare July 3, 2023 12:26
@spackbot-app spackbot-app bot added the stand-alone-tests Stand-alone (or smoke) tests for installed packages label Jul 3, 2023
@spack spack deleted a comment from spackbot-app bot Jul 3, 2023
@alalazo alalazo force-pushed the solver/separate_concretization_together branch 2 times, most recently from 965f5fc to 18ad6fe Compare July 4, 2023 10:10
@alalazo alalazo force-pushed the solver/separate_concretization_together branch from 18ad6fe to 31c67b8 Compare July 4, 2023 10:29
@alalazo alalazo force-pushed the solver/separate_concretization_together branch from c13c374 to 8a2efcf Compare August 15, 2023 07:20
If a possible provider is not used to satisfy a vdep,
then it's not a provider of that vdep.
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Aug 15, 2023

The latest commit c84df00 solves #38447 (comment) according to what we decided in DM.

Here's the build of openmpi in the e4s-oneapi stack: https://gitlab.spack.io/spack/spack/-/jobs/7985353

Comparing performance:

radiuss-8a2efcf.csv
radiuss-c84df00.csv
radiuss.txt

radiuss

The change in the concretizer didn't impact performance in the benchmark.

@alalazo alalazo requested a review from tgamblin August 15, 2023 16:13
@tgamblin tgamblin merged commit 9bb5cff into spack:develop Aug 15, 2023
@adamjstewart
Copy link
Copy Markdown
Member

Looks like there's a bug in how concretizer error messages are formatted:

Before

   1. Cannot select a single "version" for package "py-jupyter-packaging"

After

   1. Cannot select a single "version" for package "NodeArgument(id='0', pkg='py-jupyter-packaging')"

@adamjstewart
Copy link
Copy Markdown
Member

Also here:

==> Warning: using "NodeArgument(id='0', pkg='python')@3.7.17" which is a deprecated version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicts core PR affects Spack core functionality defaults dependencies directives extends gitlab Issues related to gitlab integration new-variant new-version python stand-alone-tests Stand-alone (or smoke) tests for installed packages tests General test capability(ies) update-package

Projects

Development

Successfully merging this pull request may close these issues.

Concretizer chooses build dep that doesn't satisfy all packages

4 participants