npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kaminos/flux2-klein

v0.1.0

Published

FLUX.2 [klein] 4B text-to-image in the browser on WebGPU: text encoder, transformer and decoder as compute shaders.

Readme

@kaminos/flux2-klein

FLUX.2 [klein] 4B text-to-image in the browser on WebGPU. The Qwen3-4B text encoder, the 4-step transformer and the VAE decoder run as compute shaders on a device your application provides, using the Kaminos WebGPU inference kit.

Use

import { KleinPipeline } from '@kaminos/flux2-klein';

const adapter = await navigator.gpu.requestAdapter({ powerPreference: 'high-performance' });
const device = await adapter.requestDevice({
  requiredFeatures: ['shader-f16'],
  requiredLimits: {
    maxBufferSize: adapter.limits.maxBufferSize,
    maxStorageBufferBindingSize: adapter.limits.maxStorageBufferBindingSize,
  },
});

const klein = new KleinPipeline(device);               // hosted weights, Mint level
await klein.load((part, file, { loadedBytes, totalBytes }) => console.log(part, loadedBytes / totalBytes));
const image = await klein.generate({ prompt: 'a blue tank engine on a branch line', seed: 7, width: 512, height: 512 });
// image.rgba is a Uint8ClampedArray of width * height * 4 bytes
await klein.destroy();                                  // frees Klein's buffers; the device stays yours

Without a bundler

Browsers resolve the package names through an import map. For a page served next to its node_modules:

<script type="importmap">
{ "imports": {
  "@kaminos/flux2-klein": "./node_modules/@kaminos/flux2-klein/index.js",
  "@kaminos/webgpu-inference-kit/core": "./node_modules/@kaminos/webgpu-inference-kit/src/core.js"
} }
</script>
<script type="module" src="./app.js"></script>

A bundler such as Vite or esbuild resolves them from node_modules without a map.

Progress, previews and failures

load(onProgress) reports (part, file, { loadedBytes, totalBytes }) while weights download or come out of the cache. generate() takes onPhase(phase) (text, denoise, decode, and weights when low-memory mode swaps models), onStep(step, steps) and onPreview({ width, height, rgba, step, steps }), a rough image at an eighth of the output size after each step. steps is 4 by default; 3, 2 and 1 are faster and progressively rougher. A load from a base without the weights rejects with the missing file's URL; a size that is not a multiple of 16, or one too large for the device's buffer limits, rejects without disturbing the loaded pipeline.

Weights

By default the pipeline loads the hosted weights (KLEIN_HOSTED_WEIGHTS, about 3.2 GB, kept in the browser's Cache API after the first visit). Pass weightsBase to load from a mirror or a local server laid out the same way, and level to choose the transformer: mint (int4), weathered (3-bit) or off-the-rails (2-bit). kleinWeightUrls({ base, level }) returns the three weight roots; explicit textEncoderUrl, transformerUrl and vaeUrl options override them.

Releasing

destroy() waits for submitted work, then releases every buffer the pipeline owns: both models' weights and working memory, the decoder, the live-preview resources and the prompt cache. It does not destroy the device. A destroyed pipeline refuses further calls; create a new one to load again.

License

The code is MIT (see LICENSE). The weights it downloads are FLUX.2 [klein] 4B by Black Forest Labs and its Qwen3-4B text encoder by the Qwen team, both released under the Apache License 2.0, as are the converted weights.