-
Notifications
You must be signed in to change notification settings - Fork 391
feat(launcher): add DFlash support for DeepSeek-V4-Flash target model #1379
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
Open
ChenhanYu
wants to merge
6
commits into
main
Choose a base branch
from
chenhany/dflash-deepseek-v4-flash
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0b2f2b4
feat(launcher): add DFlash support for DeepSeek-V4-Flash target model
ChenhanYu 3ff58a9
chore: drop unverified SGLang files from PR
ChenhanYu 324436d
chore: drop DeepSeek-V4-Flash-DFlash examples from PR
ChenhanYu ffe00b6
docs: clarify draft model is randomly initialized in smoke test YAML
ChenhanYu c74afcb
add: DFlash draft checkpoint creator for self-contained smoke test
ChenhanYu 1b123da
fix(dflash): handle c128a_prefill_topk_indices=None in vLLM smoke test
ChenhanYu 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
| echo "=== pattern_matcher.py lines 305-325 ===" | ||
| sed -n '305,325p' /usr/local/lib/python3.12/dist-packages/torch/_inductor/pattern_matcher.py 2>/dev/null || echo "NOT FOUND" | ||
| echo "=== post_grad.py lines 345-375 ===" | ||
| sed -n '345,375p' /usr/local/lib/python3.12/dist-packages/torch/_inductor/fx_passes/post_grad.py 2>/dev/null || echo "NOT FOUND" | ||
| echo "=== post_grad.py lines 1240-1260 ===" | ||
| sed -n '1240,1260p' /usr/local/lib/python3.12/dist-packages/torch/_inductor/fx_passes/post_grad.py 2>/dev/null || echo "NOT FOUND" | ||
| echo "=== DONE ===" |
Large diffs are not rendered by default.
Oops, something went wrong.
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
40 changes: 40 additions & 0 deletions
40
tools/launcher/examples/deepseek-ai/DeepSeek-V4-Flash/create_dflash_draft.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,40 @@ | ||
| #!/bin/bash | ||
| # SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # | ||
| # Create a randomly-initialized DFlash draft checkpoint for smoke testing. | ||
| # | ||
| # Copies the bundled config.json + dflash.py into /scratchspace/dflash_draft, | ||
| # then uses AutoModel.from_config to initialize random weights and saves the | ||
| # checkpoint in HuggingFace format. | ||
| # | ||
| # Usage: sourced as task_0 in vllm_dflash_smoke_test_cw_dfw.yaml | ||
| # /scratchspace/dflash_draft is the output path consumed by task_1. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" | ||
| export OUT="/scratchspace/dflash_draft" | ||
|
|
||
| echo "=== Creating DFlash draft checkpoint at ${OUT} ===" | ||
|
|
||
| mkdir -p "${OUT}" | ||
| cp "${SCRIPT_DIR}/dflash_draft/config.json" "${OUT}/config.json" | ||
| cp "${SCRIPT_DIR}/dflash_draft/dflash.py" "${OUT}/dflash.py" | ||
|
|
||
| python3 - <<'EOF' | ||
| import os, sys, torch | ||
| sys.path.insert(0, os.environ.get("OUT", "/scratchspace/dflash_draft")) | ||
| from transformers import AutoConfig, AutoModel | ||
|
|
||
| out = os.environ.get("OUT", "/scratchspace/dflash_draft") | ||
| print(f"Initializing random DFlash draft model from config: {out}/config.json") | ||
| config = AutoConfig.from_pretrained(out, trust_remote_code=True) | ||
| model = AutoModel.from_config(config, trust_remote_code=True).to(torch.bfloat16) | ||
| param_count = sum(p.numel() for p in model.parameters()) | ||
| print(f" Parameters: {param_count / 1e6:.1f}M") | ||
| model.save_pretrained(out) | ||
| print(f" Saved to: {out}") | ||
| EOF | ||
|
|
||
| echo "=== DFlash draft checkpoint ready at ${OUT} ===" | ||
51 changes: 51 additions & 0 deletions
51
tools/launcher/examples/deepseek-ai/DeepSeek-V4-Flash/dflash_draft/config.json
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,51 @@ | ||
| { | ||
| "architectures": [ | ||
| "DFlashDraftModel" | ||
| ], | ||
| "attention_bias": false, | ||
| "attention_dropout": 0.0, | ||
| "auto_map": { | ||
| "AutoModel": "dflash.DFlashDraftModel" | ||
| }, | ||
| "dflash_config": { | ||
| "mask_token_id": 100279, | ||
| "target_layer_ids": [ | ||
| 6, | ||
| 13, | ||
| 20, | ||
| 27, | ||
| 34, | ||
| 41 | ||
| ], | ||
| "block_size": 16 | ||
| }, | ||
| "dtype": "bfloat16", | ||
| "eos_token_id": 1, | ||
| "head_dim": 128, | ||
| "hidden_act": "silu", | ||
| "hidden_size": 4096, | ||
| "initializer_range": 0.02, | ||
| "intermediate_size": 11008, | ||
| "layer_types": [ | ||
| "full_attention", | ||
| "full_attention", | ||
| "full_attention", | ||
| "full_attention" | ||
| ], | ||
| "max_position_embeddings": 131072, | ||
| "max_window_layers": 4, | ||
| "model_type": "qwen3", | ||
| "num_attention_heads": 32, | ||
| "num_hidden_layers": 4, | ||
| "num_key_value_heads": 8, | ||
| "num_target_layers": 43, | ||
| "pad_token_id": 1, | ||
| "rms_norm_eps": 1e-06, | ||
| "rope_scaling": null, | ||
| "rope_theta": 10000000.0, | ||
| "sliding_window": null, | ||
| "tie_word_embeddings": true, | ||
| "use_cache": true, | ||
| "use_sliding_window": false, | ||
| "vocab_size": 129280 | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: NVIDIA/Model-Optimizer
Length of output: 145
🏁 Script executed:
Repository: NVIDIA/Model-Optimizer
Length of output: 146
🏁 Script executed:
Repository: NVIDIA/Model-Optimizer
Length of output: 1878
🏁 Script executed:
Repository: NVIDIA/Model-Optimizer
Length of output: 11077
🏁 Script executed:
Repository: NVIDIA/Model-Optimizer
Length of output: 1470
Avoid executing checkpoint code just to initialize random weights.
This always enables remote-code execution via the
auto_mapfield in the config. Sincedflash.pyis already copied locally in the same script, instantiate the class directly from that file instead of going throughAutoConfig/AutoModel(..., trust_remote_code=True), or at minimum make the flag caller-controlled and default it off.Possible fix
🤖 Prompt for AI Agents