Text Generation
Transformers
Safetensors
English
Arabic
quasar_long
silx-ai
quasar-preview
quasar
foundation-model
Mixture of Experts
18b
2b-active
long-context
bittensor
sn24
decentralized-training
distillation
hybrid-transformer
loop-transformer
safe-nope
drope
conversational
custom_code
Instructions to use mainline777/base_IIXIV with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mainline777/base_IIXIV with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mainline777/base_IIXIV", trust_remote_code=True, device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("mainline777/base_IIXIV", trust_remote_code=True, dtype="auto", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mainline777/base_IIXIV with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mainline777/base_IIXIV" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mainline777/base_IIXIV", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mainline777/base_IIXIV
- SGLang
How to use mainline777/base_IIXIV 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 "mainline777/base_IIXIV" \ --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": "mainline777/base_IIXIV", "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 "mainline777/base_IIXIV" \ --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": "mainline777/base_IIXIV", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mainline777/base_IIXIV with Docker Model Runner:
docker model run hf.co/mainline777/base_IIXIV
| from __future__ import annotations | |
| from typing import TYPE_CHECKING | |
| import torch | |
| import torch.distributed as dist | |
| if TYPE_CHECKING: | |
| from torch.distributed import ProcessGroup | |
| def all_gather_into_tensor( | |
| inp: torch.Tensor, | |
| out: torch.Tensor | None = None, | |
| group: ProcessGroup | None = None, | |
| async_op: bool = False | |
| ) -> tuple[torch.Tensor, dist.Work | None]: | |
| """ | |
| All-gather a tensor across ranks. | |
| Args: | |
| inp: Input tensor to gather | |
| out: Optional output tensor of shape [world_size, *inp.shape] | |
| group: Process group | |
| async_op: Whether to perform async operation | |
| Returns: | |
| Tuple of (output tensor, handle if async_op else None) | |
| """ | |
| world_size = dist.get_world_size(group=group) | |
| if out is None: | |
| out = torch.empty(world_size, *inp.shape, device=inp.device, dtype=inp.dtype) | |
| handle = dist.all_gather_into_tensor(out, inp, group=group, async_op=async_op) | |
| return out, handle | |
| def all_reduce_sum( | |
| inp: torch.Tensor, | |
| group: ProcessGroup | None = None, | |
| async_op: bool = False | |
| ) -> tuple[torch.Tensor, dist.Work | None]: | |
| """ | |
| All-reduce sum a tensor across ranks. | |
| Args: | |
| inp: Input tensor to reduce (modified in-place) | |
| group: Process group | |
| async_op: Whether to perform async operation | |
| Returns: | |
| Tuple of (reduced tensor, handle if async_op else None) | |
| """ | |
| handle = dist.all_reduce(inp, op=dist.ReduceOp.SUM, group=group, async_op=async_op) | |
| return inp, handle | |
| def send_recv_fwd( | |
| send_tensor: torch.Tensor, | |
| group: ProcessGroup, | |
| recv_from_prev: bool = True | |
| ) -> torch.Tensor: | |
| """ | |
| Forward pass communication: send tensor to next rank, receive from previous rank. | |
| Uses all_gather for simplicity and to ensure all ranks participate. | |
| Args: | |
| send_tensor: Tensor to send (e.g., tails for conv1d) | |
| group: Process group | |
| recv_from_prev: If True, receive from previous rank; if False, receive from next rank | |
| Returns: | |
| Received tensor from the specified rank (zeros if no valid source) | |
| """ | |
| rank = dist.get_rank(group) | |
| world_size = dist.get_world_size(group) | |
| # All-gather to ensure all ranks participate | |
| gathered, _ = all_gather_into_tensor(send_tensor, group=group, async_op=False) | |
| if recv_from_prev: | |
| # Receive from previous rank | |
| if rank == 0: | |
| return torch.zeros_like(send_tensor) | |
| else: | |
| return gathered[rank - 1].clone() | |
| else: | |
| # Receive from next rank | |
| if rank == world_size - 1: | |
| return torch.zeros_like(send_tensor) | |
| else: | |
| return gathered[rank + 1].clone() | |
| def send_recv_bwd( | |
| send_tensor: torch.Tensor, | |
| group: ProcessGroup, | |
| recv_from_next: bool = True | |
| ) -> torch.Tensor: | |
| """ | |
| Backward pass communication: send gradient to previous rank, receive from next rank. | |
| Uses all_gather for simplicity and to ensure all ranks participate. | |
| Args: | |
| send_tensor: Gradient tensor to send | |
| group: Process group | |
| recv_from_next: If True, receive from next rank; if False, receive from previous rank | |
| Returns: | |
| Received gradient tensor from the specified rank (zeros if no valid source) | |
| """ | |
| rank = dist.get_rank(group) | |
| world_size = dist.get_world_size(group) | |
| # All-gather to ensure all ranks participate | |
| gathered, _ = all_gather_into_tensor(send_tensor, group=group, async_op=False) | |
| if recv_from_next: | |
| # Receive from next rank | |
| if rank == world_size - 1: | |
| return torch.zeros_like(send_tensor) | |
| else: | |
| return gathered[rank + 1].clone() | |
| else: | |
| # Receive from previous rank | |
| if rank == 0: | |
| return torch.zeros_like(send_tensor) | |
| else: | |
| return gathered[rank - 1].clone() | |
| # ============ Convenience aliases for conv1d CP ============ | |
| def conv_cp_send_recv_fwd(tails: torch.Tensor, group: ProcessGroup) -> torch.Tensor: | |
| """ | |
| Conv1d CP forward: each rank sends its tails, receives previous rank's tails as heads. | |
| Args: | |
| tails: [W-1, D] or [N, D, W-1] - tail tokens from current rank | |
| group: Process group | |
| Returns: | |
| heads: Same shape as tails - head tokens from previous rank (zeros for rank 0) | |
| """ | |
| return send_recv_fwd(tails, group, recv_from_prev=True) | |
| def conv_cp_send_recv_bwd(d_initial_state: torch.Tensor, group: ProcessGroup) -> torch.Tensor: | |
| """ | |
| Conv1d CP backward: each rank sends d_initial_state, receives from next rank. | |
| The received gradient should be added to the last W-1 tokens' gradient. | |
| Args: | |
| d_initial_state: [W-1, D] or [N, D, W-1] - gradient w.r.t. initial state | |
| group: Process group | |
| Returns: | |
| recv_grad: Same shape - gradient from next rank (zeros for last rank) | |
| """ | |
| return send_recv_bwd(d_initial_state, group, recv_from_next=True) | |