Files
leleka/crates/cuda-driver/src/api/async_api.rs
T
Pavlo RatushnyiandClaude Sonnet 5.5 2e8bd2040a refill: batched lent-slot refill copies behind LELEKA_REFILL_BATCH (experimental, off)
- cuda-driver: optional cuMemcpyBatchAsync_v2 + cuStreamWaitEvent in AsyncApi (api/enabled/batch_copy.rs,
  stub answers can_batch() == false); pure call plan refill_batch_copy::plan_batch_calls (<= 512 copies per
  call, same order/bytes/destinations) and issue_copies with per-copy fallback after a refusal.
- OriginalExpertCache::fill_slots_queued_batched: same checks, pieces and order as fill_slot_queued_on, one
  context entry; batch on the fill stream ordered after the legacy default stream by fill_event; registered
  bank only; a refused call is reported once and the rest goes per copy; driver errors poison as before.
- engine: settings memory.refill_batch (LELEKA_REFILL_BATCH on|1) and refill_lent's batched branch;
  profile counters refill.batch_calls / refill.batch_copies / refill.per_copy.
- tests: host-side plan tests; #[ignore] GPU test comparing per-copy vs batched slot bytes.
- docs/experiments/refill-batch-copy.md. No GPU run, no speedup claimed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-10 20:49:32 +01:00

130 lines
4.3 KiB
Rust

//! Moved out of the parent module by STRA-338: impl AsyncApi, impl MappedApi, fn page_size.
#[allow(unused_imports)]
use super::*;
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
impl AsyncApi {
pub(crate) fn load() -> Result<Self> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn create_stream(&self) -> Result<Stream> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn create_event(&self) -> Result<Event> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn register(&self, _: &mut [u8]) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn unregister(&self, _: &mut [u8]) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn copy(&self, _: u64, _: &[u8], stream: Stream) -> Result<()> {
let _ = stream.0;
Err(Error::UnsupportedPlatform)
}
pub(crate) fn synchronize_stream(&self, _: Stream) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn zero(&self, _: u64, _: usize) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn record(&self, event: Event, stream: Stream) -> Result<()> {
let _ = (event.0, stream.0);
Err(Error::UnsupportedPlatform)
}
pub(crate) fn query(&self, event: Event) -> Result<bool> {
let _ = event.0;
Err(Error::UnsupportedPlatform)
}
pub(crate) fn wait(&self, event: Event) -> Result<()> {
let _ = event.0;
Err(Error::UnsupportedPlatform)
}
pub(crate) fn destroy_event(&self, event: Event) -> Result<()> {
let _ = event.0;
Err(Error::UnsupportedPlatform)
}
pub(crate) fn destroy_stream(&self, stream: Stream) -> Result<()> {
let _ = stream.0;
Err(Error::UnsupportedPlatform)
}
pub(crate) fn can_batch(&self) -> bool {
false
}
pub(crate) fn copy_batch(&self, _: &mut crate::refill_batch_copy::BatchCall, _: Stream) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn wait_event(&self, _: Stream, _: Event) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
}
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
impl MappedApi {
pub(crate) fn load() -> Result<Self> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn register_bank(&self, _: &[u8]) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn bank_alias(&self, _: &[u8]) -> Result<u64> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn unregister_bank(&self, _: &[u8]) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn register_read_only(&self, _: usize, _: usize) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn unregister_at(&self, _: usize) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn register_staging(&self, _: usize, _: usize) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn copy_kernel(&self, _: &mut MappedCopyArguments, _: Stream) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn stream(&self) -> Result<Stream> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn event(&self) -> Result<Event> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn record(&self, _: Event, _: Stream) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn query(&self, _: Event) -> Result<bool> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn wait(&self, _: Event) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn destroy_event(&self, _: Event) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn destroy_stream(&self, _: Stream) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
pub(crate) fn close(&mut self) -> Result<()> {
Err(Error::UnsupportedPlatform)
}
}
#[cfg(not(all(
feature = "cuda-driver",
any(target_os = "linux", target_os = "windows"),
target_pointer_width = "64"
)))]
pub(crate) fn page_size() -> Result<usize> {
Err(Error::UnsupportedPlatform)
}