-
Notifications
You must be signed in to change notification settings - Fork 0
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
Pull in from upstream #10
Pull in from upstream #10
Conversation
…pSpeed into feature/profile
Reviewer's Guide by SourceryThis pull request implements several changes to improve code quality, performance, and functionality across multiple files in the Megatron-DeepSpeed project. The changes include code refactoring, bug fixes, and the addition of new features. Updated class diagram for GPTDataset and related classesclassDiagram
class GPTDataset {
+__init__(name, data_prefix, documents, indexed_dataset, splits_string, num_samples, seq_length, seed, return_doc_ids, data_cache_path)
+__len__() int
+__getitem__(idx) dict
}
class IndexedDataset {
+__init__(path)
+read_index(path)
+read_data(path)
+check_index(i)
+__getitem__(idx)
+size(index) int
+exists(path) bool
}
class BlendableDataset {
+__init__(datasets, weights, size, data_cache_path)
+_build_indices()
}
class DatasetBuilder {
+__init__(prefix, corpus, data_impl, splits_string, num_samples, seq_length, seed, skip_warmup, return_doc_ids, data_cache_path, name)
+Build()
}
GPTDataset --> IndexedDataset
BlendableDataset --> DatasetBuilder
Updated class diagram for MMapIndexedDataset and related classesclassDiagram
class MMapIndexedDataset {
+__init__(path, skip_warmup)
+__getitem__(idx)
+get(idx, offset, length)
+exists(path) bool
}
class MMapIndexedDatasetBuilder {
+__init__(out_file, dtype)
+add_item(tensor)
+add_doc(tensor, sizes)
+merge_file_(another_file)
+finalize(index_file)
}
MMapIndexedDatasetBuilder --> MMapIndexedDataset
MMapIndexedDataset --> IndexedDataset
class IndexedDataset {
+__init__(path)
+read_index(path)
+read_data(path)
+check_index(i)
+__getitem__(idx)
+size(index) int
+exists(path) bool
}
Updated class diagram for logging utilitiesclassDiagram
class Logger {
+get_logger(name, level, rank_zero_only) Logger
}
class Profile {
+log(func)
+log_init(func)
+iter(func, iter_name)
+__enter__()
+__exit__(type, value, traceback)
+update(epoch, step, image_idx, image_size, args)
+flush()
+reset()
+log_static(func)
}
class dftracer {
+initialize_log(logfile, data_dir, process_id)
+get_time()
+enter_event()
+exit_event()
+log_event(name, cat, start_time, duration, string_args)
+finalize()
}
Logger --> Profile
Profile --> dftracer
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @saforem2 - I've reviewed your changes - here's some feedback:
Overall Comments:
- The logging improvements and configuration changes look good. Consider adding more explanatory comments for complex changes, especially in data loading and indexing code.
- We recommend conducting performance benchmarks to validate the impact of these changes, particularly for large-scale training scenarios.
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
except Exception: | ||
_DLIO_PROFILER_EXIST = False | ||
|
||
if _DLIO_PROFILER_EXIST: | ||
|
||
if _DFTRACER_EXIST: |
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.
issue (complexity): Consider implementing a factory pattern and dependency injection for profiling functionality.
The current implementation introduces unnecessary complexity through multiple conditional imports and complex class definitions for Profile and PerfTrace. To simplify and improve maintainability while preserving functionality, consider the following changes:
- Implement a factory pattern to create Profile and PerfTrace objects:
def create_profiler():
if _DFTRACER_EXIST:
from dftracer.logger import dftracer as PerfTrace, dft_fn as Profile, DFTRACER_ENABLE
return Profile, PerfTrace, DFTRACER_ENABLE
elif _DLIO_PROFILER_EXIST:
from dlio_profiler.logger import fn_interceptor as Profile, dlio_logger as PerfTrace
return Profile, PerfTrace, True
else:
return DummyProfile, DummyPerfTrace, False
class DummyProfile:
def __init__(self, *args, **kwargs):
pass
def __enter__(self):
pass
def __exit__(self, *args, **kwargs):
pass
def log(self, func):
return func
class DummyPerfTrace:
def initialize_log(self, *args, **kwargs):
pass
Profile, PerfTrace, PROFILER_ENABLED = create_profiler()
-
Simplify the dummy implementations by only including methods that are actually used in the codebase. This reduces unnecessary code while still providing a fallback when profiling libraries are unavailable.
-
Consider using dependency injection to further decouple the profiling functionality:
class CodeModule:
def __init__(self, profiler):
self.profiler = profiler
@profiler.log
def some_method(self):
# Method implementation
# Usage
profiler, _, _ = create_profiler()
module = CodeModule(profiler)
These changes will make the code more modular, easier to maintain, and simpler to extend with new profiling libraries in the future.
…into hzheng-data-fix
…tron-DeepSpeed into hzheng-data-fix
Pull in changes from [6acc370](6acc370) to [`megatron/utils.py`](https://github.com/argonne-lcf/Megatron-DeepSpeed)
Merge `alcf-tests` into `main`
PR @ argonne-lcf/Megatron-DeepSpeed/pull/63
Summary by Sourcery
Refactor dataset handling and logging mechanisms to improve code readability and maintainability. Enhance shell scripts for better configuration management and introduce sample shuffling in datasets. Update DeepSpeed configuration handling and add new test functionalities for dataset sample distribution.
Enhancements:
Build:
Tests: