Skip to content

Fix to windows-latest MSVC lwtnn linkage #334

Merged
nsmith- merged 9 commits into
cms-nanoAOD:lwtnnfrom
sbein:debug-pr333-windows
Apr 16, 2026
Merged

Fix to windows-latest MSVC lwtnn linkage #334
nsmith- merged 9 commits into
cms-nanoAOD:lwtnnfrom
sbein:debug-pr333-windows

Conversation

@sbein

@sbein sbein commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

This PR is an attempt to build on, and if successful, be pulled into or supersede, @nsmith's draft:
#333

It links lwtnn-stat on MSVC builds, since

target_link_libraries(correctionlib PRIVATE lwtnn-stat)

was inside the non-MSVC branch in CMakeLists.txt, so may be skipped on Windows.

It also fixes correction-config paths for editable installs. Editable installs were showing include/cmake paths from the source tree instead of the installed artifact location, which broke test_cmake_static_compilation.

local checks:

  • pytest -q tests/test_binding.py -vv
  • pytest -q tests/test_lwtnn.py -vv

Comment thread src/correctionlib/cli.py
@sbein

sbein commented Apr 5, 2026

Copy link
Copy Markdown
Contributor Author

I think there is now a proposed solution, which involves all commits here except the final one. The last commit temporarily points the lwtnn submodule URL at my fork so CI can fetch the MSVC warning-flags fix for validation. Once the corresponding lwtnn PR is merged upstream, I plan to revert that .gitmodules change and update the submodule pointer to the upstream merged commit.

@nsmith- nsmith- left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CI error is extraneous (will look later)
For now I'll merge it into the main PR, thanks for the help!

Comment thread .gitmodules
[submodule "lwtnn"]
path = lwtnn
url = https://github.com/lwtnn/lwtnn.git
url = https://github.com/sbein/lwtnn.git

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might have noticed my patch is not in that repo either. Actually you can get a commit in any fork on github from the main repo.

@nsmith- nsmith- merged commit e9b6e2c into cms-nanoAOD:lwtnn Apr 16, 2026
18 of 19 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants