Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Environment:Lm sys FastChat Python Core Dependencies

From Leeroopedia


Knowledge Sources
Domains Infrastructure, NLP
Last Updated 2026-02-07 04:00 GMT

Overview

Python 3.8+ environment with core web framework and NLP dependencies for running FastChat's base platform (API server, controller, CLI).

Description

This environment provides the minimum package set required to run any FastChat component. It is defined in `pyproject.toml` as the base dependency list and includes web frameworks (FastAPI, uvicorn, aiohttp), data handling (numpy, pydantic), tokenization (tiktoken), and utility libraries. Optional dependency groups (`model_worker`, `webui`, `train`, `llm_judge`) extend this base for specific use cases.

Usage

Use this environment for any FastChat operation. It is the mandatory prerequisite for running the controller, API server, Gradio web UI, model workers, training scripts, and evaluation tools. All other FastChat environments build on top of this base.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows Docker image uses Ubuntu 20.04
Python >= 3.8 Docker image uses Python 3.9; `functools.cache` used on 3.9+
Disk 500MB+ For package installation; model weights require additional storage

Dependencies

Core Packages (Always Installed)

  • `aiohttp` — Async HTTP client for worker communication
  • `fastapi` — API server framework
  • `httpx` — HTTP client library
  • `markdown2[all]` — Markdown processing
  • `nh3` — HTML sanitization
  • `numpy` — Numerical operations
  • `prompt_toolkit` >= 3.0.0 — CLI interface
  • `pydantic` >= 2.0.0, < 3 — Data validation (strict upper bound at v3)
  • `pydantic-settings` — Settings management
  • `psutil` — System resource monitoring
  • `requests` — HTTP requests
  • `rich` >= 10.0.0 — Rich terminal output
  • `shortuuid` — Short unique identifiers
  • `tiktoken` — OpenAI tokenizer for token counting
  • `uvicorn` — ASGI server

Optional: model_worker

  • `accelerate` >= 0.21 — HuggingFace model distribution
  • `peft` — LoRA/adapter model support
  • `sentencepiece` — Tokenizer for LLaMA-family models
  • `torch` — PyTorch (unpinned)
  • `transformers` >= 4.31.0 — HuggingFace model loading
  • `protobuf` — Protocol buffer support
  • `openai` — OpenAI SDK for API providers
  • `anthropic` — Anthropic SDK for API providers

Optional: webui

  • `gradio` >= 4.10 — Web UI framework
  • `plotly` — Interactive charts
  • `scipy` — Statistical functions for leaderboard

Optional: train

  • `einops` — Tensor operations
  • `flash-attn` >= 2.0 — Flash Attention (requires CUDA)
  • `wandb` — Weights & Biases experiment tracking

Optional: llm_judge

  • `openai` < 1 — Old OpenAI SDK (incompatible with model_worker's unpinned openai)
  • `anthropic` >= 0.3 — Anthropic SDK
  • `ray` — Distributed execution

Optional: dev

  • `black` == 23.3.0 — Code formatter (exact pin)
  • `pylint` == 2.8.2 — Linter (exact pin)

Credentials

No credentials required for the base environment. See Environment:Lm_sys_FastChat_API_Keys_And_Credentials for API key requirements.

Quick Install

# Base install
pip install fschat

# With model worker support
pip install "fschat[model_worker]"

# With web UI
pip install "fschat[model_worker,webui]"

# Full install (training + evaluation)
pip install "fschat[model_worker,webui,train,llm_judge]"

Code Evidence

Package name and version from `pyproject.toml:5-7`:

name = "fschat"
version = "0.2.36"
requires-python = ">=3.8"

Core dependencies from `pyproject.toml:15-19`:

dependencies = [
    "aiohttp", "fastapi", "httpx", "markdown2[all]", "nh3", "numpy",
    "prompt_toolkit>=3.0.0", "pydantic<3,>=2.0.0", "pydantic-settings", "psutil", "requests", "rich>=10.0.0",
    "shortuuid", "tiktoken", "uvicorn",
]

Python version compatibility in `fastchat/model/model_adapter.py:10-13`:

if sys.version_info >= (3, 9):
    from functools import cache
else:
    from functools import lru_cache as cache

Common Errors

Error Message Cause Solution
`ImportError: pydantic >= 2.0 required` Old pydantic installed `pip install "pydantic>=2.0.0,<3"`
`openai` version conflict between `model_worker` and `llm_judge` `llm_judge` pins `openai<1` while `model_worker` allows any version Install in separate virtual environments, or use `openai<1` if running MT-Bench
`ModuleNotFoundError: No module named 'fschat'` Package not installed `pip install fschat`

Compatibility Notes

  • llm_judge vs model_worker: The `llm_judge` extra pins `openai<1` (legacy SDK), which conflicts with the `model_worker` extra that allows any OpenAI version. These should be installed in separate virtual environments if both are needed.
  • Python 3.8: Minimum supported but not recommended. Python 3.9+ provides `functools.cache` natively and is used in the official Docker image.
  • Build system: Requires `setuptools >= 61.0` for PEP 621 metadata support.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment