Skip to content

Commit 2557972

Browse files
committed
Rename the serving model to KerasHubVllmModel
1 parent cd7617f commit 2557972

6 files changed

Lines changed: 14 additions & 10 deletions

File tree

keras_hub/src/vllm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
tpu-inference's native flax/nnx path. This package provides the serving
55
context, the paged-attention bridge, the vLLM tokenizer (the preset's own
66
KerasHub 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`)
88
lives in tpu-inference.
99
"""
1010

keras_hub/src/vllm/attention.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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)`.

keras_hub/src/vllm/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
44
with vLLM by tpu-inference's plugin hook) publishes this
55
context around each forward step with ``vllm_context_scope``, which restores
66
the prior state on exit even when the forward raises, all on one thread.

keras_hub/src/vllm/hf_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
``"KerasHubForCausalLM"``.
88
99
This 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
1111
class (the real KerasHub backbone on the flax/nnx path); this object only
1212
carries the dims vLLM reads for KV-cache profiling, which
1313
``setup_vllm_model`` fills from each preset's own config.

keras_hub/src/vllm/keras_hub_for_causal_lm.py renamed to keras_hub/src/vllm/keras_hub_vllm_model.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
44
tpu-inference's model registry (and vLLM's) by tpu-inference's plugin hook,
55
so the native `flax_nnx` loader resolves it by architecture name like any
66
other model. It is only ever instantiated on the serving path, where flax
@@ -24,12 +24,16 @@
2424
from 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

keras_hub/src/vllm/registry.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Registry module for Keras Hub to vLLM Integration.
33
44
Materializes 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

88
import inspect
@@ -48,7 +48,7 @@
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

5454
def _normalize_dtype(dtype):

0 commit comments

Comments
 (0)