Repository navigation
Add UDLF-CSR backend (CPRR and LHRR with sparse engines) - #12
Merged
Merged
Conversation
csr = UDLF(bin_path=..., backend="csr", threads=1)
res = csr.run("CPRR", ranked_lists=rks, params={"l": 1000}, classes=labels,
engine="sparse")
- runs CPRR and LHRR of UDLF-CSR with engine="dense" | "sparse" | "mkl" |
"blas" | "eigen" (or the UDLF-CSR names, e.g. "CPRR_SPARSE") and returns
the same Result as UDLF
- handles how UDLF-CSR differs from UDLF (checked in its sources and by
running it): every config variable is written (missing ones are left
uninitialized), errors are read from its output (it always exits with
0), it runs in a directory with the output/ folder it writes to, its
N x N matrix goes to /dev/null unless output="matrix", the classes file
is written in the order of the lists (it reads classes by line order),
and its log (percentages, two EFFECTIVENESS blocks) is parsed
- measures are computed by pyUDLF with the UDLF definitions, so UDLF and
UDLF-CSR results are comparable; UDLF-CSR's own are in raw_metrics
- Result.warnings: repeated elements in the ranked lists (sparse engines),
and runs repeated after UDLF-CSR's intermittent "Failed to open backing
file" startup error (dangling pointer in VirtualArray::create)
- UDLF(threads=...) sets OMP_NUM_THREADS: the dense engines are not
deterministic with several threads
- the binary type is detected, so a UDLF binary used as UDLF-CSR (or the
opposite) is reported instead of failing later
- scripts/build_csr.sh builds UDLF-CSR pinned to commit b391800 (dense and
sparse engines, or all with --full); CI builds it and runs the tests
- tests/test_csr.py compares each engine with UDLF-CSR run directly
(PYUDLF_CSR_ENGINES selects the engines to test); README and CHANGELOG
document the backend and the UDLF-CSR issues found
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The sparse engines rewrite only the first min(scored elements, L) positions of each ranked list (CprrSparse/LHRRSparse updateRankedLists; same pattern in LHRRMKL and CprrEigen). When a query has fewer scored elements than L, the remaining positions keep the previous ranking and repeat elements already placed. Verified: with L = 100 on the synthetic data, repetitions go from every list (k = 5) to none (k = 30). The warning now says why it happens and how to avoid it (larger k or smaller l); the CHANGELOG records the cause for the UDLF-CSR authors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- One CI job failed once on the push of feature/csr (Linux, Python 3.12,
"Run tests"), then passed with the same code on the pull request; 40
local runs of the suite had no failure. The only known intermittent
cause is UDLF-CSR's startup error ("Failed to open backing file",
dangling pointer in VirtualArray::create), measured at 1-5% of the runs
of every engine. The test suite runs UDLF-CSR about 60 times, so 3
attempts were not always enough. The run (which fails before any
computation) is now repeated up to 5 times, in pyUDLF and in the test
helper, through csr.RUN_ATTEMPTS.
- CI installs pytest-github-actions-annotate-failures, so a failing test
shows up as an annotation (on the pull request and in the API) instead
of only in the job log.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Adds support for UDLF-CSR, a rewrite of UDLF that runs CPRR and LHRR
with several engines (dense, sparse, MKL, BLAS, Eigen) to scale to large datasets. It uses the same API and
returns the same
Resultas UDLF, so switching between them is one line:What pyUDLF handles
UDLF-CSR behaves differently from UDLF in several ways (checked in its sources, commit
b391800, and by runningit). pyUDLF takes care of them:
output/folder it writes to, and sends its N×N matrix to/dev/nullunlessoutput="matrix";EFFECTIVENESSblocks);backend="csr"(or the opposite) gives a clear error.Measures are computed by pyUDLF with the UDLF definitions, so UDLF and UDLF-CSR results are directly comparable.
UDLF-CSR's own measures are kept in
Result.raw_metrics(its recall is averaged per query, not per class).New options
UDLF(backend="csr"),run(..., engine=...); UDLF-CSR names such as"CPRR_SPARSE"are also accepted.UDLF(threads=...)setsOMP_NUM_THREADS.Result.warnings: problems found in the results.scripts/build_csr.shbuilds UDLF-CSR pinned to commitb391800: the dense and sparse engines by default,all engines with
--full(needs MKL, GraphBLAS, Eigen)