Repository navigation
Deprecate unused DeepSpeed features - #8490
Conversation
- Nebula - Compression - 1bit Adam - 1bit Lamb Signed-off-by: Olatunji Ruwase <[email protected]>
Signed-off-by: Olatunji Ruwase <[email protected]>
Signed-off-by: Olatunji Ruwase <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 55fe3ee9a3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| def get_eigenvalue_config(param_dict): | ||
| if get_quantize_enabled(param_dict): | ||
| quantize_training_params = param_dict.get('quantize_training') | ||
| if quantize_training_params is None: | ||
| return ( | ||
| EIGENVALUE_ENABLED_DEFAULT, | ||
| EIGENVALUE_VERBOSE_DEFAULT, | ||
| EIGENVALUE_MAX_ITER_DEFAULT, | ||
| EIGENVALUE_TOL_DEFAULT, | ||
| EIGENVALUE_STABILITY_DEFAULT, | ||
| EIGENVALUE_GAS_BOUNDARY_RESOLUTION_DEFAULT, | ||
| EIGENVALUE_LAYER_NAME_DEFAULT, | ||
| EIGENVALUE_LAYER_NUM_DEFAULT, | ||
| ) | ||
|
|
||
| assert not get_eigenvalue_enabled(quantize_training_params), "Eigenvalue based MoQ is temporarily disabled" | ||
| return ( | ||
| get_eigenvalue_enabled(quantize_training_params), | ||
| get_eigenvalue_verbose(quantize_training_params), | ||
| get_eigenvalue_max_iter(quantize_training_params), | ||
| get_eigenvalue_tol(quantize_training_params), | ||
| get_eigenvalue_stability(quantize_training_params), | ||
| get_eigenvalue_gas_boundary_resolution(quantize_training_params), | ||
| get_eigenvalue_layer_name(quantize_training_params), | ||
| get_eigenvalue_layer_num(quantize_training_params), | ||
| ) | ||
| else: | ||
| return ( | ||
| EIGENVALUE_ENABLED_DEFAULT, | ||
| EIGENVALUE_VERBOSE_DEFAULT, | ||
| EIGENVALUE_MAX_ITER_DEFAULT, | ||
| EIGENVALUE_TOL_DEFAULT, | ||
| EIGENVALUE_STABILITY_DEFAULT, | ||
| EIGENVALUE_GAS_BOUNDARY_RESOLUTION_DEFAULT, | ||
| EIGENVALUE_LAYER_NAME_DEFAULT, | ||
| EIGENVALUE_LAYER_NUM_DEFAULT, | ||
| ) | ||
| return ( | ||
| EIGENVALUE_ENABLED_DEFAULT, | ||
| EIGENVALUE_VERBOSE_DEFAULT, |
There was a problem hiding this comment.
Reject removed MoQ configurations instead of silently disabling them
When an existing configuration contains quantize_training or compression_training, this unconditional default now allows initialization to proceed with eigenvalue scheduling and compression disabled, so users following the still-published docs/_tutorials/MoQ-tutorial.md can run an entire experiment without the requested quantization. The remaining runtime tests also continue to accept these configuration keys; either reject the removed keys explicitly or remove the obsolete documentation and tests so this cannot silently change experimental results.
AGENTS.md reference: AGENTS.md:L21-L21
Useful? React with 👍 / 👎.
| /deepspeed/checkpoint/ @tjruwase | ||
| /deepspeed/comm/ @guanhuawang | ||
| /deepspeed/compression/ @tjruwase | ||
|
|
There was a problem hiding this comment.
Add the required sign-off to this commit
Commit 6bf6ee9878a78783ff6b0506dc6366a8be6f8d45 is a non-merge commit, but its message contains no Signed-off-by trailer, so it does not satisfy the repository's mandatory DCO-style commit requirement.
AGENTS.md reference: AGENTS.md:L8-L8
Useful? React with 👍 / 👎.
| @@ -15,14 +15,3 @@ FusedLamb (GPU) | |||
| ---------------------------- | |||
| .. autoclass:: deepspeed.ops.lamb.FusedLamb | |||
|
|
|||
There was a problem hiding this comment.
Remove the extra newline that fails pre-commit
This file ends with two newline characters; git diff --check 6bf6ee9^ 6bf6ee9 reports docs/code-docs/source/optimizers.rst:17: new blank line at EOF, and the configured end-of-file-fixer hook would modify it. The changed files therefore cannot have passed the required pre-commit invocation in their committed form.
AGENTS.md reference: AGENTS.md:L9-L10
Useful? React with 👍 / 👎.
MiCS is no longer a supported path; drop the optimizer, config fields, and tests so the deprecation matches the other retired features. Signed-off-by: Olatunji Ruwase <[email protected]>
Raise at parse time for nebula, compression, and MiCS keys so they are not silently ignored, and keep a compression.helper import shim for DeepSpeed-Chat. Signed-off-by: Olatunji Ruwase <[email protected]> Co-authored-by: Cursor <[email protected]>
55fe3ee to
1efd402
Compare
Follow up deepspeedai#8490 with further cleanup of the compression-related leftovers tracked in deepspeedai#8489: • Remove legacy 1-bit communication backends, CuPy compression helpers, and XPU packbits support, along with associated tests, setup extras, dependencies, and CI references. • Remove MoQ/eigenvalue runtime modules and engine/config wiring. Explicitly reject legacy eigenvalue blocks alongside the existing quantize_training rejection. • Remove the orphaned fake-quantization Python API, CUDA kernels/bindings, SUPA wrappers, and build dependencies. Preserve quantization used by ZeRO++ and inference, and update SUPA compatibility detection to use the retained quantize operator. • Clean up stale tutorials, navigation entries, monitoring documentation, image assets, the compression issue template, and CODEOWNERS references. --------- Signed-off-by: Hongwei Chen <[email protected]>
Remove the `sparse_gradients` flag Tracking: deepspeedai#8489 ## Summary - Remove the `sparse_gradients` config flag, which compressed **dense** `torch.nn.Embedding` / `EmbeddingBag` gradients into DeepSpeed's sparse reduction path. - Reject the removed key in `_REMOVED_TOP_LEVEL_CONFIG_KEYS` so a leftover `sparse_gradients` entry raises `DeepSpeedConfigError` instead of being silently ignored. - Drop the `sparse_tensor_module_names` bookkeeping and its checkpoint field, which existed only to serve that flag. - Sweep the leftover docs, tutorial output, and tests. - Tracking: deepspeedai#8489 ### What the flag did, and why it goes The flag's entire contribution was the dense-input branch of `SparseTensor.__init__`: ```python result = torch.sum(dense_tensor, dim=1) self.indices = result.nonzero().flatten() self.values = dense_tensor[self.indices] ``` It selected rows whose values **sum** to something non-zero, so a row like `[1.0, -1.0]` was discarded as empty even though it carries a real gradient. That silently dropped updates. `config-json.md` has described the feature as "essentially deprecated as we don't see use cases for it as much anymore" since deepspeedai#1418 (Sept 2021), and `deepspeed/runtime/zero/` contains no sparse handling at all, so the flag never worked together with ZeRO. ### What is deliberately NOT removed **Sparse gradient reduction still works at ZeRO stage 0.** A model that builds `torch.nn.Embedding(..., sparse=True)` itself produces a natively sparse gradient, and that still reaches the full DeepSpeed sparse path. Byte-identical in this PR: - `split_half_float_double_sparse` - `sparse_allreduce`, `sparse_allreduce_bucket`, `sparse_all_gather` - the `if grad_data.is_sparse:` guard and the `SparseTensor(param.grad)` call itself Simplified, but behavior-preserving for a sparse gradient: - `sparse_allreduce_no_retain` drops an `else` branch that densified and copied back. A `SparseTensor` is now only ever built from an already-sparse gradient, so `is_sparse` is always true and that branch was unreachable. - `SparseTensor.__init__` drops its dense-input branch in favor of an assertion, and `to_dense()` goes with it, since that removed `else` branch was its only caller. Both remaining sparse tests are kept and still cover that path. They already built `EmbeddingBag(..., sparse=True)`, so the only change to them is dropping the now-rejected `"sparse_gradients": true` line from their config. The single construction site is `engine.py`: ```python grad_data = param.grad.data if grad_data.is_sparse: grad_data = SparseTensor(param.grad) ``` Reached through `backward()` or `step()` → `allreduce_gradients()` → `buffered_allreduce_fallback()` → `_get_gradients_for_reduction()`. All of the gates in `allreduce_gradients` must pass, which in practice means: DeepCompile inactive, ZeRO stage 0, and a gradient accumulation boundary. ZeRO stages 1, 2, and 3 all divert to the ZeRO optimizer before that line. **Open question for review.** Because it only works at ZeRO stage 0, that whole path is a candidate for deprecation too. Doing so would remove `sparse_tensor.py`, `split_half_float_double_sparse`, the four `sparse_allreduce*` methods, `sparse_all_gather`, and the two remaining sparse tests. This PR deliberately leaves that decision open rather than bundling it. Three `SparseTensor` members now have no caller anywhere: `add()`, `sparse_size()`, and `type()`. They are independent of the removed flag and are left for a separate dead-code pass. ### Behavior changes | Before | After | |---|---| | `"sparse_gradients": true` compressed dense embedding gradients | raises `DeepSpeedConfigError` | | `"sparse_gradients": false` parsed and did nothing | raises `DeepSpeedConfigError` | | `Embedding(sparse=True)` reduced sparsely at ZeRO stage 0 | unchanged | | checkpoints carried a `sparse_tensor_module_names` field | no longer written | Presence of the key raises regardless of its value, matching how deepspeedai#8490 treats `mics_hierarchical_params_gather`, also a boolean whose default is `False`. A checkpoint written by an older release still loads. Its leftover `sparse_tensor_module_names` key is no longer recognized, so it now appears in the `client_state` returned by `load_checkpoint` rather than being filtered out. ## Test plan Run with `slurm_scripts/test_deprecate_sparse_gradients.slurm` (1 node, 2 GPUs). The job asserts that the branch under test is the tree actually imported before running anything. - [ ] `tests/unit/runtime/test_ds_config_dict.py` — the new `test_sparse_gradients_config_is_rejected`, plus the four existing removed-key tests as a regression check on `config.py` - [ ] `tests/unit/runtime/sparse_tensor/` — sparse reduction at ZeRO stage 0 still correct with the config key gone - [ ] `tests/unit/checkpoint/test_latest_checkpoint.py`, `tests/unit/checkpoint/test_lr_scheduler.py` — cover the edited `tests/unit/checkpoint/common.py` helper - [ ] CI unit / accelerator workflows on this PR ## Diffstat ``` deepspeed/runtime/config.py | 10 +-- deepspeed/runtime/constants.py | 4 - deepspeed/runtime/engine.py | 55 ++----------- deepspeed/runtime/sparse_tensor.py | 20 ++--- deepspeed/runtime/utils.py | 5 +- docs/_pages/config-json.md | 6 -- docs/_tutorials/cifar-10.md | 1 - tests/unit/checkpoint/common.py | 1 - tests/unit/checkpoint/test_sparse.py | 88 ---------------- tests/unit/runtime/sparse_tensor/test_csr.py | 55 ------------- .../sparse_tensor/test_averaging_sparse_gradients.py | 4 +- tests/unit/runtime/sparse_tensor/test_sparse_grads.py | 4 +- tests/unit/runtime/test_ds_config_dict.py | 10 +++ 13 files changed, 34 insertions(+), 229 deletions(-) ``` Two deleted test files asserted only on removed members: `test_sparse.py` on `sparse_tensor_module_names`, and `test_csr.py` on the dense constructor and `to_dense()`. Signed-off-by: pengdurice <[email protected]>
As part of deepspeedai#8489, this PR removes the stale `test_compression.py` entry from the HPU Gaudi2 unit-test list. The legacy compression test was removed in deepspeedai#8490, but the workflow still referenced it. This keeps the CI selection aligned with the current repository contents without changing runtime code. @sfc-gh-truwase, could you please review when convenient? Thank you. Signed-off-by: nathon-lee <[email protected]>
Summary
deepspeed.compressionlibrary, 1-bit Adam, 1-bit Lamb, 0/1 Adam, and MiCS ZeRO-3 sharding.recursive_getattr/recursive_setattrintodeepspeed/utils/module_utils.pyafter the compression helper was deleted.Test plan
MiCS_Initandmics_*config fields absenttests/unit/runtime/zero/test_zero_context.py(gathered params / partition)tests/unit/v1/zero/test_zero.py::TestZero3RepeatForwardLooptests/unit/v1/moe/test_autoep_unit.py::TestAutoEPConfigZeRO-3 compatibility gatesMade with Cursor