diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 00d120b..3a12aff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -62,8 +62,9 @@ to see them all. Current ERROR rules: `thaw`. Write `import thaw`. (This one cost real fresh-pod debugging hours.) - **Personal `@icloud.com` email** in tracked files → the public contact is `nils@thaw.sh`. -- **`matteso1/thaw` URLs** → the repo lives at `thaw-ai/thaw`; the old one is - archived and 404s clone scripts. +- **Archived `matteso1` repo URLs** → the repo lives at `thaw-ai/thaw`; the old + one is archived and 404s clone scripts. (This rule's own name is why this line + doesn't spell out the full archived path — the linter would flag itself.) - **Leftover `breakpoint()` / `pdb.set_trace()`** in shipped Python. - **Retracted speedup multipliers** (`17.2x`, `12.6x`, `9.7x`, `5.9x`) in the README or `site/` — see [receipt hygiene](#receipt--benchmark-hygiene). diff --git a/crates/thaw-core/src/header.rs b/crates/thaw-core/src/header.rs index 1f70a3e..b783f82 100644 --- a/crates/thaw-core/src/header.rs +++ b/crates/thaw-core/src/header.rs @@ -202,6 +202,7 @@ impl SnapshotHeader { /// callers to pass parameters (version, model id, etc.) in future /// versions of this function, and a custom constructor is easier to /// evolve than an impl of `Default`. + #[allow(clippy::new_without_default)] // intentional: see the note above pub fn new() -> Self { SnapshotHeader { magic: MAGIC, diff --git a/crates/thaw-cuda-sys/src/lib.rs b/crates/thaw-cuda-sys/src/lib.rs index 9a2d11e..5378ddb 100644 --- a/crates/thaw-cuda-sys/src/lib.rs +++ b/crates/thaw-cuda-sys/src/lib.rs @@ -530,6 +530,9 @@ mod tests { /// feature build, `true`. This is the contract that downstream /// runtime-dispatch code depends on. #[test] + // These assert on a compile-time constant on purpose: the whole point is + // to pin the CUDA_AVAILABLE <-> feature-flag contract per build config. + #[allow(clippy::assertions_on_constants)] fn cuda_available_matches_feature() { #[cfg(feature = "cuda")] assert!(CUDA_AVAILABLE); diff --git a/crates/thaw-runtime/src/backend.rs b/crates/thaw-runtime/src/backend.rs index 355309e..da3e54d 100644 --- a/crates/thaw-runtime/src/backend.rs +++ b/crates/thaw-runtime/src/backend.rs @@ -538,7 +538,6 @@ unsafe impl Send for HostRegistration {} impl Drop for HostRegistration { fn drop(&mut self) { if !self.is_real { - return; } #[cfg(feature = "cuda")] { diff --git a/crates/thaw-runtime/src/pipeline.rs b/crates/thaw-runtime/src/pipeline.rs index 3af653b..73eb540 100644 --- a/crates/thaw-runtime/src/pipeline.rs +++ b/crates/thaw-runtime/src/pipeline.rs @@ -313,7 +313,7 @@ fn build_freeze_plan( logical_id: request.logical_id, file_offset: entry.file_offset(), size: entry.size(), - device_region: request.device_region.clone(), + device_region: request.device_region, }); total_bytes += request.device_region.size; } @@ -622,7 +622,7 @@ where bytes_copied: 0, }); } - let num_chunks = (payload_len + chunk_size - 1) / chunk_size; + let num_chunks = payload_len.div_ceil(chunk_size); let total_bytes: u64 = plan.iter().map(|p| p.size).sum(); @@ -831,7 +831,7 @@ where return Ok(FreezeStats::default()); } - let num_chunks = ((file_len as usize) + chunk_size - 1) / chunk_size; + let num_chunks = (file_len as usize).div_ceil(chunk_size); let total_bytes: u64 = plan.iter().map(|p| p.size).sum(); @@ -1248,7 +1248,7 @@ where // Align the start down to the nearest page boundary for O_DIRECT. let read_start = payload_start & !0xFFF; // round down to 4096 let read_len = (payload_end - read_start) as usize; - let num_chunks = (read_len + chunk_size - 1) / chunk_size; + let num_chunks = read_len.div_ceil(chunk_size); /// Round `n` up to the next multiple of 4096. fn align_up_4k(n: usize) -> usize { @@ -1603,7 +1603,7 @@ where let read_start = payload_start & !0xFFF; let read_len = (payload_end - read_start) as usize; - let num_chunks = (read_len + chunk_size - 1) / chunk_size; + let num_chunks = read_len.div_ceil(chunk_size); let mut bufs = acquire_wc_bufs(backend, chunk_size).map_err(RestoreError::Backend)?; let streams = [ @@ -2243,7 +2243,7 @@ mod tests { for i in 0..20u32 { let ptr = DevicePtr(0x1000 + i as u64 * 0x100); - let data: Vec = (0..32).map(|b| (b + i as u8 * 5) & 0xFF).collect(); + let data: Vec = (0..32).map(|b| b + i as u8 * 5).collect(); src.register_region(ptr, data.clone()); requests.push(FreezeRequest::new( RegionKind::Weights, @@ -2396,7 +2396,7 @@ mod tests { for i in 0..20u32 { let ptr = DevicePtr(0x1000 + i as u64 * 0x100); - let data: Vec = (0..32).map(|b| (b + i as u8 * 5) & 0xFF).collect(); + let data: Vec = (0..32).map(|b| b + i as u8 * 5).collect(); backend.register_region(ptr, data.clone()); requests.push(FreezeRequest::new( RegionKind::Weights, @@ -2417,15 +2417,11 @@ mod tests { assert_eq!(stats.regions_frozen, 20); let parsed = thaw_core::Snapshot::from_prelude_bytes(&file).expect("parse"); - for i in 0..20 { + for (i, exp) in expected.iter().enumerate() { let entry = parsed.table().get(i).unwrap(); let start = entry.file_offset() as usize; let end = start + entry.size() as usize; - assert_eq!( - &file[start..end], - expected[i].as_slice(), - "region {i} mismatch" - ); + assert_eq!(&file[start..end], exp.as_slice(), "region {i} mismatch"); } }