File size: 1,487 Bytes
8d5c18f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env bash
# SPDX-License-Identifier: Apache-2.0
# Rebuild code/tt_qwen3_tts/server/prebuilt/libmks_<hash>.so: the host build of the device sampler
# (tt/mk_common/kernels/sampler_host.cpp + sampler.hpp, used by the ttnn-prefill handoff of mk_talker), compiled in the
# container image's own base (ubuntu:22.04 at the digest tt-model's Dockerfile pins), whose runtime has no compiler.
# <hash> = the first 16 hex digits of sha256(sampler.hpp + sampler_host.cpp), the name tt/mk_common/sampler_host.py
# looks for in its cache; tt_qwen3_tts.api.seed_sampler_lib copies the matching file there when g++ is missing.
# Run it from the bundle root after any change to those two sources (needs docker and the network for apt):
#   sg docker -c "bash code/scripts/build_sampler_lib.sh"
set -euo pipefail
K="$(cd "$(dirname "$0")/../tt_qwen3_tts/tt/mk_common/kernels" && pwd)"
OUT="$(cd "$(dirname "$0")/../tt_qwen3_tts/server/prebuilt" && pwd)"
H="$(cat "$K/sampler.hpp" "$K/sampler_host.cpp" | sha256sum | cut -c1-16)"
rm -f "$OUT"/libmks_*.so
docker run --rm -v "$K:/src:ro" -v "$OUT:/out" \
  docker.io/library/ubuntu:22.04@sha256:b000e69a50ff940390233025e7a337fb8469b509e2334fa4d018ac30f3e18cdb \
  bash -c "apt-get update -qq >/dev/null && apt-get install -y -qq --no-install-recommends g++ >/dev/null \
           && g++ -O2 -std=c++17 -shared -fPIC -o /out/libmks_$H.so /src/sampler_host.cpp \
           && chown $(id -u):$(id -g) /out/libmks_$H.so"
ls -la "$OUT/libmks_$H.so"