Skip to main content

Module weights

Module weights 

Source
Expand description

Model-agnostic weight I/O — paths, formats, drain policy only.

Architecture checks and tensor renaming live in model crates (gguf_validate_arch, register_gguf_tensor_resolver), not here.

use rlx_models_core::weights::{self, LoadOpts};

let (path, map) = weights::open_map_with(LoadOpts::map().prefer_q4_k_m(), "weights/")?;
let loaded = weights::open_with(LoadOpts::loader(), "model.gguf")?;

Structs§

GgufDirGuide
GgufLoader
LlamaFamilyGgufResolver
HF model.layers.N.* ↔ GGUF blk.N.* (Llama, Qwen3, Qwen35, …).
LoadWeightsOptions
Options for load_weights_resolved — prefer crate::weights::LoadOpts presets at call sites.
PrefixStripGgufResolver
Strip common HF prefixes and match verbatim tensor names (architecture-agnostic fallback).
Qwen35NativeGgufResolver
Qwen3.5 native blk.N.* names; also accept HF aliases via the Llama mapper.
RegisteredFormat
One registered on-disk format (built-in or custom).
ResolveWeightsOptions
Options for resolve_weights_file_with_options.
WeightFormatRegistration
Describes one on-disk weight format.
WeightMap
Map of tensor name → (f32 data, shape).

Enums§

LoadedWeights
Result of resolving and opening weights.
WeightDrainPolicy
How WeightMap::drain_loader / WeightMap::from_weight_loader handle leftovers.

Traits§

GgufTensorNameResolver
Resolve a builder-requested tensor name to the name stored in a GGUF file.
WeightLoader
Common interface every weight format must satisfy. Mirrors the existing WeightMap API so the safetensors impl is a one-line adapter.

Functions§

default_resolve_opts
Default directory resolve: prefer DEFAULT_GGUF_PREFER_SUBSTR.
format_for_extension
Extension → format id (last registration wins).
gguf_dir_guide
Numbered .gguf listing + resolve hints for a directory (CLI / errors).
gguf_split_siblings
Other parts of the same multi-file GGUF split in path’s directory (sorted by split.no).
gguf_validate_arch
Ensure a GGUF file’s general.architecture is in allowed (call from model runners, not the loader).
init
Idempotent: ensure built-in GGUF tensor resolvers are registered (safe to call from main).
list_gguf_files_in_dir
Sorted .gguf paths in a directory (non-recursive).
list_registered_formats
All registered formats (built-ins first, then custom registrations).
load_gguf_file
Open a GGUF file, merging multi-part splits when all siblings are present in the directory.
load_weight_map
Resolve a weights path, validate GGUF general.architecture when applicable, drain to F32.
load_weight_map_resolved
Convenience: resolve + drain to F32 WeightMap.
load_weights_resolved
Resolve a file or directory, enforce GGUF arch policy, open via registry, optionally drain.
open
Resolve + open (live WeightLoader).
open_map
Resolve + drain to F32 WeightMap.
open_map_with
Resolve + drain with options.
open_weight_loader
Open a single file via the format registry.
open_with
Resolve + open with options.
pick
Resolve a file or weights directory to one on-disk path.
pick_default
pick with default_resolve_opts.
register_gguf_tensor_resolver
Register a custom resolver (call before first GGUF load). Later registrations win among resolvers that match the same architecture.
register_weight_format
Register a custom weight format (call before the first load). Later entries override built-ins when the same extension is registered twice.
resolve_weights_file
Resolve --weights to a single file: pass-through for files, or pick one .gguf / model.safetensors inside a directory.
resolve_weights_file_with_options
Resolve with optional GGUF file selection inside a directory.

Type Aliases§

LoadOpts
Alias for LoadWeightsOptions.
PassThroughGgufResolver
Alias for PrefixStripGgufResolver (older name).
ResolveOpts
Alias for ResolveWeightsOptions.