Flint-NVFP4-FreeToken / install.sh
qualitymaterial's picture
Publish pinned experimental Flint FreeToken setup and validation results
f2f6c96 verified
Raw History Blame Contribute Delete
1.9 kB
#!/usr/bin/env bash
set -euo pipefail
ROOT="${FLINT_HOME:-$HOME/.local/share/flint-freetoken}"
export PATH="$HOME/.local/bin:$PATH"
command -v uv >/dev/null || { echo 'Install uv before running this script.'; exit 1; }
command -v git >/dev/null
mkdir -p "$ROOT"
PYTHON_BIN=$(uv python find "${FLINT_PYTHON:-3.12}")
PYTHON_BASE=$("$PYTHON_BIN" -c 'import sys; print(sys.base_prefix)')
if [[ "$PYTHON_BASE" == *' '* ]]; then
if [ ! -d "$ROOT/python-runtime" ]; then cp -a "$PYTHON_BASE" "$ROOT/python-runtime"; fi
PYTHON_BIN="$ROOT/python-runtime/bin/python3.12"
fi
uv venv --python "$PYTHON_BIN" "$ROOT/venv"
uv pip install --python "$ROOT/venv/bin/python" \
'freetoken[accel] @ https://github.com/FlashML-org/FreeToken/releases/download/nightly/freetoken-0.2.0%2Bg507a8bfa8-cp312-cp312-linux_x86_64.whl' \
'https://github.com/FlashML-org/FreeToken/releases/download/nightly/freetoken_kernel_cache-0.2.0%2Bcu130.g507a8bfa8-py3-none-linux_x86_64.whl' ninja
if [ ! -d "$ROOT/source/.git" ]; then
git clone --no-checkout https://github.com/FlashML-org/FreeToken.git "$ROOT/source"
fi
git -C "$ROOT/source" fetch origin 711a86ef11c67bbe6c69ff59370594f64c6ef1b8
git -C "$ROOT/source" checkout --detach 711a86ef11c67bbe6c69ff59370594f64c6ef1b8
FLINT_ROOT="$ROOT" "$ROOT/venv/bin/python" - <<'PY'
import os,pathlib,sysconfig
root=pathlib.Path(os.environ['FLINT_ROOT'])
installed=pathlib.Path(sysconfig.get_paths()['purelib'])/'freetoken'
for native in installed.rglob('*.so'):
dest=root/'source/python/freetoken'/native.relative_to(installed)
dest.parent.mkdir(parents=True,exist_ok=True)
if not dest.exists(): dest.symlink_to(native)
from huggingface_hub import hf_hub_download
hf_hub_download('RecursiveSI/flint-nvfp4-gguf','flint-nvfp4.gguf',revision='6ec43e19b565fc8d560e2d04985d7724f20673bf',local_dir=root/'model')
PY
printf 'Installed in %s. Run bash serve.sh from this package.\n' "$ROOT"