ADR 0106: Label files: io::write_labels and io::read_labels in LabelPropagation-CUDA’s bytes (AD13 D2)#
Status: Accepted (2026-11-11). The format is the author’s: AD13 (sheet D2), decided by the author on 2026-10-28 (GOVERNANCE.md’s approvals log, the row “The file formats of 0.4 (sheet D1-D2)”:
io::write_labelswrites the original’si %.6fbytes). The names are AD12’s (io::write_labelsandread_labels; the row “The new public names of 0.4”). The reader’s rules and the tests are accepted under delegation, technical scope only. M10b step 2 (the M10b acceptance criterion 6).Date: 2026-11-11
Deciders: S M Shovan (AD13 D2, AD12); the AI assistant, on the author’s behalf (the rest)
Context#
LabelPropagation-CUDA@a276a3a (O) writes its labels as dynlp_labels.txt with
writeLabelsToFile (src/utils.cu): per vertex i, one space, the label through its TextWriter’s
putFixed6 (std::to_chars(double(x), chars_format::fixed, 6)), \n. M10a reproduced it in an
internal writer (detail::write_dynlp_labels, ADR 0067) that the compat tool and the replays use;
the damped replays compare its bytes with O’s goldens.
Decision#
void io::write_labels(const std::string& path, array_view<const float> labels)in<dyng/io/result_io.hpp>: the bytes of O’s writer (dynG’stext_writer::put_fixed6is O’sputFixed6), vertices 0 .. n-1 in order, the parent directory created, host memory required (invalid_argument_error),io_erroron a write failure.to_chars(double, fixed, 6)is correctly rounded with ties to even, the bytes ofprintf("%.6f")(00.000000, 11.000000, 0.50.500000, the exact tie 0.00781250.007812); a non-finite label is written as to_chars writes it.std::vector<float> io::read_labels(const std::string& path, std::int64_t num_vertices): the reader shape ofread_distances(every vertex exactly once in any order, a fast pass and a strict pass that reports the first problem with its line and column), the label a decimal token read bystd::from_chars<float>(alsonan/inf, which the writer produces for non-finite labels), outside the float range refused. A label reads back within 5e-7 plus half a float ulp of the written float; the file, not the float, is the exchange format.There is one implementation: the internal
detail::write_dynlp_labelsforwards toio::write_labels, anddyng-compat-dynlpwritesdynlp_labels.txtandirlp_labels.txtwith it (keeping O’s console message when the file cannot be opened). The compat tool’s outputs are therefore unchanged by construction; the damped replays (byte parity ofdynlp_labels.txton P) check it against O’s goldens.
Consequences#
Labels.WriteLabelsIsPrintfFixed6ByteForBytechecks 0, 1, 0.5, every k/128 tie and its neighbours and 2,000 random labels againstprintf("%.6f"); the damped replays check O’s bytes.fuzz_result_ioreads label files and checks the write-read round trip within that bound.Python’s
dyng.io.write_labels/read_labelsand the CLI’s label output (M10b step 3) use these functions.
Alternatives considered#
Shortest round-trip output (the float’s bits back exactly). Rejected by AD13 D2: the file is for comparison with the original’s, byte for byte.