Skip to content

Commit 3003589

Browse files
authored
[Chore]: Add license for Dflash code (#1837)
### What does this PR do? Type of change: Chore / documentation (license compliance) The DFlash implementation in `modelopt/torch/speculative/plugins/` is adapted from [SpecForge](https://github.com/sgl-project/SpecForge) (MIT licensed). This PR adds the required third-party attribution per the [Copying code from other sources](https://github.com/NVIDIA/Model-Optimizer/blob/main/CONTRIBUTING.md#-copying-code-from-other-sources) guidance: - **`hf_dflash.py`** ← adapted from `specforge/core/dflash.py` - **`modeling_dflash.py`** ← adapted from `specforge/modeling/draft/dflash.py` Changes: - Add upstream attribution header (source link with commit hash + SpecForge MIT copyright/license notice) above the NVIDIA Apache-2.0 header in both files. - Update `SPDX-License-Identifier` to `Apache-2.0 AND MIT` in both files. - Add `Copyright (c) 2025 sgl-project` to the MIT section under *Third-Party Software Notices* in `LICENSE`. - Exclude both files from the `insert-license` pre-commit hook so the NVIDIA header is not auto-inserted above the upstream header. ### Usage N/A — no functional/API change (comments and license metadata only). ### Testing - `pre-commit run insert-license-py --files <both files>` → reports **Skipped** (files correctly excluded). - Verified `SPDX-License-Identifier: Apache-2.0 AND MIT` is present in both files and the upstream header precedes the NVIDIA header. ### Before your PR is "*Ready for review*" - Is this change backward compatible?: ✅ - If you copied code from any other sources or added a new PIP dependency, did you follow guidance in `CONTRIBUTING.md`: ✅ - Did you write any new necessary tests?: N/A - Did you update [Changelog](https://github.com/NVIDIA/Model-Optimizer/blob/main/CHANGELOG.rst)?: N/A - Did you get Claude approval on this PR?: ❌ ### Additional Information Upstream pinned at SpecForge commit `8ea5ca6`. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Updated third-party license notices to include an additional attribution. * Added license/header text to two Python modules for clearer provenance. * Adjusted the pre-commit configuration so those files are skipped by the license insertion check. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: h-guo18 <67671475+h-guo18@users.noreply.github.com>
1 parent 7e5bd88 commit 3003589

4 files changed

Lines changed: 47 additions & 2 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ repos:
112112
modelopt/torch/quantization/plugins/attention.py|
113113
modelopt/torch/sparsity/attention_sparsity/methods/vsa_utils.py|
114114
modelopt/torch/speculative/eagle/utils.py|
115+
modelopt/torch/speculative/plugins/hf_dflash.py|
116+
modelopt/torch/speculative/plugins/modeling_dflash.py|
115117
modelopt/torch/speculative/plugins/hf_medusa.py|
116118
modelopt/torch/utils/plugins/megatron_mmlu.py|
117119
examples/deepseek/deepseek_v3/quantize_to_nvfp4.py|

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ the following copyright holders, licensed under the MIT License:
246246
Copyright (c) 2020 Dan Hendrycks
247247
Copyright (c) 2023 Deep Cognition and Language Research (DeCLaRe) Lab
248248
Copyright (c) 2023 DeepSeek
249+
Copyright (c) 2025 sgl-project
249250

250251
Permission is hereby granted, free of charge, to any person obtaining a copy
251252
of this software and associated documentation files (the "Software"), to deal

modelopt/torch/speculative/plugins/hf_dflash.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
# Adapted from https://github.com/sgl-project/SpecForge/blob/8ea5ca6/specforge/core/dflash.py
2+
# Copyright (c) 2025 sgl-project
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
122
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2-
# SPDX-License-Identifier: Apache-2.0
23+
# SPDX-License-Identifier: Apache-2.0 AND MIT
324
#
425
# Licensed under the Apache License, Version 2.0 (the "License");
526
# you may not use this file except in compliance with the License.

modelopt/torch/speculative/plugins/modeling_dflash.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
# Adapted from https://github.com/sgl-project/SpecForge/blob/8ea5ca6/specforge/modeling/draft/dflash.py
2+
# Copyright (c) 2025 sgl-project
3+
#
4+
# Permission is hereby granted, free of charge, to any person obtaining a copy
5+
# of this software and associated documentation files (the "Software"), to deal
6+
# in the Software without restriction, including without limitation the rights
7+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
# copies of the Software, and to permit persons to whom the Software is
9+
# furnished to do so, subject to the following conditions:
10+
#
11+
# The above copyright notice and this permission notice shall be included in all
12+
# copies or substantial portions of the Software.
13+
#
14+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
# SOFTWARE.
21+
122
# SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2-
# SPDX-License-Identifier: Apache-2.0
23+
# SPDX-License-Identifier: Apache-2.0 AND MIT
324
#
425
# Licensed under the Apache License, Version 2.0 (the "License");
526
# you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)