Module weight_lora_rdma

Module weight_lora_rdma 

Source

Structs§

LoraLandTarget
One landing instruction: the adapter tensor tensor_name (a manifest key), which half it is, the device destination address (a pool-slot sub-region base, already pool + slot*slot_bytes + a_off|b_off), and the geometry the convert/repack needs. rank is the adapter’s real r; max_rank the pool’s padded rank.
RdmaLoraLoader
RDMA-stage a named adapter’s A/B into pre-computed pool-slot sub-regions.

Enums§

LoraAbKind
Which half of a LoRA pair a target lands. A is copied contiguous into the head of the padded [max_rank, in] region; B is row-repacked from stride r to stride max_rank into [out, max_rank].

Functions§

convert_to_bf16
Host F16/F32/BF16 → BF16, byte-for-byte matching the disk adapter loader (load_adapter_safetensors): half::bf16::from_f32 (round-to-nearest-even) for the float conversions. Any other dtype is a hard error — a PEFT adapter is only ever F32 (default), F16, or BF16.
land_bytes_for_target
The final host bytes to copy_h2d for a target, given the raw on-wire tensor bytes (as landed in the bounce). A: convert only. B: convert + repack. Factored out (un-gated) so the byte-identity logic is unit-testable off the RDMA path — the verbs loop calls this so tested and shipped logic agree.
repack_b_to_padded
Row-repack a BF16 B tensor [out_dim, r] into the pool’s padded [out_dim, max_rank] layout: per row, r BF16 elements copied from stride r to stride max_rank; pad columns stay zero. Byte-identical to the disk pack’s B repack. Returns out_dim * max_rank * 2 bytes.