Show HN: TurboQuant-WASM – 브라우저에서 Google의 vector quantization

발행: (2026년 4월 4일 PM 11:53 GMT+9)
4 분 소요

Source: Hacker News

CI
npm
gzip size
license

브라우저와 Node.js용 실험적인 WASM + relaxed SIMD 빌드인 botirk38/turboquant 입니다.

이 프로젝트는 논문 “TurboQuant: Online Vector Quantization with Near-optimal Distortion Rate” (Google Research, ICLR 2026)를 기반으로 합니다.

Live Demo — 브라우저에서 실행되는 벡터 검색, 이미지 유사도, 그리고 3D Gaussian splatting 압축을 제공합니다.

추가된 내용

  • npm 패키지에 내장된 WASM — npm install turboquant-wasm
  • Relaxed SIMD@mulAdd FMA가 f32x4.relaxed_madd에 매핑됩니다
  • SIMD‑벡터화된 QJL 부호 패킹/언패킹 및 스케일링
  • TypeScript APITurboQuant.init() / encode() / decode() / dot()
  • Golden‑value 테스트 — 레퍼런스 Zig 구현과 바이트가 동일한 출력

브라우저 요구 사항

WASM 바이너리는 relaxed SIMD 명령어를 사용합니다:

런타임최소 버전
Chrome114+
Firefox128+
Safari18+
Node.js20+

빠른 시작

import { TurboQuant } from "turboquant-wasm";

const tq = await TurboQuant.init({ dim: 1024, seed: 42 });

// 벡터 압축 (~4.5 bits/차원, ~6배 압축)
const compressed = tq.encode(myFloat32Array);

// 다시 디코딩
const decoded = tq.decode(compressed);

// 디코딩 없이 빠른 내적 계산
const score = tq.dot(queryVector, compressed);

tq.destroy();

API

class TurboQuant {
  /** 주어진 차원과 랜덤 시드로 양자화를 초기화합니다. */
  static async init(config: { dim: number; seed: number }): Promise;

  /** Float32Array를 압축된 Uint8Array로 인코딩합니다. */
  encode(vector: Float32Array): Uint8Array;

  /** 이전에 압축된 Uint8Array를 Float32Array로 디코딩합니다. */
  decode(compressed: Uint8Array): Float32Array;

  /** 쿼리 벡터와 압축된 벡터 사이의 내적을
   *  완전히 디코딩하지 않고 계산합니다. */
  dot(query: Float32Array, compressed: Uint8Array): number;

  /** 내부 리소스를 해제합니다. */
  destroy(): void;
}

빌드

# Full npm build (zig → wasm-opt → base64 embed → bun + tsc)
bun run build

# Build only the WASM module
bun run build:zig

# Run Zig tests
zig test -target aarch64-macos src/turboquant.zig

필요: Zig 0.15.2Bun.

품질

인코딩은 내적을 보존합니다 — 골든‑밸류 테스트와 왜곡 한계로 검증되었습니다:

  • MSE 차원이 증가함에 따라 감소합니다 (단위 벡터)
  • Bits/dim ≈ 4.5 (페이로드만, 22‑byte 헤더 제외)
  • Dot‑product preservationdim=128에서 단위 벡터에 대한 평균 절대 오차 < 1.0
  • Bit‑identical 동일한 입력 및 시드에 대해 botirk38/turboquant와 동일한 출력

크레딧

라이선스

MIT

0 조회
Back to Blog

관련 글

더 보기 »