Skip to content
Open
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
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,25 @@ MIYAGI_TEST_GPU_LAYERS=0 \
cargo test --no-default-features --test model_backend
```

### Building on Windows (MSVC)

Miyagi builds and runs on Windows (validated on Windows 11, Rust
`x86_64-pc-windows-msvc`, against mainline llama.cpp b10054 with an RTX 4090).
Notes:

- With Visual Studio 18 installed, the `cmake` crate requests the
"Visual Studio 18 2026" generator, which needs CMake ≥ 4.3 on `PATH`
(VS's bundled CMake works).
- For `--features cuda` with a VS version newer than your CUDA toolkit's VS
integration, use the Ninja generator inside a `vcvars64` environment of a VS
version the toolkit supports, e.g.:

```bat
call "...\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
set CMAKE_GENERATOR=Ninja
cargo build --release --features cuda
```

## Compatibility and Boundaries

- Miyagi supports descriptor-driven Qwen/Bonsai MLP mapping for two-dimensional
Expand Down
43 changes: 43 additions & 0 deletions src/architecture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,24 @@ impl TensorInfo {

#[derive(Clone, Debug, Eq, PartialEq, Serialize)]
pub struct ArchitectureMap {
// Tuple keys cannot be JSON map keys ("key must be a string"); emit the
// tensor list instead — each TensorInfo already carries layer+projection.
#[serde(serialize_with = "serialize_tensor_map")]
tensors: BTreeMap<(usize, Projection), TensorInfo>,
layer_count: usize,
signature: String,
}

fn serialize_tensor_map<S>(
tensors: &BTreeMap<(usize, Projection), TensorInfo>,
serializer: S,
) -> std::result::Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.collect_seq(tensors.values())
}

impl ArchitectureMap {
pub fn discover(descriptors: &[TensorDescriptor]) -> Result<Self> {
let mut tensors = BTreeMap::new();
Expand Down Expand Up @@ -295,4 +308,34 @@ mod tests {
"\"down_proj\""
);
}

#[test]
fn architecture_map_json_serializes_tensors_as_array() {
let mut descriptors = Vec::new();
for layer in 0..2 {
descriptors.push(descriptor(
&format!("blk.{layer}.ffn_gate.weight"),
4096,
12288,
));
descriptors.push(descriptor(
&format!("blk.{layer}.ffn_up.weight"),
4096,
12288,
));
descriptors.push(descriptor(
&format!("blk.{layer}.ffn_down.weight"),
12288,
4096,
));
}
let map = ArchitectureMap::discover(&descriptors).unwrap();
let value = serde_json::to_value(&map).expect("JSON serialize must not fail on tuple keys");
let tensors = value
.get("tensors")
.and_then(|t| t.as_array())
.expect("tensors must serialize as a JSON array");
assert_eq!(tensors.len(), 6);
assert!(tensors.iter().all(|t| t.get("layer").is_some() && t.get("projection").is_some()));
}
}