Instructions to use tiny-random/mistral-large-4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tiny-random/mistral-large-4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="tiny-random/mistral-large-4") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("tiny-random/mistral-large-4") model = AutoModelForMultimodalLM.from_pretrained("tiny-random/mistral-large-4", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use tiny-random/mistral-large-4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tiny-random/mistral-large-4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tiny-random/mistral-large-4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/tiny-random/mistral-large-4
- SGLang
How to use tiny-random/mistral-large-4 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 "tiny-random/mistral-large-4" \ --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": "tiny-random/mistral-large-4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "tiny-random/mistral-large-4" \ --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": "tiny-random/mistral-large-4", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use tiny-random/mistral-large-4 with Docker Model Runner:
docker model run hf.co/tiny-random/mistral-large-4
Upload folder using huggingface_hub
Browse files- .meta/create_model.py +2 -3
- README.md +3 -3
- config.json +0 -1
- consolidated.safetensors +2 -2
.meta/create_model.py
CHANGED
|
@@ -60,7 +60,6 @@ def create_model(source_model_id: str, source_revision: str, save_folder: str):
|
|
| 60 |
"quant_method": "fp8",
|
| 61 |
"activation_scheme": "dynamic",
|
| 62 |
"weight_block_size": [64, 64],
|
| 63 |
-
"scale_fmt": "ue8m0",
|
| 64 |
"modules_to_not_convert": [
|
| 65 |
"model.vision_tower",
|
| 66 |
"model.multi_modal_projector",
|
|
@@ -199,7 +198,7 @@ def create_model(source_model_id: str, source_revision: str, save_folder: str):
|
|
| 199 |
rows, columns = value.shape
|
| 200 |
blocks = value.float().reshape(rows // 64, 64, columns // 64, 64)
|
| 201 |
maximum = blocks.abs().amax(dim=(1, 3)).clamp_min(torch.finfo(torch.float32).tiny)
|
| 202 |
-
inverse = torch.pow(2.0, torch.ceil(torch.log2(1.0 / maximum)))
|
| 203 |
state[name] = (
|
| 204 |
(blocks * inverse.float()[:, None, :, None])
|
| 205 |
.clamp(-448, 448)
|
|
@@ -207,7 +206,7 @@ def create_model(source_model_id: str, source_revision: str, save_folder: str):
|
|
| 207 |
.to(torch.float8_e4m3fn)
|
| 208 |
.contiguous()
|
| 209 |
)
|
| 210 |
-
state[name.removesuffix(".weight") + ".qscale_weight"] = (1.0 / inverse
|
| 211 |
|
| 212 |
for name, value in list(state.items()):
|
| 213 |
if should_quantize(name, value):
|
|
|
|
| 60 |
"quant_method": "fp8",
|
| 61 |
"activation_scheme": "dynamic",
|
| 62 |
"weight_block_size": [64, 64],
|
|
|
|
| 63 |
"modules_to_not_convert": [
|
| 64 |
"model.vision_tower",
|
| 65 |
"model.multi_modal_projector",
|
|
|
|
| 198 |
rows, columns = value.shape
|
| 199 |
blocks = value.float().reshape(rows // 64, 64, columns // 64, 64)
|
| 200 |
maximum = blocks.abs().amax(dim=(1, 3)).clamp_min(torch.finfo(torch.float32).tiny)
|
| 201 |
+
inverse = torch.pow(2.0, torch.ceil(torch.log2(1.0 / maximum)))
|
| 202 |
state[name] = (
|
| 203 |
(blocks * inverse.float()[:, None, :, None])
|
| 204 |
.clamp(-448, 448)
|
|
|
|
| 206 |
.to(torch.float8_e4m3fn)
|
| 207 |
.contiguous()
|
| 208 |
)
|
| 209 |
+
state[name.removesuffix(".weight") + ".qscale_weight"] = (1.0 / inverse).contiguous()
|
| 210 |
|
| 211 |
for name, value in list(state.items()):
|
| 212 |
if should_quantize(name, value):
|
README.md
CHANGED
|
@@ -9,8 +9,8 @@ This is a randomly initialized tiny model based on [mistralai/Mistral-Large-4-1T
|
|
| 9 |
|
| 10 |
| Feature | Source | This repo |
|
| 11 |
|---|---|---|
|
| 12 |
-
| Checkpoint tensor elements | 7.13B BF16, 63.84M F32, 1.05T F8_E4M3 | 54.84M BF16, 1.31M F8_E4M3
|
| 13 |
-
| Safetensors weight files | 1.06 TB (54 files) | 111.
|
| 14 |
| Architecture / input | Multimodal MoE; text and image | Same |
|
| 15 |
| Vocabulary rows / tied embeddings | 204,800 / false | 204,800 / true |
|
| 16 |
| Backbone layers | 72 | 12: three complete RoPE/RoPE/RoPE/NoPE cycles |
|
|
@@ -20,7 +20,7 @@ This is a randomly initialized tiny model based on [mistralai/Mistral-Large-4-1T
|
|
| 20 |
| Cross-layer KV sharing | Source pattern | Two complete three-own/one-shared NoPE cycles |
|
| 21 |
| Vision tower | 30 layers; 2,048 width | 4 layers; 64 width |
|
| 22 |
| DSpark | 3 dense MLA stages; rank 512; depth 3 | 3 dense MLA stages; rank 8; depth 3 |
|
| 23 |
-
| Checkpoint precision | E4M3 block-FP8 +
|
| 24 |
|
| 25 |
TP=2 vLLM uses a 64-wide FP8 activation group per rank, which fixes the residual width at 128. The checkpoint retains 64×64 FP8 blocks, a 512-wide MLA latent KV required by H20 sparse MLA, and four 32-wide attention heads. The input/output BF16 token table is tied, saving one 52.43 MB matrix; the optimized vLLM kernel constraints still place the checkpoint above the 30 MB soft target.
|
| 26 |
|
|
|
|
| 9 |
|
| 10 |
| Feature | Source | This repo |
|
| 11 |
|---|---|---|
|
| 12 |
+
| Checkpoint tensor elements | 7.13B BF16, 63.84M F32, 1.05T F8_E4M3 | 54.84M BF16, 320 F32, 1.31M F8_E4M3 |
|
| 13 |
+
| Safetensors weight files | 1.06 TB (54 files) | 111.13 MB (consolidated.safetensors) |
|
| 14 |
| Architecture / input | Multimodal MoE; text and image | Same |
|
| 15 |
| Vocabulary rows / tied embeddings | 204,800 / false | 204,800 / true |
|
| 16 |
| Backbone layers | 72 | 12: three complete RoPE/RoPE/RoPE/NoPE cycles |
|
|
|
|
| 20 |
| Cross-layer KV sharing | Source pattern | Two complete three-own/one-shared NoPE cycles |
|
| 21 |
| Vision tower | 30 layers; 2,048 width | 4 layers; 64 width |
|
| 22 |
| DSpark | 3 dense MLA stages; rank 512; depth 3 | 3 dense MLA stages; rank 8; depth 3 |
|
| 23 |
+
| Checkpoint precision | E4M3 block-FP8 + FP32 scales; BF16 exclusions | Same format; 64×64 blocks |
|
| 24 |
|
| 25 |
TP=2 vLLM uses a 64-wide FP8 activation group per rank, which fixes the residual width at 128. The checkpoint retains 64×64 FP8 blocks, a 512-wide MLA latent KV required by H20 sparse MLA, and four 32-wide attention heads. The input/output BF16 token table is tied, saving one 52.43 MB matrix; the optimized vLLM kernel constraints still place the checkpoint above the 30 MB soft target.
|
| 26 |
|
config.json
CHANGED
|
@@ -14,7 +14,6 @@
|
|
| 14 |
64,
|
| 15 |
64
|
| 16 |
],
|
| 17 |
-
"scale_fmt": "ue8m0",
|
| 18 |
"modules_to_not_convert": [
|
| 19 |
"model.vision_tower",
|
| 20 |
"model.multi_modal_projector",
|
|
|
|
| 14 |
64,
|
| 15 |
64
|
| 16 |
],
|
|
|
|
| 17 |
"modules_to_not_convert": [
|
| 18 |
"model.vision_tower",
|
| 19 |
"model.multi_modal_projector",
|
consolidated.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab784992be89268fd19a096a69a31216896129dd6703af7339411b09d7e4bf4a
|
| 3 |
+
size 111125104
|