Skip to content

Conversation

@carlory
Copy link
Contributor

@carlory carlory commented Oct 20, 2025

What type of PR is this?

fix: label count params should be c_int in the pub extern "C" fn init_unified_classifier_c

What this PR does / why we need it:

unified_classifier.go:
// C function declarations - Legacy low confidence functions
bool init_unified_classifier_c(const char* modernbert_path, const char* intent_head_path,
                               const char* pii_head_path, const char* security_head_path,
                               const char** intent_labels, int intent_labels_count,
                               const char** pii_labels, int pii_labels_count,
                               const char** security_labels, int security_labels_count,
                               bool use_cpu);

lib.rs:
/// Initialize unified classifier (called from Go)
#[no_mangle]
pub extern "C" fn init_unified_classifier_c(
    modernbert_path: *const c_char,
    intent_head_path: *const c_char,
    pii_head_path: *const c_char,
    security_head_path: *const c_char,
    intent_labels: *const *const c_char,
    intent_labels_count: usize,
    pii_labels: *const *const c_char,
    pii_labels_count: usize,
    security_labels: *const *const c_char,
    security_labels_count: usize,
    use_cpu: bool,
) -> bool {

DEBUG log:

DEBUG: security_labels ptr = 0x140000455d0, count = 4294967298

root cause:

4294967298 = 0x100000002 = 2^32 + 2
The Rust function signature uses usize (64 bits), but Go passes C.int (32 bits).

test with this patch:

(base) ➜  semantic-router git:(fix-unit-test) make build
==================> Running rust ============> ...
Building Rust library...
   Compiling candle-semantic-router v0.4.0 (/Users/kiki/workspace/semantic-router/candle-binding)
    Finished `release` profile [optimized] target(s) in 3.99s
==================> Running build-router ============> ...
# command-line-arguments
ld: warning: ignoring duplicate libraries: '-lcandle_semantic_router'
(base) ➜  semantic-router git:(fix-unit-test) src/semantic-router/pkg/utils/classification
(base) ➜  classification git:(fix-unit-test) go test -timeout 300s -count=1 --run ^TestUnifiedClassifier_Initialize$/^Initialization_attempt$ github.com/vllm-project/semantic-router/src/semantic-router/pkg/utils/classification
# github.com/vllm-project/semantic-router/src/semantic-router/pkg/utils/classification.test
ld: warning: ignoring duplicate libraries: '-lcandle_semantic_router'
ok  	github.com/vllm-project/semantic-router/src/semantic-router/pkg/utils/classification	0.836s

Which issue(s) this PR fixes:

Fixes #481

Release Notes: Yes/No

@netlify
Copy link

netlify bot commented Oct 20, 2025

Deploy Preview for vllm-semantic-router ready!

Name Link
🔨 Latest commit 113b1a0
🔍 Latest deploy log https://app.netlify.com/projects/vllm-semantic-router/deploys/68f5e4e4e11c140008470158
😎 Deploy Preview https://deploy-preview-482--vllm-semantic-router.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Oct 20, 2025

👥 vLLM Semantic Team Notification

The following members have been identified for the changed files in this PR and have been automatically assigned:

📁 candle-binding

Owners: @rootfs
Files changed:

  • candle-binding/src/lib.rs

vLLM

🎉 Thanks for your contributions!

This comment was automatically generated based on the OWNER files in the repository.

@rootfs
Copy link
Collaborator

rootfs commented Oct 20, 2025

@carlory we are trying to refactor the candle binding in #207

Can you create the PR against the feat-candle-refactoring branch? Thanks

@carlory
Copy link
Contributor Author

carlory commented Oct 21, 2025

@rootfs recreated #494
/close

@carlory carlory closed this Oct 21, 2025
@carlory carlory deleted the fix-unit-test branch October 21, 2025 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: TestUnifiedClassifier_Initialize always fails on macOS

2 participants