Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions crates/thaw-core/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions crates/thaw-cuda-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion crates/thaw-runtime/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
{
Expand Down
22 changes: 9 additions & 13 deletions crates/thaw-runtime/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -2243,7 +2243,7 @@ mod tests {

for i in 0..20u32 {
let ptr = DevicePtr(0x1000 + i as u64 * 0x100);
let data: Vec<u8> = (0..32).map(|b| (b + i as u8 * 5) & 0xFF).collect();
let data: Vec<u8> = (0..32).map(|b| b + i as u8 * 5).collect();
src.register_region(ptr, data.clone());
requests.push(FreezeRequest::new(
RegionKind::Weights,
Expand Down Expand Up @@ -2396,7 +2396,7 @@ mod tests {

for i in 0..20u32 {
let ptr = DevicePtr(0x1000 + i as u64 * 0x100);
let data: Vec<u8> = (0..32).map(|b| (b + i as u8 * 5) & 0xFF).collect();
let data: Vec<u8> = (0..32).map(|b| b + i as u8 * 5).collect();
backend.register_region(ptr, data.clone());
requests.push(FreezeRequest::new(
RegionKind::Weights,
Expand All @@ -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");
}
}

Expand Down
Loading