VllmSampler: mapped weight sync into tpu-inference's vLLM (torchax) model - #2014
Merged
Merged
Conversation
…odel On MODEL_IMPL_TYPE=vllm the tpu-inference runner keeps its weights in a flat dict in an internal, tp-dependent layout, so writing the mapped trainer weights into `transformer_state` directly is not enough. `update_params` now maps onto the runner model's canonical (vLLM TP=1) weight specs and hands the result to `VllmModelWrapper.load_canonical_weights`, which re-runs tpu-inference's own layout processing and resharding. The nnx path is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
VllmSampler.update_params: mapped weight sync into tpu-inference's vLLM (torchax) model implementation (MODEL_IMPL_TYPE=vllm), which is the path native Qwen3.5 runs on.On that path the runner keeps its weights in a flat
{name: jax.Array}dict in an internal, TP/MoE-backend-dependent layout, so writing mapped trainer weights intotransformer_statedirectly is not enough.update_paramsnow:preprocess_src_state+transfer_state_with_mappings, but against the runner model's canonical weight specs (VllmModelWrapper.canonical_weight_specs(state): vLLM's TP=1 parameter names/shapes) withreshard_fn=None;VllmModelWrapper.load_canonical_weights(weights, state), which re-runs tpu-inference's own layout processing and resharding in place.The nnx path is unchanged. The torchax path is detected by
isinstance(runner.state, dict)plus the presence ofload_canonical_weightson the runner model.Also:
_vllm_confignow merges the caller'sadditional_config["sharding"]["sharding_strategy"](e.g. tpu-inference'sattn_dp_size) instead of overwriting it, so production sharding settings can be passed through the sampler.Testing
End to end on v7x-8 with MaxText Qwen3.5-35B-A3B (bf16) →
update_params→ tpu-inference torchax model started from random weights: all 613 weight tensors bit-identical to the HF-loaded model, greedy generations 4/4 identical to the in-process HF-weight reference.update_paramstakes ~150 s on the first call (JIT of the preprocess and processing), HBM returns to 28.6 GiB/device.Also validated with the production Qwen3.5 sampler configuration passed through
VllmConfig(TP=8,enable_expert_parallel,enable_dp_attention=Truewithadditional_config={"sharding": {"sharding_strategy": {"attn_dp_size": 4}}}, prefix caching, async scheduling, chunked prefill): 4/4 identical generations after the sync.Companion PRs: vllm-project/tpu-inference#3477 (
load_canonical_weights), AI-Hypercomputer/maxtext#5034 (Qwen3.5 mapping withpreprocess_src_state).