Skip to content

Commit 9fc4edd

Browse files
FindHaometa-codesync[bot]
authored andcommitted
Context Manager API Enhancement (#159)
Summary: ## Overview This PR enhances the `TritonParseManager` context manager by adding support for tensor blob storage configuration. ## Changes - **New Parameters Added to `TritonParseManager.__init__`**: - `enable_tensor_blob_storage` (bool, default: `False`): Enables tensor blob storage when set to `True` - `tensor_storage_quota` (int, optional, default: `None`): Sets storage quota in bytes for tensor blobs (default quota is 100GB when enabled) - **Implementation Details**: - The new parameters are properly stored as instance attributes - Parameters are passed through to the `init()` function in the `__enter__` method - Uses conditional inclusion: `tensor_storage_quota` is only passed to `init()` when explicitly set (not `None`) ## Impact - Backward compatible: All new parameters have default values - Provides users with fine-grained control over tensor blob storage behavior - Maintains clean API design by conditionally passing parameters only when needed Pull Request resolved: #159 Reviewed By: sfzhu93 Differential Revision: D84107701 Pulled By: FindHao fbshipit-source-id: d8918a948f7c14a820e5a701c1ef15079e30583d
1 parent c991a5e commit 9fc4edd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

tritonparse/context_manager.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ def __init__(
1717
self,
1818
enable_trace_launch=False,
1919
split_inductor_compilations=True,
20+
enable_tensor_blob_storage=False,
21+
tensor_storage_quota=None,
2022
**parse_kwargs,
2123
):
2224
"""
@@ -25,17 +27,28 @@ def __init__(
2527
Args:
2628
enable_trace_launch: Whether to enable trace launch
2729
split_inductor_compilations: Whether to split inductor compilations in the output
30+
enable_tensor_blob_storage: Whether to enable tensor blob storage
31+
tensor_storage_quota: Storage quota in bytes for tensor blobs (default: 100GB)
2832
**parse_kwargs: Additional keyword arguments to pass to unified_parse
2933
"""
3034
self.enable_trace_launch = enable_trace_launch
3135
self.split_inductor_compilations = split_inductor_compilations
36+
self.enable_tensor_blob_storage = enable_tensor_blob_storage
37+
self.tensor_storage_quota = tensor_storage_quota
3238
self.parse_kwargs = parse_kwargs
3339
self.dir_path = None
3440
self.output_link = None
3541

3642
def __enter__(self):
3743
self.dir_path = createUniqueTempDirectory()
38-
init(self.dir_path, enable_trace_launch=self.enable_trace_launch)
44+
init_kwargs = {
45+
"enable_trace_launch": self.enable_trace_launch,
46+
"enable_tensor_blob_storage": self.enable_tensor_blob_storage,
47+
}
48+
if self.tensor_storage_quota is not None:
49+
init_kwargs["tensor_storage_quota"] = self.tensor_storage_quota
50+
51+
init(self.dir_path, **init_kwargs)
3952
return self
4053

4154
def __exit__(self, exc_type, exc_val, exc_tb):

0 commit comments

Comments
 (0)