Fix lwtnn schema validation and add FastSim scale factor example#343
Merged
Conversation
21c8eaa to
1c6a30b
Compare
nsmith-
reviewed
May 13, 2026
1c6a30b to
c29d233
Compare
pull Bot
pushed a commit
to tjni/correctionlib
that referenced
this pull request
Jun 12, 2026
* Add submodule lwtnn * Implement an LWTNN neural network node Draft implementation for comments Closes #35 * Fix gcc compiler error * Add PIC * Fix to windows-latest MSVC lwtnn linkage (cms-nanoAOD#334) * Fix correction config paths for editable installs * Link lwtnn-stat on MSVC builds * Added comment about editable configuration check and ran formatting * Match pre-commit import ordering in test_binding * updating spooky spaces that might be causing a problem? * Preserve correctionlib version variables across lwtnn subproject * updating version call * Update lwtnn submodule for MSVC warning flags * Point lwtnn submodule to fork for MSVC fix validation * Use upstream lwtnn submodule URL (cms-nanoAOD#340) * format * Fix lwtnn schema validation and add FastSim scale factor example (cms-nanoAOD#343) * Accept LWTNN nodes in schema validation * Simplify tests / examples --------- Co-authored-by: Nick Smith <nick.smith@cern.ch> * Check thread-safety, looks OK * Add better error message when lwtnn opaque blob fails to parse Wrap lwt::parse_json in a try/catch so malformed or missing fields in the 'opaque' blob produce a clear RuntimeError rather than an opaque boost exception. Add a test to cover the error path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Fix several bugs found in PR review C++ (lwtnn.cc): - Widen try/catch to cover full constructor, wrapping LightweightNeuralNetwork construction errors with a correctionlib-prefixed message - Reject string-typed correction inputs at construction time, consistent with all other numeric node types - Guard against empty outputs list in the lwtnn model Python (schemav2.py): - _validate_input: add empty-inputs guard, None-name guard, and finalizer variable cross-check against opaque outputs - _summarize: add explicit `used` flag to _SummaryInfo and set it in all branches (including new Formula and LWTNN cases); use it instead of the min/max sentinel to detect unused inputs - Factor _artifact_base_dir into util.artifact_base_dir and apply to both cli.py and binding.py so editable-install path resolution is consistent Partially Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * Add enough schema for LWTNN to make validation * Add compatibility break table to README Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Sam Bein <sbein@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <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.
This patch fixes schema validation for LWTNN correction nodes.
The C++/Python evaluator can already evaluate LWTNN nodes, but the Python schema traversal failed with:
RuntimeError: Unknown content node type: <class 'correctionlib.schemav2.LWTNN'>
The patch:
The FastSim example, which loads an example NN json payload and computes an electron scale factor, can be run with: