mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-10-07 04:45:44 +00:00
Some checks failed
SqlStore Integration Tests / test-postgres (3.13) (push) Failing after 1s
SqlStore Integration Tests / test-postgres (3.12) (push) Failing after 0s
Integration Auth Tests / test-matrix (oauth2_token) (push) Failing after 1s
Integration Tests (Replay) / Integration Tests (, , , client=, ) (push) Failing after 3s
Python Package Build Test / build (3.12) (push) Failing after 1s
Test External Providers Installed via Module / test-external-providers-from-module (venv) (push) Has been skipped
Test Llama Stack Build / generate-matrix (push) Successful in 4s
Test Llama Stack Build / build-custom-container-distribution (push) Failing after 2s
Vector IO Integration Tests / test-matrix (push) Failing after 4s
Python Package Build Test / build (3.13) (push) Failing after 2s
Test Llama Stack Build / build-ubi9-container-distribution (push) Failing after 3s
Test Llama Stack Build / build-single-provider (push) Failing after 4s
API Conformance Tests / check-schema-compatibility (push) Successful in 10s
Test Llama Stack Build / build (push) Failing after 2s
Test External API and Providers / test-external (venv) (push) Failing after 4s
Unit Tests / unit-tests (3.12) (push) Failing after 4s
Unit Tests / unit-tests (3.13) (push) Failing after 5s
UI Tests / ui-tests (22) (push) Successful in 39s
Pre-commit / pre-commit (push) Successful in 1m22s
# What does this PR do? WARNING 2025-10-06 12:01:45,137 root:266 uncategorized: Unknown logging category: tokenizer_utils. Falling back to default 'root' level: 20 ## Test Plan
40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
# All rights reserved.
|
|
#
|
|
# This source code is licensed under the terms described in the LICENSE file in
|
|
# the root directory of this source tree.
|
|
|
|
import base64
|
|
from pathlib import Path
|
|
|
|
from llama_stack.log import get_logger
|
|
|
|
logger = get_logger(__name__, "models")
|
|
|
|
|
|
def load_bpe_file(model_path: Path) -> dict[bytes, int]:
|
|
"""
|
|
Load BPE file directly and return mergeable ranks.
|
|
|
|
Args:
|
|
model_path (Path): Path to the BPE model file.
|
|
|
|
Returns:
|
|
dict[bytes, int]: Dictionary mapping byte sequences to their ranks.
|
|
"""
|
|
mergeable_ranks = {}
|
|
|
|
with open(model_path, encoding="utf-8") as f:
|
|
content = f.read()
|
|
|
|
for line in content.splitlines():
|
|
if not line.strip(): # Skip empty lines
|
|
continue
|
|
try:
|
|
token, rank = line.split()
|
|
mergeable_ranks[base64.b64decode(token)] = int(rank)
|
|
except Exception as e:
|
|
logger.warning(f"Failed to parse line '{line}': {e}")
|
|
continue
|
|
|
|
return mergeable_ranks
|