-
Notifications
You must be signed in to change notification settings - Fork 226
feat(c-api): add cuOptSetLogCallback #1636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
3756aaf
feat(c-api): add cuOptSetLogCallback and cuOptSetLogLevel
ramakrishnap-nv a1ce114
fix/test(c-api): fix log callback race condition and add tests
ramakrishnap-nv adc2f81
refactor(c-api): drop cuOptSetLogLevel, control log level via env var
ramakrishnap-nv dc14e3b
feat(c-api): drop the log level from the callback, deliver standard o…
ramakrishnap-nv ade6670
Merge remote-tracking branch 'origin/main' into wip/c-log-callback
ramakrishnap-nv 351decb
fix(c-api): consume the pending log callback exactly once
ramakrishnap-nv 6562dda
fix(c-api): make log callback registration per-thread
ramakrishnap-nv 46249e7
Merge branch 'main' into feat/c-log-callback
ramakrishnap-nv 85cb36d
Merge branch 'main' into feat/c-log-callback
ramakrishnap-nv 30632ca
fix(c-api): deliver the log callback for remote solves
ramakrishnap-nv 8831f1a
Merge remote-tracking branch 'origin/feat/c-log-callback' into wip/c-…
ramakrishnap-nv 31e6c10
test(c-api): cover log callback delivery for remote solves
ramakrishnap-nv 205512b
Merge remote-tracking branch 'origin/main' into HEAD
ramakrishnap-nv 29c7e2a
Merge remote-tracking branch 'origin/main' into HEAD
ramakrishnap-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How this handled with GRPC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch — it wasn't, and it is now (30632ca).
With
CUOPT_REMOTE_HOST/CUOPT_REMOTE_PORTset,cuOptSolvedispatches throughsolve_lp_remote/solve_mip_remote, and the callback saw almost nothing. Two reasons:std::coutand the log file, bypassingdefault_logger()and therefore the callback sink.config.stream_logswas only enabled whenlog_to_consoleorlog_filewas set, so a registered callback alone did not even request streaming.Both remote paths now forward each streamed line to the user callback, and request streaming when a callback is present. The registration is captured at call time rather than read inside the lambda, because
grpc_client_tinvokeslog_callbackfrom its ownlog_thread_, which carries no thread-local registration (registration is per-thread as of 6562dda, so concurrent solves cannot capture each other's callback).Verified against a live
cuopt_grpc_serverwith a small C probe — the same LP delivers the same number of callback lines either way:and the remote lines are the server's own solver log (
Using PSLP presolver,PSLP Presolved problem: ...,Status: Optimal), cross-checked against the server-side log.One behavioural note now documented in the header: the callback runs on the calling thread for a local solve, and on the log-streaming thread for a remote one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow-up: this is now covered by a test as well (31e6c10).
CpuOnlyWithServerTest.log_callback_remotereuses the existing fixture that forks a realcuopt_grpc_serverand pointsCUOPT_REMOTE_HOST/PORTat it.Worth noting why the assertion is what it is: the client emits its own
Using remote GPU backendline locally, so a bare "callback fired at least once" check passes even when no server output is forwarded at all. The test therefore asserts that a line from the server's solver log arrives. Reverting the forwarding insolve_remote.cppmakes it fail with: