Skip to content

Commit 22891ca

Browse files
committed
feat: switch to media-nixl feature flag
Signed-off-by: Alexandre Milesi <milesial@users.noreply.github.com>
1 parent b23cdf6 commit 22891ca

File tree

11 files changed

+106
-177
lines changed

11 files changed

+106
-177
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/bindings/python/Cargo.lock

Lines changed: 2 additions & 108 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/llm/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ testing-etcd = []
2424
block-manager = ["dep:nixl-sys", "dep:cudarc", "dep:nix", "dep:aligned-vec"]
2525
cuda = ["dep:cudarc"]
2626
integration = ["dynamo-runtime/integration"]
27+
media-nixl = ["dep:nixl-sys", "dep:dynamo-memory"]
2728

2829
[[bench]]
2930
name = "tokenizer"
@@ -42,7 +43,7 @@ dynamo-runtime = { workspace = true }
4243
aho-corasick = "1.1"
4344
anyhow = { workspace = true }
4445
dynamo-async-openai = { workspace = true }
45-
dynamo-memory = { workspace = true }
46+
dynamo-memory = { workspace = true, optional = true }
4647
dynamo-parsers = { workspace = true }
4748
async-stream = { workspace = true }
4849
async-trait = { workspace = true }
@@ -97,7 +98,7 @@ dialoguer = { version = "0.11", default-features = false, features = [
9798

9899
# block_manager
99100
aligned-vec = { version = "0.6.4", optional = true }
100-
nixl-sys = { git = "https://github.com/ai-dynamo/nixl", rev = "00bac00", optional = true }
101+
nixl-sys = { version = "0.7", optional = true }
101102
cudarc = { workspace = true, optional = true }
102103
nix = { version = "0.26", optional = true }
103104

lib/llm/src/mocker/engine.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ impl AsyncEngine<SingleIn<PreprocessedRequest>, ManyOut<LLMEngineOutput>, Error>
228228
input: SingleIn<PreprocessedRequest>,
229229
) -> Result<ManyOut<LLMEngineOutput>, Error> {
230230
let (request, ctx) = input.into_parts();
231+
println!("request: {request:?}");
231232

232233
// Extract dp_rank from request field (defaults to 0 if not set)
233234
let dp_rank = request.dp_rank.unwrap_or(0);

lib/llm/src/preprocessor.rs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ use std::{collections::HashMap, pin::Pin, sync::Arc};
2727
use tracing;
2828

2929
use crate::model_card::{ModelDeploymentCard, ModelInfo};
30-
use crate::preprocessor::media::MediaLoader;
30+
#[cfg(feature = "media-nixl")]
31+
use crate::preprocessor::media::{MediaDecoder, MediaLoader, MediaFetcher};
3132
use crate::preprocessor::prompt::OAIChatLikeRequest;
3233
use crate::protocols::common::preprocessor::{
3334
MultimodalData, MultimodalDataMap, PreprocessedRequestBuilder,
@@ -114,6 +115,7 @@ pub struct OpenAIPreprocessor {
114115
/// Per-model runtime configuration propagated to response generator (e.g., reasoning/tool parser)
115116
runtime_config: crate::local_model::runtime_config::ModelRuntimeConfig,
116117
tool_call_parser: Option<String>,
118+
#[cfg(feature = "media-nixl")]
117119
media_loader: Option<MediaLoader>,
118120
}
119121

@@ -143,14 +145,16 @@ impl OpenAIPreprocessor {
143145

144146
// // Initialize runtime config from the ModelDeploymentCard
145147
let runtime_config = mdc.runtime_config.clone();
146-
let media_loader = None; // TODO: enable with decoder config from MDC
148+
#[cfg(feature = "media-nixl")]
149+
let media_loader = Some(MediaLoader::new(MediaDecoder::default(), MediaFetcher::default())?);
147150
Ok(Arc::new(Self {
148151
formatter,
149152
tokenizer,
150153
model_info,
151154
mdcsum,
152155
runtime_config,
153156
tool_call_parser,
157+
#[cfg(feature = "media-nixl")]
154158
media_loader,
155159
}))
156160
}
@@ -279,7 +283,8 @@ impl OpenAIPreprocessor {
279283
let messages = request.messages();
280284
let message_count = messages.len().unwrap_or(0);
281285
let mut media_map: MultimodalDataMap = HashMap::new();
282-
let mut fetch_tasks = Vec::new();
286+
#[cfg(feature = "media-nixl")]
287+
let mut fetch_tasks: Vec<(String, ChatCompletionRequestUserMessageContentPart)> = Vec::new();
283288

284289
for idx in 0..message_count {
285290
let msg = messages
@@ -312,19 +317,22 @@ impl OpenAIPreprocessor {
312317
_ => continue,
313318
};
314319

320+
#[cfg(feature = "media-nixl")]
315321
if self.media_loader.is_some() {
316322
fetch_tasks.push((type_str, content_part.clone()));
317-
} else {
318-
// No loader, just pass the URL through
319-
media_map
320-
.entry(type_str)
321-
.or_default()
322-
.push(MultimodalData::Url(url));
323+
continue;
323324
}
325+
326+
//Fallback: ust pass the URL through
327+
media_map
328+
.entry(type_str)
329+
.or_default()
330+
.push(MultimodalData::Url(url));
324331
}
325332
}
326333

327334
// Execute all fetch tasks
335+
#[cfg(feature = "media-nixl")]
328336
if !fetch_tasks.is_empty() {
329337
let loader = self.media_loader.as_ref().unwrap();
330338
let results = futures::future::join_all(

lib/llm/src/preprocessor/media.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ mod rdma;
99
pub use common::EncodedMediaData;
1010
pub use decoders::{Decoder, ImageDecoder, MediaDecoder};
1111
pub use loader::{MediaFetcher, MediaLoader};
12-
pub use rdma::{DecodedMediaData, RdmaMediaDataDescriptor, get_nixl_agent, get_nixl_metadata};
12+
13+
pub use rdma::{DecodedMediaData, RdmaMediaDataDescriptor};
14+
#[cfg(feature = "media-nixl")]
15+
pub use rdma::{get_nixl_agent, get_nixl_metadata};

0 commit comments

Comments
 (0)