ADR 0109: The label_propagation API review and freeze (0.4), and per-algorithm kernel groups#
Status: Accepted (M10b, step docs-api-review-freeze-final-reads). Part A carries out the author’s decisions AD15 (sheet F1: everything new of M10 is frozen at the end of M10b and becomes
stableat 0.4.0 only on the author’s confirmation at the release) and AD12 (sheet E1: the new public names), both decided by the author on 2026-10-28 (GOVERNANCE.md, approvals log, P040’s rows “The 0.4.0 plan …” and “The new public names of 0.4 (AD12, HD8, HD12; sheet E1)”), by the method of ADRs 0023, 0047 and 0060 and the checklistdocs/developer/api_review_checklist.md. Pending the author: the stability confirmation at 0.4.0 (AD15), in GOVERNANCE.md’s open decisions, M10 (AD). Every public name beyond AD12’s list (section “The new public names”; the author’s decision of 2026-10-29 that M10b’s API ADR lists them for approval at the freeze) was approved by the author on 2026-11-12 (GOVERNANCE.md, approvals log, the row “M10’s public names beyond AD12’s list”): frozen with the API, a rename is an api-change. Part B carries out the author’s decisions of 2026-11-03 and 2026-11-05 (the rows “The D14-path excursions of M10a step 5” and “The cycle_count module-loading excursions of the merged library”); its mechanism is a technical choice under delegation. Neither part changes a rule the author approved: the stability policy of PLAN 5.9, the gates and their protocol (AD2’sCUDA_MODULE_LOADING=EAGERon both sides included), the parity rules and the frozen headers (additive changes only) are untouched.Decided: the author confirmed on 2026-11-18 (GOVERNANCE.md, approvals log, the row “AD15 and HD17: the stability of 0.4’s surfaces”; carried out in R040, ADR 0110 part A) that label_propagation (
<dyng/label_propagation.hpp>,dyng.label_propagationanddyng label_propagation), the graph additions of M10, the vertex-arrival generators,io::write_labels/read_labelsand AD13’s format extensions with the label files arestablefrom 0.4.0, and that the three testing oraclestesting::harmonic_solution,union_findandlp_host_modelstay frozen outside the stable tier (withdyng.testing’sharmonic_solution/HarmonicResult, confirmed on 2026-11-21); the reservation above is closed.Date: 2026-11-12
Deciders: the AI assistant, on the author’s behalf (M10b, step 4); the names beyond AD12: S M Shovan (approved 2026-11-12); the stability: S M Shovan (2026-11-18, at the release)
Builds on: ADR 0023 (the method, the snapshot), ADR 0035 (the freeze enforced against the base branch), ADR 0047 (the freeze’s Doxygen rules), ADR 0060 (the last algorithm freeze), ADRs 0063-0079 and 0100-0108 (label_propagation, its container additions, formats, Python and command line).
One ADR for two subjects: M10’s numbers are 0063-0079 and 0100-0109 (the reconciliation of 2026-10-27); 0109 is the last, so the review (part A) and the kernel groups (part B) share it, as ADR 0108 shares three subjects.
Part A: the API review and freeze#
Context#
label_propagation arrived in M10a (ADRs 0069-0079) at maturity experimental, its header tracked
by the API baseline; M10b added the operators engine (ADRs 0101, 0102), slack rows and the
streaming threshold (0103, 0104), the formats and the label files (0105, 0106), the library
generator (0107), Python, the command line and the kNN recipe (0108). AD15 freezes all of it at
the end of M10b, and makes it stable at 0.4.0 only on the author’s confirmation, so from the
merge of M10b a change is an api-change (a CHANGELOG entry; a breaking one needs the label too),
and the manifest says experimental until the author confirms, as triad_count’s did before 0.3.0
was confirmed.
Reviewed: every public entity of <dyng/label_propagation.hpp> (schedule, on_limit,
options, stats, result, compute(), update(), and the detail contract the baseline
lists: label_propagation_supported_v, update_traits<label_propagation::result>,
DYNG_LABEL_PROPAGATION_TYPES_MESSAGE); the graph additions (graph::with_capacity,
row_layout::slotted and slack, vertex_status, graph_view::status and row_end,
graph::num_active_vertices, batch_semantics::net_effect() and as_net_effect,
edge_batch::insert_vertex / delete_vertex and their read-back, apply_summary’s
dropped_insertions, relocated_rows, compactions, the float graph instantiations); the
generators (<dyng/generators/vertex_arrival.hpp>); the dyng::testing names
(harmonic_solution.hpp, union_find.hpp, lp_host_model.hpp); io::write_labels /
read_labels and the format tokens (.dgt +v / -v and float weights, .dgb
batch_dtype::float32 and batch_file_flags::vertex_records); Python (dyng.label_propagation
and the graph, batch, generator, testing and I/O additions of ADR 0108); the command line
(dyng label_propagation, dyng generate vertex_arrival_stream / dynlp_vertex_arrival_stream);
dyng-compat-dynlp’s argv; docs/design/sketches/label_propagation.md and its open questions.
Findings and what was done#
# |
Area |
Finding |
Resolution |
|---|---|---|---|
1 |
Naming |
The names follow ADR 0004 (clang-tidy’s naming rules pass); they are AD12’s, with E1’s changes ( |
none needed |
2 |
The verb vocabulary |
|
none needed |
3 |
Contract uniformity |
The skeleton of ADR 0006: an aggregate |
Accepted |
4 |
|
The header states AD20’s per-field levels ( |
none needed |
5 |
Doxygen |
Every entity is documented; |
|
6 |
Exceptions |
The entry points translate a host |
none needed |
7 |
Host-compilability |
|
none needed |
8 |
Ownership, ABI, limits |
|
Accepted |
9 |
The sketch’s open questions |
(1) |
Answered; the sketch is marked frozen |
10 |
The graph additions |
All additive ( |
No change in 0.4; a vertex-capacity reserve is listed for a later release (consequences) |
11 |
The stable algorithms on slotted and slack graphs |
|
none needed |
12 |
Generators and testing |
|
Frozen with the algorithm (decision 2) |
13 |
io and the formats |
|
Frozen by this ADR as names and bytes; enforced by the format tests (round trips, the 0.3 reader’s refusals, the label bytes against O’s goldens) |
14 |
Python |
|
Frozen (decision 3) |
15 |
Command line |
`dyng label_propagation compute |
update |
16 |
|
The original’s argv unchanged (a negative |
Reviewed; the diagnostic flags are listed with the names beyond AD12 |
17 |
Maturity |
The manifest stays |
Decision 4 |
Decision#
The label_propagation API is frozen as reviewed: every declaration of
<dyng/label_propagation.hpp>(its baseline section, thedetailcontract included), the Python names ofdyng.label_propagation, and the flags and output formats ofdyng label_propagationand of the two vertex-arrival generators ofdyng generate. No signature changed in the review, so the freeze needs no migration note.The baselines.
ci/api_snapshot.pygainsFROZEN_BEFORE_STABLE: the headers frozen at the end of their milestone while their algorithm’s maturity stays below stable,dyng/label_propagation.hppand the headers only it adds (dyng/generators/vertex_arrival.hpp,dyng/testing/harmonic_solution.hpp,union_find.hpp,lp_host_model.hpp). The baselinecpp/tests/api/api_snapshot/public_api.txtlists their sections asfrozen(ci/docs.sh --update-api); a removed or changed declaration failsci/docs.sh(against the baseline) andci/api_check.sh(against the base branch) without theapi-changelabel and a CHANGELOG entry. The Python half is griffe against the base branch (ci/api_check.sh), from the merge of M10b; the tests below pin the rule now. The graph additions are ingraph/*, frozen since 0.1: they are checked as additions already.Both checks fail on a deliberate change (the outcome below), and the tests keep it:
ci/tests/test_api_snapshot.py::test_the_label_propagation_headers_are_frozen_and_a_change_is_breaking(a changed default ofoptions::tolerance, a removedstats::initial_frontierand a changed default ofvertex_arrival_options::num_batchesare breaking changes of their sections; the manifest is not stable);ci/tests/test_api_check.py(a renamed parameter ofdyng.label_propagation.update, a changed default ofOptions.toleranceand a removedResult.labelsare breaking for griffe);python/tests/test_label_propagation_cli.py:: test_the_frozen_flags_are_kept(the command line).Maturity.
experimentaluntil the author confirmsstableat 0.4.0 (AD15; GOVERNANCE.md, open decisions, M10 (AD), with everything the confirmation covers). On confirmation the manifest saysstable,stable_algorithm_headers()lists the header as well, and nothing else changes.The sketch
docs/design/sketches/label_propagation.mdis marked frozen, with its questions answered (finding 9) and the header as the authority where they differ.
Outcome#
The deliberate changes (a throwaway clone of this branch at the freeze commit, reverted and
deleted; the logs in $DYNG_SCRATCH/runs/m10b-docs-api-review-freeze-final-reads/demo-*.log):
recorded in parity/results/M10b.md section 4 (the C++ default of options::tolerance changed:
ci/docs.sh --doxygen-only fails against the baseline, and with the baseline regenerated
ci/api_check.sh fails against the base; the Python default of Options.tolerance changed:
ci/api_check.sh fails; reverted: both pass).
Amendments after M10b’s review (2026-11-14)#
Finding 5 / 6 (exceptions). The header’s
@throwswere incomplete next to the sibling headers:compute(),update(),clone()andreserve()now documentcuda_error(cuda backend) and device memory inout_of_memory_error, andcompute()/update()the refusal ofengine::operatorswithschedule::in_placeon cuda (whichset_options()accepts and the next update refuses);dyng.label_propagation’sRaisessay the same, withupdate()’sConvergenceErrorandCapacityErroron cuda (the graph updated and poisoned, asgraph::apply()documents). Documentation only: the baselines are unchanged.Finding 13 (io and the formats). “Enforced by the format tests” held for the bytes, not for the declarations: a new defaulted parameter of
write_labelsor another value ofvertex_recordspassed every check.ci/api_snapshot.pygainsFROZEN_DECLARATIONS: inside the tracked io headers,io::write_labels,read_labels,batch_dtype::float32 = 3(the enumeration may gain enumerators after it),batch_file_flags::vertex_records = 16Uandknown_graph(withvertex_records) are frozen by declaration: once the base has them, a changed line is a breaking change (ci/tests/test_api_snapshot.py); the format test pins bit 4 with a literal.Finding 15 (command line). The freeze test pinned the flags’ names only; it now pins each frozen flag’s choices (a choice may be added), argparse default and required-ness, and the generators’ flag lists its choices, spelled
--edge-type(the author’s decision of 2026-11-14).Finding 16 and the names. The delta above.
Part B: kernel groups#
Context#
Every .cu file registers its fat binary with the CUDA runtime from a static constructor, so
loading libdyng registers every module of the library, and under CUDA_MODULE_LOADING=EAGER (the
protocol of every gate, AD2) the context creation of every CUDA process loads every kernel of the
library. M10a measured the cost (parity/results/M10a-merged/context-probe.json): the merged
library’s context 8.6 ms later than the 0.3 library’s, 4.8 ms of it label_propagation’s kernels and
3.8 ms those M11a added; it put sssp’s CUDA end_to_end (roadNet-PA unsafe50k, 1.021) and two
cycle_count CUDA regions (DD_k4 1.022 / 1.024) above ADR 0024’s bar. The author decided that
M10b loads each algorithm’s kernels only when that algorithm runs, every algorithm’s (M11a’s
included), and reads those regions again (2026-11-03, widened 2026-11-05).
Options considered#
One shared object per algorithm,
dlopened on first use. Every algorithm’s host boundary (the templates its host code calls in its.cufiles) would need a function table and trampolines; static builds (the wheels) could not do it; and M11’shyper_sssp, whose boundary M11b is changing, would need edits in its files. Rejected.Launches through
cudaLibraryLoadData/cudaLibraryGetKernel. Every<<<...>>>, every CUB and Thrust call would change. Rejected.Deferred registration (chosen). The registration calls are the only thing that makes a module eager. Renaming them in the group’s objects, recording them, and replaying them on first use changes nothing else: not the device code, not the host code, not the kernels’ bindings.
Decision#
A kernel group per algorithm, and one for the hypergraph containers.
dyng_add_algorithm()makes every algorithm’s CUDA sources a group named after the algorithm (no algorithm’s own files change, M11’shyper_ssspincluded);dyng_add_module(KERNEL_GROUP hypergraph)makes the hypergraph module’s (the ESCHER store,slack_csr, the line graph: only hypergraph algorithms use them). The core,utilandgraphmodules (the containers every graph algorithm uses) stay registered at load.The mechanism (
cmake/kernel_groups.cmake,cmake/kernel_group_launcher.sh,cmake/kernel_group.cpp.in,cpp/src/core/kernel_groups.{hpp,cpp}): the group’sCUDA_COMPILER_LAUNCHERcompiles each.cufile as before, then renames in the object (objcopy--redefine-syms)__cudaRegisterFatBinary,__cudaRegisterFatBinaryEnd,__cudaUnregisterFatBinary,__cudaRegisterFunction,__cudaRegisterVar,__cudaRegisterManagedVar,__cudaInitModuleand the runtime functions that take a kernel or a device symbol (__cudaGetKernel, which a launch calls once per site,cudaFuncGetAttributes,cudaFuncSetAttribute,cudaFuncSetCacheConfig,cudaLaunchKernel,cudaLaunchCooperativeKernel,cudaLaunchKernelExC, the occupancy queries, the symbol functions,cudaGetFuncBySymbol) to functions of a generated translation unit of the group, and refuses (nm) an object that still calls such a function unrenamed, so a new use cannot slip past the group. The group records the registrations at load time; the first renamed call (the safety net: a group can never be used unloaded),kernel_groups::load()or a warm-up replays them, creates the context if there is none (cudaFree(nullptr)) and asks for every recorded kernel’s attributes (cudaFuncGetAttributes), which loads it, so that the modules are created there, not inside the next (timed) call: the runtime loads the kernels of a fat binary registered after the context exists at their first use, even underCUDA_MODULE_LOADING=EAGER(a kernel without an image for the device is skipped and its error cleared). The first version of this step made only thecudaFree(nullptr)call; the final re-read found the cost in label_propagation’s first timed update (section “Consequences”). Redirection of another group’s copies (the resumed step, after the merge of M11b): the linker keeps one copy of an inline function or template that several groups’ objects define (CUB’s and Thrust’s dispatch functions instantiated with the same arguments, such ascub::DeviceScan::ExclusiveSum<int*, int*, int>), and a template kernel’s host function is local to its translation unit, so one group’s code can run another group’s copy, which launches that group’s own kernel. A renamed call that hands the runtime a kernel of a group that is not loaded therefore first looks the kernel up by its device name among the loaded groups’ kernels (the same template instantiation, the same device code); if one is found, the call goes to it and the group stays unloaded (kernel_group::ensure_for(), the redirection remembered per kernel); otherwise the group is loaded as before. Calls with a device symbol (no redirection) load the group. Thread-safe; the groups are never destroyed (the runtime’satexitunregistration may run after the static destructors). It works the same in shared and static builds (the wheels).Warm-ups.
resources::warm_up()keeps its frozen contract (“loads every kernel of the library”): it loads every group first.detail::warm_up_kernel_groups(res, {names})warms up the kernels outside every group and those of the named groups only; the compatibility tools (dyng-compat-mosp: sssp, mosp;dyng-compat-cycle-enum: cycle_count;dyng-compat-escher run: triad_count, hypergraph) use it, so their start-up still loads every kernel they run before any timed region (the originals’ eager loading) and nothing else.dyng-compat-hsosp(M11’s) is unchanged: it still loads everything. label_propagation loads its own group atcompute()and before an update’s first CUDA work (its compat tool uses public headers only), so the published flow pays for its modules in the untimedcompute().DYNG_DEFER_KERNEL_GROUPS(CMake option, default ON) turns the mechanism off: every module is registered at load, as before 0.4. Builds without CUDA have no group. Amended after M10b’s review: a CUDA 12 build with the static runtime (thedyng-cu12plugin wheel) turns it off (CMakeLists.txt, with a configure message): that runtime cannot use a fat binary registered after the device’s context exists (every call that names one of its kernels fails withcudaErrorInvalidResourceHandle; the cu12 plugin of step 4 failed its install smoke onsssp.compute). A two-file reproduction (a kernel, its registration renamed and replayed aftercudaFree(nullptr)) fails under CUDA 12.9’s static runtime and passes under 12.9’s shared runtime and under both runtimes of 13.1;__cudaInitModuleafter the replay does not help. The cu13 plugin, the shared-runtime builds and every gate keep the groups;ci/gpu_local.sh’s plugin step builds and tests the cu12 plugin too when a CUDA 12 toolkit is at hand.Tests.
dyng_kernel_groups_tests(each test a process of its own under CTest): every algorithm with CUDA kernels and the hypergraph containers have a group; creating a context loads none;load()loads only the named groups; the firstsssp::compute()loads sssp’s group and no other;warm_up()loads every group and every registered kernel; the narrow warm-up leaves the others unloaded; the registered kernels carry their group. Every other GPU suite exercises the safety net (no test loads a group explicitly).
Consequences#
A CUDA process loads the kernels of the core and the graph container, then each algorithm’s on its first use: a label_propagation process no longer loads cycle_count’s 6 MB of fat binaries or the hypergraph containers’, and an sssp process none of label_propagation’s or M11’s. The re-read regions and the context probe are
parity/results/M10b.mdsection 4.The first version’s miss (M10b step 4’s final re-read). With only
cudaFree(nullptr)after the replay, the runtime created label_propagation’s modules at their first launch: in the published flow, inside the first timed update (update[b0]0.31 ms on M10a’s library, 7.9 ms onb359d20’s at 50k, 8.0 ms at 500k; the gate’supdate[sum]1.077 at 50k, above 1.05, and ADR 0024’s LP slotted path 1.072). Loading every kernel of the group inensure()moves the cost back out of the timed region (parity/results/M10b.mdsection 4); a test checks that every registered kernel of a loaded group is loaded (cuFuncIsLoaded).The second miss (the resumed step 4, on the merged library). With every kernel of the group loaded, label_propagation’s first update still read
update[b0]8.05 ms against 0.31 ms (ADR 0024’s LP slotted path 1.073 at 50k,parity/results/M10b.mdsection 4): a debug run showed the hypergraph group loaded inside batch 0 (16 translation units, 152 kernels), and a breakpoint on its renamed__cudaGetKernelshowed the path:lp_cuda::launch_connected_components->cub::DeviceScan::ExclusiveSum<int*, int*, int>, the hypergraph module’s copy, which the linker had kept -> its ownDeviceScanInitKernelstub. The redirection of decision 2 fixes it; the testKernelGroups.LabelPropagationLoadsItsGroupOnlyruns the published flow on CUDA and checks that no other group is loaded (it failed before the fix). The compatibility tools were checked the same way (debug log of the groups each one loads; section 4).Under lazy module loading (the CUDA 12.2+ default outside the gates) nothing changes for users but the moment a group’s kernels load: all of them at the group’s first use.
A new runtime entry point that takes a kernel or a device symbol must be added to
DYNG_KERNEL_GROUP_SYMBOLSand the template; the launcher’s check fails the build until it is.For M11 (the integrator):
dyng-compat-hsospmay use the narrow warm-up as the other tools do (itsend_to_endwould then load hyper_sssp’s, sssp’s and the hypergraph containers’ groups only); M11’s mutant copies of the hypergraph module register at load, as every mutant copy does. M10b, the integrator after M11b’s merge, kept the tool’s fullresources::warm_up(): it loads every kernel before any timed region, which is what M11b’s readings measured, and a change of the tool would have been a change of M11’s frozen tool after its readings.Later, outside 0.4: a vertex-capacity
graph::reserve()(finding 10), for the author.