File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44tpu-inference's native flax/nnx path. This package provides the serving
55context, the paged-attention bridge, the vLLM tokenizer (the preset's own
66KerasHub tokenizer, served via `tokenizer_mode="keras_hub"`), and the
7- `KerasHubLLM` entry point; the serving model class (`KerasHubForCausalLM `)
7+ `KerasHubLLM` entry point; the serving model class (`KerasHubVllmModel `)
88lives in tpu-inference.
99"""
1010
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ def vllm_paged_attention(
9797 value = ops .reshape (value , (- 1 , kv_heads * head_dim ))
9898
9999 # `paged_attention_func` comes from the serving model
100- # (keras_hub_for_causal_lm .py).
100+ # (keras_hub_vllm_model .py).
101101 # It takes only what an attention layer knows; engine details (the
102102 # attention metadata, the mesh) are already bound inside it. It returns
103103 # `(new_kv_cache, output)`.
Original file line number Diff line number Diff line change 11"""Thread-local context for passing vLLM metadata to Keras layers.
22
3- The serving model (``KerasHubForCausalLM `` in this package, registered
3+ The serving model (``KerasHubVllmModel `` in this package, registered
44with vLLM by tpu-inference's plugin hook) publishes this
55context around each forward step with ``vllm_context_scope``, which restores
66the prior state on exit even when the forward raises, all on one thread.
Original file line number Diff line number Diff line change 77``"KerasHubForCausalLM"``.
88
99This config is never used to build a model. tpu-inference's native loader routes
10- any config carrying ``keras_hub_preset`` to its ``KerasHubForCausalLM `` model
10+ any config carrying ``keras_hub_preset`` to its ``KerasHubVllmModel `` model
1111class (the real KerasHub backbone on the flax/nnx path); this object only
1212carries the dims vLLM reads for KV-cache profiling, which
1313``setup_vllm_model`` fills from each preset's own config.
Original file line number Diff line number Diff line change 11"""The serving model that runs a KerasHub `CausalLM` on vLLM's TPU backend.
22
3- `KerasHubForCausalLM ` lives here in keras-hub and is registered with
3+ `KerasHubVllmModel ` lives here in keras-hub and is registered with
44tpu-inference's model registry (and vLLM's) by tpu-inference's plugin hook,
55so the native `flax_nnx` loader resolves it by architecture name like any
66other model. It is only ever instantiated on the serving path, where flax
2424from keras_hub .src .vllm .context import vllm_context_scope
2525
2626
27- class KerasHubForCausalLM (_NnxModule ):
27+ class KerasHubVllmModel (_NnxModule ):
2828 """Serves a KerasHub `CausalLM` on tpu-inference's native JAX path.
2929
30+ Registered under the ``"KerasHubForCausalLM"`` architecture string
31+ (``KERAS_HUB_ARCHITECTURE``), which follows the HF naming convention
32+ configs use on the wire; the class itself carries the keras-hub-style
33+ name.
34+
3035 An adapter, not a conversion: it implements the model interface the
31- native `flax_nnx` runner drives (resolved by the `KerasHubForCausalLM`
32- architecture name through the standard model registry), reusing the
36+ native `flax_nnx` runner drives, reusing the
3337 preset's existing backbone and weights. Keras's NNX mode
3438 (`KERAS_NNX_ENABLED=true`) makes the backbone's variables nnx state, so
3539 the runner's `nnx.split`/`nnx.merge` machinery carries the weights with
Original file line number Diff line number Diff line change 22Registry module for Keras Hub to vLLM Integration.
33
44Materializes a model directory for `LLM(model="keras_hub:preset_name")` so that
5- tpu-inference's native flax/nnx path serves it via `KerasHubForCausalLM `.
5+ tpu-inference's native flax/nnx path serves it via `KerasHubVllmModel `.
66"""
77
88import inspect
4848# teaches transformers the `model_type`, and tpu-inference registers the
4949# architecture with vLLM. Both only carry KV dims for cache profiling; the real
5050# model is selected by `keras_hub_preset` and served by tpu-inference's
51- # `KerasHubForCausalLM ` model class.
51+ # `KerasHubVllmModel ` model class.
5252
5353
5454def _normalize_dtype (dtype ):
You can’t perform that action at this time.
0 commit comments