Skip to content

Conversation

@cheese-head
Copy link
Contributor

What?

This PR adds support for custom backend parameters in the NIXL Rust bindings, enabling users to pass arbitrary key-value configuration parameters to NIXL backends.

Why?

This PR will allow from Rust to

  • Configure backend-specific options (e.g., UCX transport settings, GDS options)
  • Passing custom parameters for plugin initialization

How?

It exposes to APIs outside of the crate.

  • try_clone
  • from_iter

@copy-pr-bot
Copy link

copy-pr-bot bot commented Oct 14, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions
Copy link

👋 Hi cheese-head! Thank you for contributing to ai-dynamo/nixl.

Your PR reviewers will review your contribution then trigger the CI to test your changes.

🚀

@roiedanino
Copy link
Contributor

Hi @cheese-head,
Can you please resolve conflicts and clang-format issues?

Thanks!

@aranadive
Copy link
Contributor

/ok to test 66688a3

@aranadive
Copy link
Contributor

/build

Copy link
Contributor

@roiedanino roiedanino left a comment

Choose a reason for hiding this comment

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

Please make sure your PR only contains changes relevant to backend parameters, without formatting other parts of the code

…m-bindings

# Conflicts:
#	src/bindings/rust/src/lib.rs
Signed-off-by: Patrick Riel <[email protected]>
@cheese-head cheese-head force-pushed the cheese-head/rust-param-bindings branch from 66688a3 to d03d96a Compare November 12, 2025 21:09
Signed-off-by: Patrick Riel <[email protected]>
@cheese-head
Copy link
Contributor Author

@roiedanino @aranadive clang format changes have been reverted and fixed.

@aranadive
Copy link
Contributor

/ok to test 7d8c614

@aranadive
Copy link
Contributor

/build

///
/// let params = Params::try_from_iter(map.iter().map(|(k, v)| (*k, *v)))?;
/// ```
pub fn try_from_iter<I, K, V>(iter: I) -> Result<Self, NixlError>
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it would be better to call this function from just like in HashMap, following language convention

Copy link
Contributor Author

@cheese-head cheese-head Nov 13, 2025

Choose a reason for hiding this comment

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

Since it can produce an error, would it be better to implement TryFrom?

Copy link
Contributor

Choose a reason for hiding this comment

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

Most APIs can produce an error, that's what the Result<> return type is for; Result object forces the user code to handle errors.

/// let mut modified_params = original_params.try_clone()?;
/// modified_params.set("bucket", "my-custom-bucket")?;
/// ```
pub fn try_clone(&self) -> Result<Self, NixlError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can name it clone?

Comment on lines +233 to +234
let params = Params::try_from_iter(map.iter().map(|(k, v)| (*k, *v)))
.expect("Failed to create params from iterator");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
let params = Params::try_from_iter(map.iter().map(|(k, v)| (*k, *v)))
.expect("Failed to create params from iterator");
let params = Params::from(&map)
.expect("Failed to create params from iterator");

should work as well

}

#[test]
fn test_params_try_clone() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn test_params_try_clone() {
fn test_params_clone() {

Comment on lines +273 to +276
for param in copied_params.iter().unwrap() {
let param = param.unwrap();
copied_map.insert(param.key.to_string(), param.value.to_string());
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can do HashMap::from(copied_params) if Params iterator provides a key and a value?

}

#[test]
fn test_params_try_from_iter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
fn test_params_try_from_iter() {
fn test_params_from_iter() {

// SAFETY: If status is 0 and key_ptr is not null, both pointers are valid null-terminated strings
let result = unsafe {
let key = CStr::from_ptr(key_ptr).to_str().unwrap();
let value = CStr::from_ptr(value_ptr).to_str().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm refering to line 61 (Ok(ParamPair { key, value })) it could be nicer to just return Ok((key, value)) which will enable iterating for key, value:

    for (key, value) in params.iter() {
       ...
    }

It will also allow us to remove the ParamPair object, and use HashMap::from(params.iter())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you want the entire ParamPair object removed?

Copy link
Contributor

Choose a reason for hiding this comment

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

Why would we want that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants