repo
stringlengths
7
90
file_url
stringlengths
81
315
file_path
stringlengths
4
228
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 14:38:15
2026-01-05 02:33:18
truncated
bool
2 classes
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/engines/mlx/__init__.py
src/exo/worker/engines/mlx/__init__.py
from typing import Any import mlx.core as mx import mlx.nn as nn from mlx_lm.models.cache import KVCache # These are wrapper functions to fix the fact that mlx is not strongly typed in the same way that EXO is. # For example - MLX has no guarantee of the interface that nn.Module will expose. But we need a guarantee t...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/engines/mlx/cache.py
src/exo/worker/engines/mlx/cache.py
# type: ignore # TODO: Fix this file, including types! from copy import deepcopy from typing import Callable import mlx.core as mx from mlx_lm import stream_generate from mlx_lm.models.cache import _BaseCache, trim_prompt_cache from mlx_lm.tokenizer_utils import TokenizerWrapper from exo.worker.engines.mlx import Mod...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/engines/mlx/auto_parallel.py
src/exo/worker/engines/mlx/auto_parallel.py
from abc import ABC, abstractmethod from functools import partial from inspect import signature from typing import TYPE_CHECKING, Callable, Protocol, cast import mlx.core as mx import mlx.nn as nn from mlx.nn.layers.distributed import ( shard_inplace, shard_linear, sum_gradients, ) from mlx_lm.models.cache...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/engines/mlx/generator/generate.py
src/exo/worker/engines/mlx/generator/generate.py
from typing import Any, Callable, Generator, cast, get_args import mlx.core as mx from mlx_lm import stream_generate from mlx_lm.models.cache import KVCache from mlx_lm.tokenizer_utils import TokenizerWrapper # from exo.engines.mlx.cache import KVPrefixCache from exo.shared.types.api import ChatCompletionMessage, Fin...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/engines/mlx/generator/__init__.py
src/exo/worker/engines/mlx/generator/__init__.py
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/download/shard_downloader.py
src/exo/worker/download/shard_downloader.py
from abc import ABC, abstractmethod from copy import copy from datetime import timedelta from pathlib import Path from typing import AsyncIterator, Callable from exo.shared.types.memory import Memory from exo.shared.types.models import ModelId, ModelMetadata from exo.shared.types.worker.shards import ( PipelineSha...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/download/download_utils.py
src/exo/worker/download/download_utils.py
import asyncio import hashlib import os import shutil import ssl import time import traceback from datetime import timedelta from pathlib import Path from typing import Callable, Literal from urllib.parse import urljoin import aiofiles import aiofiles.os as aios import aiohttp import certifi from loguru import logger ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/download/impl_shard_downloader.py
src/exo/worker/download/impl_shard_downloader.py
import asyncio from pathlib import Path from typing import AsyncIterator, Callable from exo.shared.models.model_cards import MODEL_CARDS from exo.shared.models.model_meta import get_model_meta from exo.shared.types.worker.shards import ( PipelineShardMetadata, ShardMetadata, ) from exo.worker.download.download...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/worker/download/huggingface_utils.py
src/exo/worker/download/huggingface_utils.py
import os from fnmatch import fnmatch from pathlib import Path from typing import Callable, Generator, Iterable import aiofiles import aiofiles.os as aios from loguru import logger from exo.shared.types.worker.shards import ShardMetadata def filter_repo_objects[T]( items: Iterable[T], *, allow_patterns:...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/routing/router.py
src/exo/routing/router.py
from copy import copy from itertools import count from math import inf from os import PathLike from pathlib import Path from typing import cast from anyio import ( BrokenResourceError, ClosedResourceError, create_task_group, sleep_forever, ) from anyio.abc import TaskGroup from exo_pyo3_bindings import...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/routing/connection_message.py
src/exo/routing/connection_message.py
from enum import Enum from exo_pyo3_bindings import ConnectionUpdate, ConnectionUpdateType from exo.shared.types.common import NodeId from exo.utils.pydantic_ext import CamelCaseModel """Serialisable types for Connection Updates/Messages""" class ConnectionMessageType(Enum): Connected = 0 Disconnected = 1 ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/routing/__init__.py
src/exo/routing/__init__.py
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/routing/topics.py
src/exo/routing/topics.py
from dataclasses import dataclass from enum import Enum from exo.routing.connection_message import ConnectionMessage from exo.shared.election import ElectionMessage from exo.shared.types.commands import ForwarderCommand from exo.shared.types.events import ( ForwarderEvent, ) from exo.utils.pydantic_ext import Came...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/routing/tests/test_event_buffer.py
src/exo/routing/tests/test_event_buffer.py
import pytest from exo.shared.types.events import Event, TestEvent from exo.utils.event_buffer import OrderedBuffer def make_indexed_event(idx: int) -> tuple[int, Event]: """Factory function to create a unique ForwarderEvent for a given index.""" return (idx, TestEvent()) @pytest.fixture def buffer() -> Or...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/reactive.py
src/exo/utils/reactive.py
""" Utilities for reactive variables """ from typing import Protocol class OnChange[T](Protocol): def __call__(self, old_value: T, new_value: T) -> None: ... class Reactive[T]: def __init__(self, initial_value: T, on_change: OnChange[T]): self._value = initial_value self._on_change = on_ch...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/channels.py
src/exo/utils/channels.py
import multiprocessing as mp from dataclasses import dataclass, field from math import inf from multiprocessing.synchronize import Event from queue import Empty, Full from types import TracebackType from typing import Self from anyio import ( CapacityLimiter, ClosedResourceError, EndOfStream, WouldBloc...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/fs.py
src/exo/utils/fs.py
import contextlib import os import pathlib import tempfile from typing import LiteralString type StrPath = str | os.PathLike[str] type BytesPath = bytes | os.PathLike[bytes] type StrOrBytesPath = str | bytes | os.PathLike[str] | os.PathLike[bytes] def delete_if_exists(filename: StrOrBytesPath) -> None: with cont...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/banner.py
src/exo/utils/banner.py
def print_startup_banner(port: int) -> None: """Print a prominent startup banner with API endpoint information.""" dashboard_url = f"http://localhost:{port}" banner = f""" ╔═══════════════════════════════════════════════════════════════════════╗ ║ ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/pydantic_ext.py
src/exo/utils/pydantic_ext.py
# pyright: reportAny=false, reportUnknownArgumentType=false, reportUnknownVariableType=false from typing import Any, Self from pydantic import BaseModel, ConfigDict, model_serializer, model_validator from pydantic.alias_generators import to_camel from pydantic_core.core_schema import ( SerializerFunctionWrapHandl...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/dashboard_path.py
src/exo/utils/dashboard_path.py
import os import sys from pathlib import Path from typing import cast def find_dashboard() -> Path: dashboard = ( _find_dashboard_in_env() or _find_dashboard_in_repo() or _find_dashboard_in_bundle() ) if not dashboard: raise FileNotFoundError( "Unable to locate ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/event_buffer.py
src/exo/utils/event_buffer.py
from loguru import logger class OrderedBuffer[T]: """ A buffer that resequences events to ensure their ordering is preserved. Currently this buffer doesn't raise any errors if an event is lost This buffer is NOT thread safe, and is designed to only be polled from one source at a time. """ ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/__init__.py
src/exo/utils/__init__.py
from typing import Any, Type from .phantom import PhantomData def ensure_type[T](obj: Any, expected_type: Type[T]) -> T: # type: ignore if not isinstance(obj, expected_type): raise TypeError(f"Expected {expected_type}, got {type(obj)}") # type: ignore return obj def todo[T]( msg: str = "This ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/phantom.py
src/exo/utils/phantom.py
class _PhantomData[*T]: """ Internal machinery of the phantom data - it stores nothing. """ type PhantomData[*T] = _PhantomData[*T] | None """ Allows you to use generics in functions without storing anything of that generic type. Just use `None` and you'll be fine """
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/tests/test_tagged.py
src/exo/utils/tests/test_tagged.py
import anyio import pytest from pydantic import BaseModel, TypeAdapter, ValidationError from exo.utils.pydantic_ext import TaggedModel def test_plain_union_prefers_first_member_when_shapes_are_identical(): class Foo1(BaseModel): x: int class Foo2(BaseModel): x: int # Base Pydantic behav...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/utils/tests/testing_mp.py
src/exo/utils/tests/testing_mp.py
import multiprocessing as mp import time import pytest from anyio import fail_after from loguru import logger from exo.utils.channels import MpReceiver, MpSender, mp_channel def foo(recv: MpReceiver[str]): expected = ["hi", "hi 2", "bye"] with recv as r: for item in r: assert item == exp...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/api.py
src/exo/master/api.py
import time from collections.abc import AsyncGenerator from typing import cast import anyio from anyio import create_task_group from anyio.abc import TaskGroup from fastapi import FastAPI, HTTPException from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import StreamingResponse from fastapi.stat...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/placement_utils.py
src/exo/master/placement_utils.py
from collections.abc import Generator from typing import TypeGuard, cast from loguru import logger from pydantic import BaseModel from exo.shared.topology import Topology from exo.shared.types.common import Host, NodeId from exo.shared.types.memory import Memory from exo.shared.types.models import ModelMetadata from ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/main.py
src/exo/master/main.py
from datetime import datetime, timedelta, timezone import anyio from anyio.abc import TaskGroup from loguru import logger from exo.master.placement import ( add_instance_to_placements, delete_instance, get_transition_events, place_instance, ) from exo.shared.apply import apply from exo.shared.types.co...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/__init__.py
src/exo/master/__init__.py
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/placement.py
src/exo/master/placement.py
import random from collections.abc import Mapping from copy import deepcopy from typing import Sequence from loguru import logger from exo.master.placement_utils import ( filter_cycles_by_memory, get_mlx_ibv_devices_matrix, get_mlx_jaccl_coordinators, get_mlx_ring_hosts_by_node, get_shard_assignme...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/tests/test_topology.py
src/exo/master/tests/test_topology.py
import pytest from exo.shared.topology import Topology from exo.shared.types.multiaddr import Multiaddr from exo.shared.types.profiling import ( MemoryPerformanceProfile, NodePerformanceProfile, SystemPerformanceProfile, ) from exo.shared.types.topology import Connection, ConnectionProfile, NodeId, NodeInf...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/tests/test_placement_utils.py
src/exo/master/tests/test_placement_utils.py
from typing import Callable import pytest from exo.master.placement_utils import ( filter_cycles_by_memory, get_hosts_from_subgraph, get_mlx_jaccl_coordinators, get_shard_assignments, get_smallest_cycles, ) from exo.shared.topology import Topology from exo.shared.types.common import Host, NodeId f...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/tests/conftest.py
src/exo/master/tests/conftest.py
from typing import Callable import pytest from exo.shared.types.common import NodeId from exo.shared.types.multiaddr import Multiaddr from exo.shared.types.profiling import ( MemoryPerformanceProfile, NodePerformanceProfile, SystemPerformanceProfile, ) from exo.shared.types.topology import Connection, Con...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/tests/test_placement.py
src/exo/master/tests/test_placement.py
from typing import Callable import pytest from loguru import logger from exo.master.placement import ( get_transition_events, place_instance, ) from exo.shared.topology import Topology from exo.shared.types.commands import PlaceInstance from exo.shared.types.common import CommandId, NodeId from exo.shared.typ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/master/tests/test_master.py
src/exo/master/tests/test_master.py
from datetime import datetime, timezone from typing import Sequence import anyio import pytest from loguru import logger from exo.master.main import Master from exo.routing.router import get_node_id_keypair from exo.shared.types.api import ChatCompletionMessage, ChatCompletionTaskParams from exo.shared.types.commands...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/election.py
src/exo/shared/election.py
from typing import Self import anyio from anyio import ( CancelScope, Event, create_task_group, get_cancelled_exc_class, ) from anyio.abc import TaskGroup from loguru import logger from exo.routing.connection_message import ConnectionMessage from exo.shared.types.commands import ForwarderCommand from ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/topology.py
src/exo/shared/topology.py
import contextlib from typing import Iterable import rustworkx as rx from pydantic import BaseModel, ConfigDict from exo.shared.types.common import NodeId from exo.shared.types.profiling import ConnectionProfile, NodePerformanceProfile from exo.shared.types.topology import Connection, NodeInfo class TopologySnapsho...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/constants.py
src/exo/shared/constants.py
import os import sys from pathlib import Path _EXO_HOME_ENV = os.environ.get("EXO_HOME", None) def _get_xdg_dir(env_var: str, fallback: str) -> Path: """Get XDG directory, prioritising EXO_HOME environment variable if its set. On non-Linux platforms, default to ~/.exo.""" if _EXO_HOME_ENV is not None: ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/apply.py
src/exo/shared/apply.py
import copy from collections.abc import Mapping, Sequence from datetime import datetime from loguru import logger from exo.shared.types.common import NodeId from exo.shared.types.events import ( ChunkGenerated, Event, IndexedEvent, InstanceCreated, InstanceDeleted, NodeCreated, NodeDownloa...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/logging.py
src/exo/shared/logging.py
import logging import sys from pathlib import Path from hypercorn import Config from hypercorn.logging import Logger as HypercornLogger from loguru import logger class InterceptLogger(HypercornLogger): def __init__(self, config: Config): super().__init__(config) assert self.error_logger #...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/__init__.py
src/exo/shared/__init__.py
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/test_node_id_persistence.py
src/exo/shared/tests/test_node_id_persistence.py
import contextlib import multiprocessing import os from multiprocessing import Event, Queue, Semaphore from multiprocessing.process import BaseProcess from multiprocessing.queues import Queue as QueueT from multiprocessing.synchronize import Event as EventT from multiprocessing.synchronize import Semaphore as Semaphore...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/conftest.py
src/exo/shared/tests/conftest.py
"""Pytest configuration and shared fixtures for shared package tests.""" import asyncio from typing import Generator import pytest from _pytest.logging import LogCaptureFixture from loguru import logger from exo.shared.types.memory import Memory from exo.shared.types.models import ModelId, ModelMetadata from exo.sha...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/test_xdg_paths.py
src/exo/shared/tests/test_xdg_paths.py
"""Tests for XDG Base Directory Specification compliance.""" import os import sys from pathlib import Path from unittest import mock def test_xdg_paths_on_linux(): """Test that XDG paths are used on Linux when XDG env vars are set.""" with ( mock.patch.dict( os.environ, { ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/__init__.py
src/exo/shared/tests/__init__.py
# Test package for shared utilities
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/test_election.py
src/exo/shared/tests/test_election.py
import pytest from anyio import create_task_group, fail_after, move_on_after from exo.routing.connection_message import ConnectionMessage, ConnectionMessageType from exo.shared.election import Election, ElectionMessage, ElectionResult from exo.shared.types.commands import ForwarderCommand, TestCommand from exo.shared....
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/test_state_serialization.py
src/exo/shared/tests/test_state_serialization.py
from exo.shared.types.common import NodeId from exo.shared.types.multiaddr import Multiaddr from exo.shared.types.state import State from exo.shared.types.topology import Connection def test_state_serialization_roundtrip() -> None: """Verify that State → JSON → State round-trip preserves topology.""" # --- b...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/tests/test_apply/test_apply_node_download.py
src/exo/shared/tests/test_apply/test_apply_node_download.py
from exo.shared.apply import apply_node_download_progress from exo.shared.tests.conftest import get_pipeline_shard_metadata from exo.shared.types.common import NodeId from exo.shared.types.events import NodeDownloadProgress from exo.shared.types.state import State from exo.shared.types.worker.downloads import DownloadC...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/models/model_cards.py
src/exo/shared/models/model_cards.py
from exo.shared.types.memory import Memory from exo.shared.types.models import ModelId, ModelMetadata from exo.utils.pydantic_ext import CamelCaseModel class ModelCard(CamelCaseModel): short_id: str model_id: ModelId name: str description: str tags: list[str] metadata: ModelMetadata MODEL_CA...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/models/model_meta.py
src/exo/shared/models/model_meta.py
from typing import Annotated import aiofiles import aiofiles.os as aios from huggingface_hub import model_info from loguru import logger from pydantic import BaseModel, Field from exo.shared.models.model_cards import MODEL_CARDS from exo.shared.types.memory import Memory from exo.shared.types.models import ModelId, M...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/multiaddr.py
src/exo/shared/types/multiaddr.py
import re from typing import ClassVar from pydantic import BaseModel, computed_field, field_validator class Multiaddr(BaseModel): address: str PATTERNS: ClassVar[list[str]] = [ r"^/ip4/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(/tcp/(\d{1,5}))?(/p2p/[A-Za-z0-9]+)?$", r"^/ip6/([0-9a-fA-F:]+)(/tcp/(...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/tasks.py
src/exo/shared/types/tasks.py
from enum import Enum from pydantic import Field from exo.shared.types.api import ChatCompletionTaskParams from exo.shared.types.common import CommandId, Id from exo.shared.types.worker.instances import BoundInstance, InstanceId from exo.shared.types.worker.runners import RunnerId from exo.shared.types.worker.shards ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/topology.py
src/exo/shared/types/topology.py
from exo.shared.types.common import NodeId from exo.shared.types.multiaddr import Multiaddr from exo.shared.types.profiling import ConnectionProfile, NodePerformanceProfile from exo.utils.pydantic_ext import CamelCaseModel class NodeInfo(CamelCaseModel): node_id: NodeId node_profile: NodePerformanceProfile | ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/api.py
src/exo/shared/types/api.py
import time from typing import Any, Literal from pydantic import BaseModel, Field, field_validator from pydantic_core import PydanticUseDefault from exo.shared.types.common import CommandId from exo.shared.types.models import ModelId, ModelMetadata from exo.shared.types.worker.instances import Instance, InstanceId, I...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/common.py
src/exo/shared/types/common.py
from typing import Self from uuid import uuid4 from pydantic import GetCoreSchemaHandler, field_validator from pydantic_core import core_schema from exo.utils.pydantic_ext import CamelCaseModel class Id(str): def __new__(cls, value: str | None = None) -> Self: return super().__new__(cls, value or str(uu...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/state.py
src/exo/shared/types/state.py
from collections.abc import Mapping, Sequence from datetime import datetime from typing import Any, cast from pydantic import ConfigDict, Field, field_serializer, field_validator from pydantic.alias_generators import to_camel from exo.shared.topology import Topology, TopologySnapshot from exo.shared.types.common impo...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/chunks.py
src/exo/shared/types/chunks.py
from enum import Enum from exo.utils.pydantic_ext import TaggedModel from .api import FinishReason from .models import ModelId class ChunkType(str, Enum): Token = "Token" Image = "Image" class BaseChunk(TaggedModel): idx: int model: ModelId class TokenChunk(BaseChunk): text: str token_id...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/memory.py
src/exo/shared/types/memory.py
from math import ceil from typing import Self from exo.utils.pydantic_ext import CamelCaseModel class Memory(CamelCaseModel): in_bytes: int = 0 @classmethod def from_bytes(cls, val: int) -> Self: """Construct a new Memory object from a number of bytes""" return cls(in_bytes=val) @pr...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/models.py
src/exo/shared/types/models.py
from pydantic import PositiveInt from exo.shared.types.common import Id from exo.shared.types.memory import Memory from exo.utils.pydantic_ext import CamelCaseModel class ModelId(Id): pass class ModelMetadata(CamelCaseModel): model_id: ModelId pretty_name: str storage_size: Memory n_layers: Pos...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/commands.py
src/exo/shared/types/commands.py
from pydantic import Field from exo.shared.types.api import ChatCompletionTaskParams from exo.shared.types.common import CommandId, NodeId from exo.shared.types.models import ModelMetadata from exo.shared.types.worker.instances import Instance, InstanceId, InstanceMeta from exo.shared.types.worker.shards import Shardi...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/events.py
src/exo/shared/types/events.py
from datetime import datetime from pydantic import Field from exo.shared.topology import Connection, NodePerformanceProfile from exo.shared.types.chunks import GenerationChunk from exo.shared.types.common import CommandId, Id, NodeId, SessionId from exo.shared.types.profiling import MemoryPerformanceProfile from exo....
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/__init__.py
src/exo/shared/types/__init__.py
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/profiling.py
src/exo/shared/types/profiling.py
from typing import Self import psutil from exo.shared.types.memory import Memory from exo.utils.pydantic_ext import CamelCaseModel class MemoryPerformanceProfile(CamelCaseModel): ram_total: Memory ram_available: Memory swap_total: Memory swap_available: Memory @classmethod def from_bytes( ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/downloads.py
src/exo/shared/types/worker/downloads.py
from exo.shared.types.common import NodeId from exo.shared.types.memory import Memory from exo.shared.types.worker.shards import ShardMetadata from exo.utils.pydantic_ext import CamelCaseModel, TaggedModel class DownloadProgressData(CamelCaseModel): total_bytes: Memory downloaded_bytes: Memory downloaded_...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/runner_response.py
src/exo/shared/types/worker/runner_response.py
from exo.shared.types.api import FinishReason from exo.utils.pydantic_ext import TaggedModel class BaseRunnerResponse(TaggedModel): pass class TokenizedResponse(BaseRunnerResponse): prompt_tokens: int class GenerationResponse(BaseRunnerResponse): text: str token: int # logprobs: list[float] | ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/instances.py
src/exo/shared/types/worker/instances.py
from enum import Enum from pydantic import model_validator from exo.shared.types.common import Host, Id, NodeId from exo.shared.types.worker.runners import RunnerId, ShardAssignments, ShardMetadata from exo.utils.pydantic_ext import CamelCaseModel, TaggedModel class InstanceId(Id): pass class InstanceMeta(str...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/resource_monitor.py
src/exo/shared/types/worker/resource_monitor.py
import asyncio from abc import ABC, abstractmethod from collections.abc import Coroutine from typing import Callable from exo.shared.types.profiling import ( MemoryPerformanceProfile, SystemPerformanceProfile, ) class ResourceCollector(ABC): @abstractmethod async def collect(self) -> SystemPerformanc...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/shards.py
src/exo/shared/types/worker/shards.py
from enum import Enum from pydantic import Field from exo.shared.types.models import ModelMetadata from exo.utils.pydantic_ext import TaggedModel class Sharding(str, Enum): Tensor = "Tensor" Pipeline = "Pipeline" class BaseShardMetadata(TaggedModel): """ Defines a specific shard of the model that ...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/src/exo/shared/types/worker/runners.py
src/exo/shared/types/worker/runners.py
from collections.abc import Mapping from pydantic import model_validator from exo.shared.types.common import Id, NodeId from exo.shared.types.models import ModelId from exo.shared.types.worker.shards import ShardMetadata from exo.utils.pydantic_ext import CamelCaseModel, TaggedModel class RunnerId(Id): pass c...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
exo-explore/exo
https://github.com/exo-explore/exo/blob/17f9b583a48def54c99d35a5815a4fdc3e81f090/rust/exo_pyo3_bindings/tests/test_python.py
rust/exo_pyo3_bindings/tests/test_python.py
import asyncio import pytest from exo_pyo3_bindings import Keypair, NetworkingHandle, NoPeersSubscribedToTopicError @pytest.mark.asyncio async def test_sleep_on_multiple_items() -> None: print("PYTHON: starting handle") h = NetworkingHandle(Keypair.generate_ed25519()) ct = asyncio.create_task(_await_con...
python
Apache-2.0
17f9b583a48def54c99d35a5815a4fdc3e81f090
2026-01-04T14:40:59.780748Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/launch_openai_api_test_server.py
tests/launch_openai_api_test_server.py
""" Launch an OpenAI API server with multiple model workers. """ import os import argparse def launch_process(cmd): os.popen(cmd) if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("--multimodal", action="store_true", default=False) args = parser.parse_args() laun...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/test_openai_vision_api.py
tests/test_openai_vision_api.py
""" Test the OpenAI compatible server Launch: python3 launch_openai_api_test_server.py --multimodal """ import openai from fastchat.utils import run_cmd openai.api_key = "EMPTY" # Not support yet openai.base_url = "http://localhost:8000/v1/" def encode_image(image): import base64 from io import BytesIO ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/test_image_utils.py
tests/test_image_utils.py
""" Usage: python3 -m unittest tests.test_image_utils """ import base64 from io import BytesIO import os import unittest import numpy as np from PIL import Image from fastchat.utils import ( resize_image_and_return_image_in_bytes, image_moderation_filter, ) from fastchat.conversation import get_conv_template...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/test_openai_api.py
tests/test_openai_api.py
""" Test the OpenAI compatible server Launch: python3 launch_openai_api_test_server.py """ import warnings import openai from fastchat.utils import run_cmd openai.api_key = "EMPTY" # Not support yet openai.base_url = "http://localhost:8000/v1/" def test_list_models(): model_list = openai.models.list() na...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/test_cli.py
tests/test_cli.py
"""Test command line interface for model inference.""" import argparse import os from fastchat.utils import run_cmd def test_single_gpu(): models = [ "lmsys/vicuna-7b-v1.5", "lmsys/longchat-7b-16k", "lmsys/fastchat-t5-3b-v1.0", "meta-llama/Llama-2-7b-chat-hf", "THUDM/chatg...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/test_openai_langchain.py
tests/test_openai_langchain.py
# Usage: # python3 -m fastchat.serve.model_worker --model-path lmsys/vicuna-7b-v1.5 --model-names gpt-3.5-turbo,text-davinci-003,text-embedding-ada-002 # export OPENAI_API_BASE=http://localhost:8000/v1 # export OPENAI_API_KEY=EMPTY # wget https://raw.githubusercontent.com/hwchase17/langchain/v0.0.200/docs/modules/state...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/tests/load_test.py
tests/load_test.py
import argparse import time import threading from concurrent.futures import ThreadPoolExecutor import uuid import traceback import numpy as np from transformers import AutoTokenizer from litellm import completion def litellm_completion(args, tokenizer, image_url=None): try: if image_url: messa...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/conversation.py
fastchat/conversation.py
""" Conversation prompt templates. We kindly request that you import fastchat instead of copying this file if you wish to use it. If you have any changes in mind, please contribute back so the community can benefit collectively and continue to maintain these valuable templates. """ import base64 import dataclasses fr...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
true
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/constants.py
fastchat/constants.py
""" Global constants. """ from enum import IntEnum import os REPO_PATH = os.path.dirname(os.path.dirname(__file__)) # Survey Link URL (to be removed) #00729c # SURVEY_LINK = """<div style='text-align: left; margin: 20px 0;'> # <div style='display: inline-block; border: 2px solid #00729c; padding: 20px; padding-b...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/utils.py
fastchat/utils.py
""" Common utilities. """ from asyncio import AbstractEventLoop from io import BytesIO import base64 import json import logging import logging.handlers import os import platform import sys import time from typing import AsyncGenerator, Generator import warnings import requests from fastchat.constants import LOGDIR ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/__init__.py
fastchat/__init__.py
__version__ = "0.2.36"
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train.py
fastchat/train/train.py
# This code is based on tatsu-lab/stanford_alpaca. Below is the original copyright: # # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_with_template.py
fastchat/train/train_with_template.py
# This code is based on tatsu-lab/stanford_alpaca. Below is the original copyright: # # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/llama_xformers_attn_monkey_patch.py
fastchat/train/llama_xformers_attn_monkey_patch.py
""" Directly copied the code from https://raw.githubusercontent.com/oobabooga/text-generation-webui/main/modules/llama_attn_hijack.py and made some adjustments """ import logging import math from typing import Optional, Tuple import torch import transformers.models.llama.modeling_llama from torch import nn try: ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_mem.py
fastchat/train/train_mem.py
# Make it more memory efficient by monkey patching the LLaMA model with FlashAttn. # Need to call this before importing transformers. from fastchat.train.llama2_flash_attn_monkey_patch import ( replace_llama_attn_with_flash_attn, ) replace_llama_attn_with_flash_attn() from fastchat.train.train import train if _...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_baichuan.py
fastchat/train/train_baichuan.py
# This code is based on tatsu-lab/stanford_alpaca. Below is the original copyright: # # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_yuan2.py
fastchat/train/train_yuan2.py
# This code is based on tatsu-lab/stanford_alpaca. Below is the original copyright: # # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_lora_t5.py
fastchat/train/train_lora_t5.py
# Adapted from tatsu-lab@stanford_alpaca. Below is the original copyright: # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may ob...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_xformers.py
fastchat/train/train_xformers.py
# Make it more memory efficient by monkey patching the LLaMA model with xformers attention. # Need to call this before importing transformers. from fastchat.train.llama_xformers_attn_monkey_patch import ( replace_llama_attn_with_xformers_attn, ) replace_llama_attn_with_xformers_attn() from fastchat.train.train i...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_lora.py
fastchat/train/train_lora.py
# Usage: deepspeed train_lora.py --deepspeed <$PATH_TO_DEEPSPEED_CONFIG> # Adapted from tatsu-lab@stanford_alpaca. Below is the original copyright: # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you ma...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/llama2_flash_attn_monkey_patch.py
fastchat/train/llama2_flash_attn_monkey_patch.py
import warnings from typing import Optional, Tuple import torch from flash_attn import __version__ as flash_attn_version from flash_attn.bert_padding import pad_input, unpad_input from flash_attn.flash_attn_interface import ( flash_attn_func, flash_attn_varlen_kvpacked_func, ) from transformers.models.llama.mo...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/train_flant5.py
fastchat/train/train_flant5.py
# Adapted from tatsu-lab@stanford_alpaca. Below is the original copyright: # Copyright 2023 Rohan Taori, Ishaan Gulrajani, Tianyi Zhang, Yann Dubois, Xuechen Li # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may ob...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/train/llama_flash_attn_monkey_patch.py
fastchat/train/llama_flash_attn_monkey_patch.py
from typing import Optional, Tuple import warnings import torch from torch import nn import transformers from transformers.models.llama.modeling_llama import apply_rotary_pos_emb from flash_attn.flash_attn_interface import flash_attn_varlen_qkvpacked_func from flash_attn.bert_padding import unpad_input, pad_input d...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/convert_fp16.py
fastchat/model/convert_fp16.py
""" Usage: python3 -m fastchat.model.convert_fp16 --in in-folder --out out-folder """ import argparse from transformers import AutoTokenizer, AutoModelForCausalLM import torch def convert_fp16(in_checkpoint, out_checkpoint): tokenizer = AutoTokenizer.from_pretrained(in_checkpoint, use_fast=False) model = Aut...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_codet5p.py
fastchat/model/model_codet5p.py
import gc from threading import Thread import torch import transformers from transformers import ( GenerationConfig, StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer, ) @torch.inference_mode() def generate_stream_codet5p( model, tokenizer, params, device, context_len=20...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/upload_hub.py
fastchat/model/upload_hub.py
""" Upload weights to huggingface. Usage: python3 -m fastchat.model.upload_hub --model-path ~/model_weights/vicuna-13b --hub-repo-id lmsys/vicuna-13b-v1.3 """ import argparse import tempfile import torch from transformers import AutoTokenizer, AutoModelForCausalLM def upload_hub(model_path, hub_repo_id, component, ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_cllm.py
fastchat/model/model_cllm.py
import torch import gc import os import time import random from typing import Dict, Optional, Sequence, List, Tuple from transformers.cache_utils import Cache, DynamicCache from transformers import ( LlamaModel, LlamaForCausalLM, GenerationConfig, StoppingCriteria, StoppingCriteriaList, TextIte...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/model_registry.py
fastchat/model/model_registry.py
"""Additional information of the models.""" from collections import namedtuple, OrderedDict from typing import List ModelInfo = namedtuple("ModelInfo", ["simple_name", "link", "description"]) model_info = OrderedDict() def register_model_info( full_names: List[str], simple_name: str, link: str, description: s...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/make_delta.py
fastchat/model/make_delta.py
""" Make the delta weights by subtracting base weights. Usage: python3 -m fastchat.model.make_delta --base ~/model_weights/llama-13b --target ~/model_weights/vicuna-13b --delta ~/model_weights/vicuna-13b-delta --hub-repo-id lmsys/vicuna-13b-delta-v1.1 """ import argparse import torch from tqdm import tqdm from transf...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false
lm-sys/FastChat
https://github.com/lm-sys/FastChat/blob/587d5cfa1609a43d192cedb8441cac3c17db105d/fastchat/model/rwkv_model.py
fastchat/model/rwkv_model.py
import os from types import SimpleNamespace import warnings import torch os.environ["RWKV_JIT_ON"] = "1" os.environ["RWKV_CUDA_ON"] = "1" from rwkv.model import RWKV from rwkv.utils import PIPELINE, PIPELINE_ARGS class RwkvModel: def __init__(self, model_path): warnings.warn( "Experimental ...
python
Apache-2.0
587d5cfa1609a43d192cedb8441cac3c17db105d
2026-01-04T14:41:02.114326Z
false