1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Compile-time guards for the auto-trait bounds the parallel dispatch relies on.
//!
//! `src/parallel.rs`'s `map_indexed` shares `&self` across scoped worker threads,
//! which requires the shared parsed-model types to be `Sync`. That holds today
//! purely because every field happens to be `Sync` — no marker impl is written
//! anywhere, and none should be (`CONVENTIONS.md` "When Parallelizing Work":
//! *never reach for manual `Send`/`Sync` impls*).
//!
//! The risk is silent regression by omission: adding a `Cell`, `RefCell`, `Rc`,
//! or raw pointer field to `ParsedModel` or `ParsedGguf` would drop `Sync`, and
//! the failure would surface as an inscrutable closure-bound error deep inside
//! the `thread::scope` call, far from the field that caused it. These assertions
//! turn that into a one-line failure naming the type.
//!
//! `Send` is asserted alongside `Sync` because the `Send` requirement is what
//! lets the produced results move back to the calling thread, and both are
//! equally easy to lose.
//!
//! These are **compile-time** assertions: if the crate builds, the contract
//! holds. The `#[test]` wrapper exists only so the file is a runnable target and
//! shows up in the suite.
/// Fails to compile unless `T: Send + Sync`.
const
/// The safetensors model shared across workers by
/// `ParsedModel::dequantize_all` (Phase 7, v0.7.0).
/// The `GGUF` model shared across workers by `convert::read_gguf`
/// (Phase 7.2, v0.7.2). The ROADMAP long recorded `ParsedGguf: Sync` as a
/// *blocker* for this parallelisation; it was in fact already satisfied — every
/// field (`Backing`, `u32`, the metadata `HashMap`, the tensor-info `Vec`) is
/// `Sync`, and `memmap2::Mmap` is `Send + Sync`. This assertion is what keeps
/// that true.
/// The tensor **views** are what actually cross into the workers (the dispatch
/// is handed a `&[GgufTensor<'_>]`), so their auto-traits matter as much as the
/// owner's.
/// The option types travel by value into the library entry points and will
/// cross the `PyO3` boundary at Phase 8; losing `Send` here would be a silent
/// ergonomics regression for any caller driving conversions from a worker pool.