-
Notifications
You must be signed in to change notification settings - Fork 556
Update multimodal docs with new models #4148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
60 changes: 60 additions & 0 deletions
60
tests/end_to_end/tpu/qwen/moe/qwen3-omni-30b-a3b/1_test_qwen3_omni_30b_a3b.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This file is documentation for how to get started with Qwen3-Omni-30B-A3B. | ||
|
|
||
| # This file runs Step 1 on CPU. | ||
| # 1. Convert the HuggingFace checkpoint (bf16) to MaxText-compatible checkpoint (bf16): | ||
| # Unscanned format is used here as it is better suited for decoding. | ||
| # --- | ||
| # Example Usage: | ||
| # | ||
| # export HF_TOKEN=<your_hf_token> | ||
| # export BASE_OUTPUT_PATH=gs://your-gcs-bucket/qwen3-omni-30b-a3b_maxtext_ckpt | ||
| # bash tests/end_to_end/tpu/qwen/moe/qwen3-omni-30b-a3b/1_test_qwen3_omni_30b_a3b.sh | ||
| # --- | ||
|
|
||
| set -ex | ||
|
|
||
| export MODEL_NAME="${MODEL_NAME:-qwen3-omni-30b-a3b}" | ||
| export TOKENIZER_PATH="${TOKENIZER_PATH:-Qwen/Qwen3-Omni-30B-A3B-Instruct}" | ||
|
|
||
| # (Optional) Path to your local Hugging Face checkpoint | ||
| export HF_MODEL_PATH="${HF_MODEL_PATH:-}" | ||
|
|
||
| # Base output path for MaxText checkpoint. | ||
| export BASE_OUTPUT_PATH="${BASE_OUTPUT_PATH:-gs://your-gcs-bucket/qwen3-omni-30b-a3b_maxtext_ckpt}" | ||
|
|
||
| if [ -z "${HF_TOKEN}" ]; then | ||
| echo "Error: HF_TOKEN environment variable is not set. Please export your Hugging Face token." | ||
| echo "Example: export HF_TOKEN=hf_..." | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Strip trailing slash from base path to avoid malformed URIs | ||
| BASE_OUTPUT_PATH=${BASE_OUTPUT_PATH%/} | ||
| echo "Using BASE_OUTPUT_PATH = ${BASE_OUTPUT_PATH}" | ||
|
|
||
| # Install torch for checkpoint conversion | ||
| python3 -m pip install torch --index-url https://download.pytorch.org/whl/cpu | ||
|
|
||
| # Setup local HF path argument if one was provided | ||
| HF_LOCAL_ARG="" | ||
| if [ -n "${HF_MODEL_PATH}" ]; then | ||
| HF_LOCAL_ARG="hf_model_path=${HF_MODEL_PATH}" | ||
| fi | ||
|
|
||
| # --- | ||
| # Step 1: Checkpoint Conversion | ||
| # Convert HuggingFace checkpoint to MaxText unscanned format (better for decoding). | ||
| # use_multimodal=true is required to include vision/audio encoder weights. | ||
| # --- | ||
| JAX_PLATFORMS=cpu python3 -m maxtext.checkpoint_conversion.to_maxtext src/maxtext/configs/base.yml \ | ||
| model_name=${MODEL_NAME} \ | ||
| base_output_directory=${BASE_OUTPUT_PATH}/unscanned \ | ||
| hf_access_token=${HF_TOKEN} \ | ||
| scan_layers=false \ | ||
| use_multimodal=true \ | ||
| --lazy_load_tensors=False \ | ||
| ${HF_LOCAL_ARG} | ||
|
|
||
|
|
||
85 changes: 85 additions & 0 deletions
85
tests/end_to_end/tpu/qwen/moe/qwen3-omni-30b-a3b/2_test_qwen3_omni_30b_a3b.sh
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This file is documentation for how to get started with Qwen3-Omni-30B-A3B. | ||
|
|
||
| # This file runs Step 2 on a v5p-8 TPU VM. | ||
| # 2. Run multimodal decoding: text+image, and text+video+audio. | ||
| # --- | ||
| # Example Usage: | ||
| # | ||
| # export HF_TOKEN=<your_hf_token> | ||
| # export BASE_OUTPUT_PATH=gs://your-gcs-bucket/qwen3-omni-30b-a3b_maxtext_ckpt | ||
| # bash tests/end_to_end/tpu/qwen/moe/qwen3-omni-30b-a3b/2_test_qwen3_omni_30b_a3b.sh | ||
| # --- | ||
|
|
||
| set -ex | ||
|
|
||
| export MODEL_NAME="${MODEL_NAME:-qwen3-omni-30b-a3b}" | ||
| export TOKENIZER_PATH="${TOKENIZER_PATH:-Qwen/Qwen3-Omni-30B-A3B-Instruct}" | ||
|
|
||
| if [ -z "${BASE_OUTPUT_PATH}" ]; then | ||
| # Non-Googlers please remember to point `BASE_OUTPUT_PATH` to GCS buckets that you own, this script uses internal buckets for testing. | ||
| # this bucket will store all the files generated by MaxText during a run | ||
| export BASE_OUTPUT_PATH=gs://runner-maxtext-logs/$(date +%Y-%m-%d-%H-%M) | ||
| echo "BASE_OUTPUT_PATH is not set" | ||
| fi | ||
| BASE_OUTPUT_PATH=${BASE_OUTPUT_PATH%/} | ||
| echo using BASE_OUTPUT_PATH = ${BASE_OUTPUT_PATH} | ||
|
|
||
| if [ -z "${HF_TOKEN}" ]; then | ||
| echo "Error: HF_TOKEN environment variable is not set. Please export your Hugging Face token." | ||
| echo "Example: export HF_TOKEN=hf_..." | ||
| exit 1 | ||
| fi | ||
|
|
||
| UNSCANNED_CKPT_PATH=gs://maxtext-model-checkpoints/qwen3-omni-30b-a3b/unscanned/0/items | ||
|
|
||
| # --- | ||
| # Step 2a: Multimodal Decode — text + image | ||
|
hengtaoguo marked this conversation as resolved.
|
||
| # Uses a test image from the repo assets. | ||
| # max_prefill_predict_length accounts for image tokens (~256) + text prompt tokens. | ||
| # --- | ||
| python3 -m maxtext.inference.decode ${MAXTEXT_CONFIGS_DIR:-${MAXTEXT_REPO_ROOT:-$PWD}/src/maxtext/configs}/base.yml \ | ||
| model_name=${MODEL_NAME} \ | ||
| tokenizer_path=${TOKENIZER_PATH} \ | ||
| tokenizer_type=huggingface \ | ||
| load_parameters_path=${UNSCANNED_CKPT_PATH} \ | ||
| hf_access_token=${HF_TOKEN} \ | ||
| per_device_batch_size=1 \ | ||
| run_name=qwen3_omni_decode_image \ | ||
| steps=1 \ | ||
| async_checkpointing=false \ | ||
| scan_layers=false \ | ||
| use_multimodal=true \ | ||
| prompt='Describe this image in one sentence.' \ | ||
| image_path='tests/assets/test_image.jpg' \ | ||
| max_prefill_predict_length=512 \ | ||
| max_target_length=542 \ | ||
| add_bos=false \ | ||
| attention=dot_product | ||
|
|
||
| # --- | ||
| # Step 2b: Multimodal Decode — text + video + audio | ||
| # Passes a video file and enables audio processing from the video track. | ||
| # max_prefill_predict_length is set higher to accommodate video frame tokens (~1126) | ||
| # plus audio tokens (~77) plus text prompt tokens. | ||
| # --- | ||
| python3 -m maxtext.inference.decode ${MAXTEXT_CONFIGS_DIR:-${MAXTEXT_REPO_ROOT:-$PWD}/src/maxtext/configs}/base.yml \ | ||
| model_name=${MODEL_NAME} \ | ||
| tokenizer_path=${TOKENIZER_PATH} \ | ||
| tokenizer_type=huggingface \ | ||
| load_parameters_path=${UNSCANNED_CKPT_PATH} \ | ||
| hf_access_token=${HF_TOKEN} \ | ||
| per_device_batch_size=1 \ | ||
| run_name=qwen3_omni_decode_video \ | ||
| steps=1 \ | ||
| async_checkpointing=false \ | ||
| scan_layers=false \ | ||
| use_multimodal=true \ | ||
| use_audio_in_video=true \ | ||
| prompt='What can you see and hear? Answer in one short sentence.' \ | ||
| video_path='tests/assets/test_video.mp4' \ | ||
| max_prefill_predict_length=1240 \ | ||
| max_target_length=1280 \ | ||
| add_bos=false \ | ||
| attention=dot_product | ||
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.