Text Generation
Transformers
Safetensors
zaya
nvfp4
fp4
vllm
llm-compressor
compressed-tensors
conversational
8-bit precision
Instructions to use inference-optimization/ZAYA1-74B-preview-NVFP4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use inference-optimization/ZAYA1-74B-preview-NVFP4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="inference-optimization/ZAYA1-74B-preview-NVFP4") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("inference-optimization/ZAYA1-74B-preview-NVFP4") model = AutoModelForCausalLM.from_pretrained("inference-optimization/ZAYA1-74B-preview-NVFP4", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use inference-optimization/ZAYA1-74B-preview-NVFP4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "inference-optimization/ZAYA1-74B-preview-NVFP4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/ZAYA1-74B-preview-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/inference-optimization/ZAYA1-74B-preview-NVFP4
- SGLang
How to use inference-optimization/ZAYA1-74B-preview-NVFP4 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "inference-optimization/ZAYA1-74B-preview-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/ZAYA1-74B-preview-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "inference-optimization/ZAYA1-74B-preview-NVFP4" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "inference-optimization/ZAYA1-74B-preview-NVFP4", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use inference-optimization/ZAYA1-74B-preview-NVFP4 with Docker Model Runner:
docker model run hf.co/inference-optimization/ZAYA1-74B-preview-NVFP4
Summary
This is a quantized variant of Zyphra/ZAYA1-74B-preview with linears and experts quantized to NVFP4 using GPTQ.
Creation Process
- Quantize the model to NVFP4 using LLM Compressor
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
# Run this example with `torchrun --nproc_per_node=N zaya1_nvfp4.py`
import torch
from compressed_tensors.offload import init_dist
from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor import oneshot
from llmcompressor.modifiers.quantization import GPTQModifier
from llmcompressor.utils import load_context
# Load model
model_id = "Zyphra/ZAYA1-74B-preview"
init_dist()
with load_context():
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map="auto_offload",
max_memory={},
offload_folder="offload_folder",
)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Configure the quantization algorithm and scheme.
# Ignore `lm_head` and the MoE router/gate layers (`model.layers.*.mlp.gate.*`).
recipe = GPTQModifier(
targets="Linear", scheme="NVFP4", ignore=["lm_head", r"re:.*mlp\.gate\..*"]
)
# Apply quantization.
oneshot(
model=model,
processor=tokenizer,
dataset="perfectblend",
splits="train[:512]",
recipe=recipe,
max_seq_length=512,
num_calibration_samples=256,
batch_size=16,
)
# Save to disk in compressed-tensors format.
SAVE_DIR = model_id.rstrip("/").split("/")[-1] + "-NVFP4"
model.save_pretrained(SAVE_DIR)
tokenizer.save_pretrained(SAVE_DIR)
torch.distributed.destroy_process_group()
- Once the model is saved, repack the 2d weights into 3d weights to match the original checkpoint format
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from compressed_tensors.entrypoints.convert import (
convert_checkpoint,
MoEExpertPacker,
)
# Example model with unfused, linearized weights
# model.layers.0.mlp.experts.0.gate_proj.weight
# model.layers.0.mlp.experts.0.up_proj.weight
# model.layers.0.mlp.experts.0.down_proj.weight
MODEL_ID = "inference-optimization/ZAYA1-74B-preview-NVFP4-linear"
SAVE_DIR = MODEL_ID.rstrip("/").split("/")[-1] + "-3d"
# Convert 2d linearized weights into 3d packed weights
converter = MoEExpertPacker.from_pretrained(
model_name_or_path=MODEL_ID,
fuse_gate_up=True,
)
convert_checkpoint(
model_stub=MODEL_ID,
save_directory=SAVE_DIR,
converter=converter,
max_workers=8,
)
Serving
Serving in vLLM is currently limited, so only HF loading with a patch is supported as of now:
from transformers import AutoModelForCausalLM, AutoTokenizer
from llmcompressor.utils import load_context
model_id = "inference-optimization/ZAYA1-74B-preview-NVFP4-linear"
with load_context():
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
input_ids = tokenizer("According to all known laws", return_tensors="pt").input_ids.to(model.device)
output = model.generate(input_ids, max_new_tokens=20)
print(tokenizer.decode(output[0]))
diff --git a/src/llmcompressor/modeling/moe/conversion_mappings.py b/src/llmcompressor/modeling/moe/conversion_mappings.py
index 36f90c1f0..9c8d4c64d 100644
--- a/src/llmcompressor/modeling/moe/conversion_mappings.py
+++ b/src/llmcompressor/modeling/moe/conversion_mappings.py
@@ -164,6 +164,10 @@ ARCH_TO_IMPORT_PATHS: dict[str, tuple[str | list[str], str | list[str]]] = {
"transformers.models.qwen3_vl_moe.configuration_qwen3_vl_moe.Qwen3VLMoeTextConfig",
"transformers.models.qwen3_vl_moe.modeling_qwen3_vl_moe.Qwen3VLMoeTextExperts",
),
+ "zaya": (
+ "transformers.models.zaya.configuration_zaya.ZayaConfig",
+ "transformers.models.zaya.modeling_zaya.ZayaExperts",
+ ),
}
ARCH_TO_2D_MAPPINGS = {
@@ -248,6 +252,10 @@ ARCH_TO_2D_MAPPINGS = {
),
],
),
+ "zaya": (
+ [],
+ []
+ ),
}
- Downloads last month
- 220
Model tree for inference-optimization/ZAYA1-74B-preview-NVFP4
Base model
Zyphra/ZAYA1-74B-preview