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) 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") - 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
| # Copyright (c) 2023-2025, Songlin Yang, Yu Zhang | |
| import torch | |
| import triton | |
| import triton.language as tl | |
| from fla.ops.utils.index import prepare_chunk_indices | |
| from fla.utils import autotune_cache_kwargs, check_shared_mem, input_guard | |
| BS_LIST = [32, 64] if check_shared_mem() else [16, 32] | |
| def chunk_local_cumsum_scalar_kernel( | |
| s, | |
| o, | |
| scale, | |
| cu_seqlens, | |
| chunk_indices, | |
| T, | |
| B: tl.constexpr, | |
| H: tl.constexpr, | |
| BT: tl.constexpr, | |
| REVERSE: tl.constexpr, | |
| HAS_SCALE: tl.constexpr, | |
| IS_VARLEN: tl.constexpr, | |
| HEAD_FIRST: tl.constexpr, | |
| ): | |
| i_t, i_bh = tl.program_id(0), tl.program_id(1) | |
| i_b, i_h = i_bh // H, i_bh % H | |
| if IS_VARLEN: | |
| i_n, i_t = tl.load(chunk_indices + i_t * 2).to(tl.int32), tl.load(chunk_indices + i_t * 2 + 1).to(tl.int32) | |
| bos, eos = tl.load(cu_seqlens + i_n).to(tl.int32), tl.load(cu_seqlens + i_n + 1).to(tl.int32) | |
| T = eos - bos | |
| else: | |
| bos, eos = i_b * T, i_b * T + T | |
| if HEAD_FIRST: | |
| p_s = tl.make_block_ptr(s + bos*H + i_h*T, (T,), (1,), (i_t * BT,), (BT,), (0,)) | |
| p_o = tl.make_block_ptr(o + bos*H + i_h*T, (T,), (1,), (i_t * BT,), (BT,), (0,)) | |
| else: | |
| p_s = tl.make_block_ptr(s + bos*H + i_h, (T,), (H,), (i_t * BT,), (BT,), (0,)) | |
| p_o = tl.make_block_ptr(o + bos*H + i_h, (T,), (H,), (i_t * BT,), (BT,), (0,)) | |
| # [BT] | |
| b_s = tl.load(p_s, boundary_check=(0,)).to(tl.float32) | |
| b_o = tl.cumsum(b_s, axis=0) | |
| if REVERSE: | |
| b_z = tl.sum(b_s, axis=0) | |
| b_o = -b_o + b_z[None] + b_s | |
| if HAS_SCALE: | |
| b_o *= scale | |
| tl.store(p_o, b_o.to(p_o.dtype.element_ty), boundary_check=(0,)) | |
| def chunk_local_cumsum_vector_kernel( | |
| s, | |
| o, | |
| scale, | |
| cu_seqlens, | |
| chunk_indices, | |
| T, | |
| B: tl.constexpr, | |
| H: tl.constexpr, | |
| S: tl.constexpr, | |
| BT: tl.constexpr, | |
| BS: tl.constexpr, | |
| REVERSE: tl.constexpr, | |
| HAS_SCALE: tl.constexpr, | |
| IS_VARLEN: tl.constexpr, | |
| HEAD_FIRST: tl.constexpr, | |
| ): | |
| i_s, i_t, i_bh = tl.program_id(0), tl.program_id(1), tl.program_id(2) | |
| i_b, i_h = i_bh // H, i_bh % H | |
| if IS_VARLEN: | |
| i_n, i_t = tl.load(chunk_indices + i_t * 2).to(tl.int32), tl.load(chunk_indices + i_t * 2 + 1).to(tl.int32) | |
| bos, eos = tl.load(cu_seqlens + i_n).to(tl.int32), tl.load(cu_seqlens + i_n + 1).to(tl.int32) | |
| T = eos - bos | |
| else: | |
| bos, eos = i_b * T, i_b * T + T | |
| if HEAD_FIRST: | |
| p_s = tl.make_block_ptr(s + (bos * H + i_h*T)*S, (T, S), (S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| p_o = tl.make_block_ptr(o + (bos * H + i_h*T)*S, (T, S), (S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| else: | |
| p_s = tl.make_block_ptr(s + (bos * H + i_h) * S, (T, S), (H*S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| p_o = tl.make_block_ptr(o + (bos * H + i_h) * S, (T, S), (H*S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| # [BT, BS] | |
| b_s = tl.load(p_s, boundary_check=(0, 1)).to(tl.float32) | |
| if REVERSE: | |
| b_o = tl.cumsum(b_s, axis=0, reverse=True) | |
| else: | |
| b_o = tl.cumsum(b_s, axis=0) | |
| if HAS_SCALE: | |
| b_o *= scale | |
| tl.store(p_o, b_o.to(p_o.dtype.element_ty), boundary_check=(0, 1)) | |
| def chunk_global_cumsum_scalar_kernel( | |
| s, | |
| o, | |
| scale, | |
| cu_seqlens, | |
| T, | |
| B: tl.constexpr, | |
| H: tl.constexpr, | |
| BT: tl.constexpr, | |
| REVERSE: tl.constexpr, | |
| HAS_SCALE: tl.constexpr, | |
| IS_VARLEN: tl.constexpr, | |
| HEAD_FIRST: tl.constexpr, | |
| ): | |
| i_nh = tl.program_id(0) | |
| i_n, i_h = i_nh // H, i_nh % H | |
| if IS_VARLEN: | |
| bos, eos = tl.load(cu_seqlens + i_n).to(tl.int32), tl.load(cu_seqlens + i_n + 1).to(tl.int32) | |
| else: | |
| bos, eos = i_n * T, i_n * T + T | |
| T = eos - bos | |
| b_z = tl.zeros([], dtype=tl.float32) | |
| NT = tl.cdiv(T, BT) | |
| for i_c in range(NT): | |
| i_t = NT - 1 - i_c if REVERSE else i_c | |
| if HEAD_FIRST: | |
| p_s = tl.make_block_ptr(s + bos*H + i_h*T, (T,), (1,), (i_t * BT,), (BT,), (0,)) | |
| p_o = tl.make_block_ptr(o + bos*H + i_h*T, (T,), (1,), (i_t * BT,), (BT,), (0,)) | |
| else: | |
| p_s = tl.make_block_ptr(s + bos*H + i_h, (T,), (H,), (i_t * BT,), (BT,), (0,)) | |
| p_o = tl.make_block_ptr(o + bos*H + i_h, (T,), (H,), (i_t * BT,), (BT,), (0,)) | |
| b_s = tl.load(p_s, boundary_check=(0,)).to(tl.float32) | |
| b_o = tl.cumsum(b_s, axis=0) | |
| b_ss = tl.sum(b_s, 0) | |
| if REVERSE: | |
| b_o = -b_o + b_ss + b_s | |
| b_o += b_z | |
| if i_c >= 0: | |
| b_z += b_ss | |
| if HAS_SCALE: | |
| b_o *= scale | |
| tl.store(p_o, b_o.to(p_o.dtype.element_ty), boundary_check=(0,)) | |
| def chunk_global_cumsum_vector_kernel( | |
| s, | |
| o, | |
| scale, | |
| cu_seqlens, | |
| T, | |
| B: tl.constexpr, | |
| H: tl.constexpr, | |
| S: tl.constexpr, | |
| BT: tl.constexpr, | |
| BS: tl.constexpr, | |
| REVERSE: tl.constexpr, | |
| HAS_SCALE: tl.constexpr, | |
| IS_VARLEN: tl.constexpr, | |
| HEAD_FIRST: tl.constexpr, | |
| ): | |
| i_s, i_nh = tl.program_id(0), tl.program_id(1) | |
| i_n, i_h = i_nh // H, i_nh % H | |
| if IS_VARLEN: | |
| bos, eos = tl.load(cu_seqlens + i_n).to(tl.int32), tl.load(cu_seqlens + i_n + 1).to(tl.int32) | |
| else: | |
| bos, eos = i_n * T, i_n * T + T | |
| T = eos - bos | |
| b_z = tl.zeros([BS], dtype=tl.float32) | |
| NT = tl.cdiv(T, BT) | |
| for i_c in range(NT): | |
| i_t = NT - 1 - i_c if REVERSE else i_c | |
| if HEAD_FIRST: | |
| p_s = tl.make_block_ptr(s + (bos * H + i_h*T)*S, (T, S), (S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| p_o = tl.make_block_ptr(o + (bos * H + i_h*T)*S, (T, S), (S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| else: | |
| p_s = tl.make_block_ptr(s + (bos * H + i_h) * S, (T, S), (H*S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| p_o = tl.make_block_ptr(o + (bos * H + i_h) * S, (T, S), (H*S, 1), (i_t * BT, i_s * BS), (BT, BS), (1, 0)) | |
| # [BT, BS] | |
| b_s = tl.load(p_s, boundary_check=(0, 1)).to(tl.float32) | |
| if REVERSE: | |
| b_c = b_z[None, :] + tl.cumsum(b_s, axis=0, reverse=True) | |
| else: | |
| b_c = b_z[None, :] + tl.cumsum(b_s, axis=0) | |
| if HAS_SCALE: | |
| b_c *= scale | |
| tl.store(p_o, b_c.to(p_o.dtype.element_ty), boundary_check=(0, 1)) | |
| b_z += tl.sum(b_s, 0) | |
| def chunk_local_cumsum_scalar( | |
| g: torch.Tensor, | |
| chunk_size: int, | |
| reverse: bool = False, | |
| scale: float = None, | |
| cu_seqlens: torch.Tensor | None = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| chunk_indices: torch.LongTensor | None = None, | |
| ) -> torch.Tensor: | |
| if head_first: | |
| B, H, T = g.shape | |
| else: | |
| B, T, H = g.shape | |
| assert chunk_size == 2**(chunk_size.bit_length()-1), "chunk_size must be a power of 2" | |
| BT = chunk_size | |
| if chunk_indices is None and cu_seqlens is not None: | |
| chunk_indices = prepare_chunk_indices(cu_seqlens, BT) | |
| NT = triton.cdiv(T, BT) if cu_seqlens is None else len(chunk_indices) | |
| g_org, g = g, torch.empty_like(g, dtype=output_dtype or g.dtype) | |
| grid = (NT, B * H) | |
| chunk_local_cumsum_scalar_kernel[grid]( | |
| s=g_org, | |
| o=g, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| chunk_indices=chunk_indices, | |
| T=T, | |
| B=B, | |
| H=H, | |
| BT=BT, | |
| HEAD_FIRST=head_first, | |
| REVERSE=reverse, | |
| ) | |
| return g | |
| def chunk_local_cumsum_vector( | |
| g: torch.Tensor, | |
| chunk_size: int, | |
| reverse: bool = False, | |
| scale: float = None, | |
| cu_seqlens: torch.Tensor | None = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| chunk_indices: torch.LongTensor | None = None, | |
| ) -> torch.Tensor: | |
| if head_first: | |
| B, H, T, S = g.shape | |
| else: | |
| B, T, H, S = g.shape | |
| BT = chunk_size | |
| if chunk_indices is None and cu_seqlens is not None: | |
| chunk_indices = prepare_chunk_indices(cu_seqlens, BT) | |
| NT = triton.cdiv(T, BT) if cu_seqlens is None else len(chunk_indices) | |
| assert chunk_size == 2**(chunk_size.bit_length()-1), "chunk_size must be a power of 2" | |
| g_org, g = g, torch.empty_like(g, dtype=output_dtype or g.dtype) | |
| def grid(meta): return (triton.cdiv(meta['S'], meta['BS']), NT, B * H) | |
| # keep cummulative normalizer in fp32 | |
| # this kernel is equivalent to | |
| # g = g.view(B, H, NT, BT, -1).cumsum(-2).view(B, H, T, -1) | |
| chunk_local_cumsum_vector_kernel[grid]( | |
| s=g_org, | |
| o=g, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| chunk_indices=chunk_indices, | |
| T=T, | |
| B=B, | |
| H=H, | |
| S=S, | |
| BT=BT, | |
| HEAD_FIRST=head_first, | |
| REVERSE=reverse, | |
| ) | |
| return g | |
| def chunk_global_cumsum_scalar( | |
| s: torch.Tensor, | |
| reverse: bool = False, | |
| cu_seqlens: torch.Tensor | None = None, | |
| scale: float = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| ) -> torch.Tensor: | |
| if head_first: | |
| B, H, T = s.shape | |
| else: | |
| B, T, H = s.shape | |
| N = len(cu_seqlens) - 1 if cu_seqlens is not None else B | |
| z = torch.empty_like(s, dtype=output_dtype or s.dtype) | |
| grid = (N * H,) | |
| chunk_global_cumsum_scalar_kernel[grid]( | |
| s=s, | |
| o=z, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| T=T, | |
| B=B, | |
| H=H, | |
| HEAD_FIRST=head_first, | |
| REVERSE=reverse, | |
| ) | |
| return z | |
| def chunk_global_cumsum_vector( | |
| s: torch.Tensor, | |
| reverse: bool = False, | |
| cu_seqlens: torch.Tensor | None = None, | |
| scale: float = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| ) -> torch.Tensor: | |
| if head_first: | |
| B, H, T, S = s.shape | |
| else: | |
| B, T, H, S = s.shape | |
| N = len(cu_seqlens) - 1 if cu_seqlens is not None else B | |
| BS = min(32, triton.next_power_of_2(S)) | |
| z = torch.empty_like(s, dtype=output_dtype or s.dtype) | |
| grid = (triton.cdiv(S, BS), N * H) | |
| chunk_global_cumsum_vector_kernel[grid]( | |
| s=s, | |
| o=z, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| T=T, | |
| B=B, | |
| H=H, | |
| S=S, | |
| BS=BS, | |
| HEAD_FIRST=head_first, | |
| REVERSE=reverse, | |
| ) | |
| return z | |
| def chunk_global_cumsum( | |
| s: torch.Tensor, | |
| reverse: bool = False, | |
| cu_seqlens: torch.Tensor | None = None, | |
| scale: float = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| ) -> torch.Tensor: | |
| if cu_seqlens is not None: | |
| assert s.shape[0] == 1, "Only batch size 1 is supported when cu_seqlens are provided" | |
| if len(s.shape) == 3: | |
| return chunk_global_cumsum_scalar( | |
| s=s, | |
| reverse=reverse, | |
| cu_seqlens=cu_seqlens, | |
| scale=scale, | |
| head_first=head_first, | |
| output_dtype=output_dtype, | |
| ) | |
| elif len(s.shape) == 4: | |
| return chunk_global_cumsum_vector( | |
| s=s, | |
| reverse=reverse, | |
| cu_seqlens=cu_seqlens, | |
| scale=scale, | |
| head_first=head_first, | |
| output_dtype=output_dtype, | |
| ) | |
| else: | |
| raise ValueError( | |
| f"Unsupported input shape {s.shape}, " | |
| f"which should be [B, T, H]/[B, T, H, D] if `head_first=False` " | |
| f"or [B, H, T]/[B, H, T, D] otherwise", | |
| ) | |
| def chunk_local_cumsum( | |
| g: torch.Tensor, | |
| chunk_size: int, | |
| reverse: bool = False, | |
| scale: float = None, | |
| cu_seqlens: torch.Tensor | None = None, | |
| head_first: bool = False, | |
| output_dtype: torch.dtype | None = torch.float, | |
| chunk_indices: torch.LongTensor | None = None, | |
| **kwargs, | |
| ) -> torch.Tensor: | |
| if cu_seqlens is not None: | |
| assert g.shape[0] == 1, "Only batch size 1 is supported when cu_seqlens are provided" | |
| if len(g.shape) == 3: | |
| return chunk_local_cumsum_scalar( | |
| g=g, | |
| chunk_size=chunk_size, | |
| reverse=reverse, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| head_first=head_first, | |
| output_dtype=output_dtype, | |
| chunk_indices=chunk_indices, | |
| ) | |
| elif len(g.shape) == 4: | |
| return chunk_local_cumsum_vector( | |
| g=g, | |
| chunk_size=chunk_size, | |
| reverse=reverse, | |
| scale=scale, | |
| cu_seqlens=cu_seqlens, | |
| head_first=head_first, | |
| output_dtype=output_dtype, | |
| chunk_indices=chunk_indices, | |
| ) | |
| else: | |
| raise ValueError( | |
| f"Unsupported input shape {g.shape}, " | |
| f"which should be (B, T, H, D) if `head_first=False` " | |
| f"or (B, H, T, D) otherwise", | |
| ) | |