Image-Text-to-Text
Transformers
Safetensors
mage_vl
text-generation
mage-vl
vision-language-model
quantization
xpo3
runtime-v4
nvfp4
w4a4
w4a16
blackwell
conversational
custom_code
8-bit precision
Instructions to use ajh-code/Mage-VL-XPO3-NVFP4-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ajh-code/Mage-VL-XPO3-NVFP4-W4A4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="ajh-code/Mage-VL-XPO3-NVFP4-W4A4", trust_remote_code=True) 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)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("ajh-code/Mage-VL-XPO3-NVFP4-W4A4", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ajh-code/Mage-VL-XPO3-NVFP4-W4A4 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ajh-code/Mage-VL-XPO3-NVFP4-W4A4" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ajh-code/Mage-VL-XPO3-NVFP4-W4A4", "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/ajh-code/Mage-VL-XPO3-NVFP4-W4A4
- SGLang
How to use ajh-code/Mage-VL-XPO3-NVFP4-W4A4 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 "ajh-code/Mage-VL-XPO3-NVFP4-W4A4" \ --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": "ajh-code/Mage-VL-XPO3-NVFP4-W4A4", "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 "ajh-code/Mage-VL-XPO3-NVFP4-W4A4" \ --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": "ajh-code/Mage-VL-XPO3-NVFP4-W4A4", "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 ajh-code/Mage-VL-XPO3-NVFP4-W4A4 with Docker Model Runner:
docker model run hf.co/ajh-code/Mage-VL-XPO3-NVFP4-W4A4
| namespace { | |
| torch::Tensor smallm_nvfp4_linear( | |
| const torch::Tensor& input, | |
| const torch::Tensor& packed_weight, | |
| const torch::Tensor& weight_block_scales, | |
| const torch::Tensor& weight_tensor_scale, | |
| const std::optional<torch::Tensor>& bias) { | |
| TORCH_CHECK(input.is_cuda(), "small-M GEMV requires a CUDA input"); | |
| TORCH_CHECK( | |
| input.scalar_type() == at::kBFloat16, | |
| "small-M GEMV input must be bfloat16"); | |
| TORCH_CHECK( | |
| input.dim() >= 1 && input.is_contiguous(), | |
| "small-M GEMV input must be contiguous"); | |
| TORCH_CHECK( | |
| packed_weight.is_cuda() && packed_weight.scalar_type() == at::kByte && | |
| packed_weight.dim() == 2 && packed_weight.is_contiguous(), | |
| "packed weight must be contiguous CUDA uint8 [N,K/2]"); | |
| TORCH_CHECK( | |
| weight_block_scales.is_cuda() && weight_block_scales.dim() == 2 && | |
| weight_block_scales.is_contiguous() && | |
| weight_block_scales.element_size() == 1, | |
| "weight block scales must be contiguous CUDA byte-sized [padded_N,padded_K/16]"); | |
| TORCH_CHECK( | |
| weight_tensor_scale.is_cuda() && | |
| weight_tensor_scale.scalar_type() == at::kFloat && | |
| weight_tensor_scale.numel() == 1 && | |
| weight_tensor_scale.is_contiguous(), | |
| "weight tensor scale must be one contiguous CUDA float32 value"); | |
| TORCH_CHECK( | |
| input.device() == packed_weight.device() && | |
| input.device() == weight_block_scales.device() && | |
| input.device() == weight_tensor_scale.device(), | |
| "all small-M GEMV tensors must use the same CUDA device"); | |
| const int64_t out_features = packed_weight.size(0); | |
| const int64_t in_features = packed_weight.size(1) * 2; | |
| TORCH_CHECK( | |
| input.size(-1) == in_features, | |
| "small-M GEMV expected input width ", | |
| in_features, | |
| " but got ", | |
| input.size(-1)); | |
| TORCH_CHECK( | |
| in_features > 0 && in_features % 32 == 0, | |
| "small-M GEMV requires K divisible by 32"); | |
| TORCH_CHECK( | |
| out_features > 0, | |
| "small-M GEMV requires positive N"); | |
| TORCH_CHECK( | |
| weight_block_scales.size(0) >= out_features && | |
| weight_block_scales.size(1) >= in_features / 16, | |
| "weight block scale tensor is too small"); | |
| if (bias.has_value()) { | |
| const auto& value = *bias; | |
| TORCH_CHECK( | |
| value.is_cuda() && value.scalar_type() == at::kBFloat16 && | |
| value.dim() == 1 && value.is_contiguous() && | |
| value.numel() == out_features && | |
| value.device() == input.device(), | |
| "bias must be contiguous CUDA bfloat16 [N]"); | |
| } | |
| return smallm_nvfp4_linear_cuda( | |
| input, | |
| packed_weight, | |
| weight_block_scales, | |
| weight_tensor_scale, | |
| bias); | |
| } | |
| } // namespace | |
| PYBIND11_MODULE(TORCH_EXTENSION_NAME, module) { | |
| module.def( | |
| "linear", | |
| &smallm_nvfp4_linear, | |
| "Fused BF16-activation x packed-NVFP4-weight small-M GEMV"); | |
| } | |