Spaces:
Running on Zero
Running on Zero
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -41,6 +41,7 @@ from transformers import AutoConfig, AutoModel, AutoProcessor # noqa: E402
|
|
| 41 |
# --------------------------------------------------------------------------- #
|
| 42 |
|
| 43 |
MODEL_ID = "Alibaba-DAMO-Academy/RynnValue-4B"
|
|
|
|
| 44 |
|
| 45 |
_config = AutoConfig.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 46 |
# The exported checkpoint doesn't persist the attention implementation, so force
|
|
@@ -51,9 +52,12 @@ model = AutoModel.from_pretrained(
|
|
| 51 |
MODEL_ID,
|
| 52 |
config=_config,
|
| 53 |
trust_remote_code=True,
|
| 54 |
-
torch_dtype=
|
| 55 |
)
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 59 |
tokenizer = processor.tokenizer
|
|
|
|
| 41 |
# --------------------------------------------------------------------------- #
|
| 42 |
|
| 43 |
MODEL_ID = "Alibaba-DAMO-Academy/RynnValue-4B"
|
| 44 |
+
DTYPE = torch.bfloat16
|
| 45 |
|
| 46 |
_config = AutoConfig.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 47 |
# The exported checkpoint doesn't persist the attention implementation, so force
|
|
|
|
| 52 |
MODEL_ID,
|
| 53 |
config=_config,
|
| 54 |
trust_remote_code=True,
|
| 55 |
+
torch_dtype=DTYPE,
|
| 56 |
)
|
| 57 |
+
# The value heads are built in fp32 regardless of `torch_dtype`; the reference
|
| 58 |
+
# CLI casts the whole model with `.to(device=..., dtype=...)`, so do the same or
|
| 59 |
+
# the head matmuls hit "mat1 and mat2 must have the same dtype".
|
| 60 |
+
model = model.eval().to(device="cuda", dtype=DTYPE)
|
| 61 |
|
| 62 |
processor = AutoProcessor.from_pretrained(MODEL_ID, trust_remote_code=True)
|
| 63 |
tokenizer = processor.tokenizer
|