handwoven8588 commited on
Commit
aa2548a
·
verified ·
1 Parent(s): 7961156

README: reframe bf16 weights — reason is flash_attn half-precision + runtime-bf16 (not download size)

Browse files
Files changed (1) hide show
  1. README.md +11 -6
README.md CHANGED
@@ -32,11 +32,12 @@ itself, so no runtime patching or post-load hooks are needed.
32
 
33
  ## Behavior
34
 
35
- - **Loads bf16 by default.** Weights are stored bf16 (half the download: 274 MB vs 547 MB) and
36
- `config.json` declares `torch_dtype: bfloat16`. The upstream custom `from_pretrained` silently
37
- dropped `torch_dtype` and always loaded fp32; the copy in this repo honors it, so the model loads
38
- bf16 natively, like any normal HF model. Pass `torch_dtype=torch.float32` to load fp32 (note: the
39
- stored weights are bf16-precision, so this only widens the dtype, not the precision).
 
40
  - **CUDA + `flash_attn`** → flash-varlen path (fast, low VRAM). Attention tensors are cast to bf16
41
  internally as a safety net; with the default bf16 load this is a no-op.
42
  - **CPU, or no `flash_attn`** → the original eager attention algorithm runs unchanged. Because the
@@ -78,7 +79,11 @@ also scales to far larger batches (bs=256 fits in ~7.6 GB) where eager O(seq²)
78
 
79
  ## What changed vs the source repo
80
 
81
- 1. **Weights**: fp32 → bf16 (lossy cast, parity-neutral). Halves the download.
 
 
 
 
82
  2. **`from_pretrained` dtype fix**: the upstream custom `from_pretrained` instantiated the model
83
  fp32 and `load_state_dict`-ed the checkpoint into fp32 params, **ignoring `torch_dtype`**. The
84
  copy here adds the standard transformers dtype resolution (explicit arg → `config.torch_dtype` →
 
32
 
33
  ## Behavior
34
 
35
+ - **Loads bf16 by default.** `flash_attn` requires half precision and the model runs bf16 in any
36
+ real serving setup, so the weights are stored bf16 and `config.json` declares `torch_dtype:
37
+ bfloat16`. The upstream custom `from_pretrained` silently dropped `torch_dtype` and always loaded
38
+ fp32; the copy in this repo honors it, so the model loads bf16 natively, like any normal HF
39
+ model. Pass `torch_dtype=torch.float32` to load fp32 (note: the stored weights are bf16-precision,
40
+ so this only widens the dtype, not the precision).
41
  - **CUDA + `flash_attn`** → flash-varlen path (fast, low VRAM). Attention tensors are cast to bf16
42
  internally as a safety net; with the default bf16 load this is a no-op.
43
  - **CPU, or no `flash_attn`** → the original eager attention algorithm runs unchanged. Because the
 
79
 
80
  ## What changed vs the source repo
81
 
82
+ 1. **Weights**: fp32 → bf16. `flash_attn` only accepts half precision and the model runs bf16 in
83
+ any real serving configuration, so the weights are stored bf16 and (via the load fix below)
84
+ arrive bf16 — which is simply how this model is used, and removes the need for a post-load dtype
85
+ cast. Parity-neutral (cosine 0.9986 vs the fp32 original); the smaller download is incidental,
86
+ not the reason.
87
  2. **`from_pretrained` dtype fix**: the upstream custom `from_pretrained` instantiated the model
88
  fp32 and `load_state_dict`-ed the checkpoint into fp32 params, **ignoring `torch_dtype`**. The
89
  copy here adds the standard transformers dtype resolution (explicit arg → `config.torch_dtype` →