koichi12 commited on
Commit
7e7bbc5
·
verified ·
1 Parent(s): e278978

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/__init__.cpython-311.pyc +0 -0
  2. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_gpu_trace.cpython-311.pyc +0 -0
  3. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_memory_viz.cpython-311.pyc +0 -0
  4. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_sanitizer.cpython-311.pyc +0 -0
  5. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_utils.cpython-311.pyc +0 -0
  6. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/comm.cpython-311.pyc +0 -0
  7. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/error.cpython-311.pyc +0 -0
  8. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/gds.cpython-311.pyc +0 -0
  9. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/graphs.cpython-311.pyc +0 -0
  10. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/jiterator.cpython-311.pyc +0 -0
  11. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/nccl.cpython-311.pyc +0 -0
  12. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/nvtx.cpython-311.pyc +0 -0
  13. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/profiler.cpython-311.pyc +0 -0
  14. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/random.cpython-311.pyc +0 -0
  15. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/sparse.cpython-311.pyc +0 -0
  16. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/streams.cpython-311.pyc +0 -0
  17. .venv/lib/python3.11/site-packages/torch/cuda/__pycache__/tunable.cpython-311.pyc +0 -0
  18. .venv/lib/python3.11/site-packages/torch/cuda/amp/__init__.py +12 -0
  19. .venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/__init__.cpython-311.pyc +0 -0
  20. .venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/autocast_mode.cpython-311.pyc +0 -0
  21. .venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/common.cpython-311.pyc +0 -0
  22. .venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/grad_scaler.cpython-311.pyc +0 -0
  23. .venv/lib/python3.11/site-packages/torch/cuda/amp/autocast_mode.py +90 -0
  24. .venv/lib/python3.11/site-packages/torch/cuda/amp/common.py +11 -0
  25. .venv/lib/python3.11/site-packages/torch/cuda/amp/grad_scaler.py +38 -0
  26. .venv/lib/python3.11/site-packages/torch/nn/quantizable/__init__.py +1 -0
  27. .venv/lib/python3.11/site-packages/torch/nn/quantizable/modules/activation.py +10 -0
  28. .venv/lib/python3.11/site-packages/torch/nn/quantizable/modules/rnn.py +11 -0
  29. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/__init__.cpython-311.pyc +0 -0
  30. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/conv_expanded_weights.cpython-311.pyc +0 -0
  31. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/conv_utils.cpython-311.pyc +0 -0
  32. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/expanded_weights_utils.cpython-311.pyc +0 -0
  33. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/group_norm_expanded_weights.cpython-311.pyc +0 -0
  34. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/instance_norm_expanded_weights.cpython-311.pyc +0 -0
  35. .venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/layer_norm_expanded_weights.cpython-311.pyc +0 -0
  36. .venv/lib/python3.11/site-packages/torch/quantization/__init__.py +86 -0
  37. .venv/lib/python3.11/site-packages/torch/quantization/_numeric_suite.py +28 -0
  38. .venv/lib/python3.11/site-packages/torch/quantization/_numeric_suite_fx.py +26 -0
  39. .venv/lib/python3.11/site-packages/torch/quantization/_quantized_conversions.py +133 -0
  40. .venv/lib/python3.11/site-packages/torch/quantization/fake_quantize.py +32 -0
  41. .venv/lib/python3.11/site-packages/torch/quantization/fuse_modules.py +22 -0
  42. .venv/lib/python3.11/site-packages/torch/quantization/fuser_method_mappings.py +15 -0
  43. .venv/lib/python3.11/site-packages/torch/quantization/fx/__init__.py +15 -0
  44. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/__init__.cpython-311.pyc +0 -0
  45. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/_equalize.cpython-311.pyc +0 -0
  46. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/convert.cpython-311.pyc +0 -0
  47. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/fuse.cpython-311.pyc +0 -0
  48. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/fusion_patterns.cpython-311.pyc +0 -0
  49. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/graph_module.cpython-311.pyc +0 -0
  50. .venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/match_utils.cpython-311.pyc +0 -0
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (76.2 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_gpu_trace.cpython-311.pyc ADDED
Binary file (4.57 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_memory_viz.cpython-311.pyc ADDED
Binary file (37.4 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_sanitizer.cpython-311.pyc ADDED
Binary file (36.8 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/_utils.cpython-311.pyc ADDED
Binary file (2.18 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/comm.cpython-311.pyc ADDED
Binary file (492 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/error.cpython-311.pyc ADDED
Binary file (180 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/gds.cpython-311.pyc ADDED
Binary file (6.83 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/graphs.cpython-311.pyc ADDED
Binary file (29.4 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/jiterator.cpython-311.pyc ADDED
Binary file (7.96 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/nccl.cpython-311.pyc ADDED
Binary file (6.81 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/nvtx.cpython-311.pyc ADDED
Binary file (3.83 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/profiler.cpython-311.pyc ADDED
Binary file (4.17 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/random.cpython-311.pyc ADDED
Binary file (8.59 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/sparse.cpython-311.pyc ADDED
Binary file (181 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/streams.cpython-311.pyc ADDED
Binary file (13.2 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/__pycache__/tunable.cpython-311.pyc ADDED
Binary file (12.3 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/amp/__init__.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from .autocast_mode import autocast, custom_bwd, custom_fwd
2
+ from .common import amp_definitely_not_available
3
+ from .grad_scaler import GradScaler
4
+
5
+
6
+ __all__ = [
7
+ "amp_definitely_not_available",
8
+ "autocast",
9
+ "custom_bwd",
10
+ "custom_fwd",
11
+ "GradScaler",
12
+ ]
.venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (497 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/autocast_mode.cpython-311.pyc ADDED
Binary file (4.82 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/common.cpython-311.pyc ADDED
Binary file (604 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/amp/__pycache__/grad_scaler.cpython-311.pyc ADDED
Binary file (1.74 kB). View file
 
.venv/lib/python3.11/site-packages/torch/cuda/amp/autocast_mode.py ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: allow-untyped-defs
2
+ import functools
3
+ from typing import Any
4
+ from typing_extensions import deprecated
5
+
6
+ import torch
7
+
8
+
9
+ __all__ = ["autocast", "custom_fwd", "custom_bwd"]
10
+
11
+
12
+ class autocast(torch.amp.autocast_mode.autocast):
13
+ r"""See :class:`torch.autocast`.
14
+
15
+ ``torch.cuda.amp.autocast(args...)`` is deprecated. Please use ``torch.amp.autocast("cuda", args...)`` instead.
16
+ """
17
+
18
+ @deprecated(
19
+ "`torch.cuda.amp.autocast(args...)` is deprecated. "
20
+ "Please use `torch.amp.autocast('cuda', args...)` instead.",
21
+ category=FutureWarning,
22
+ )
23
+ def __init__(
24
+ self,
25
+ enabled: bool = True,
26
+ dtype: torch.dtype = torch.float16,
27
+ cache_enabled: bool = True,
28
+ ):
29
+ if torch._jit_internal.is_scripting():
30
+ self._enabled = enabled
31
+ self.device = "cuda"
32
+ self.fast_dtype = dtype
33
+ return
34
+ super().__init__(
35
+ "cuda", enabled=enabled, dtype=dtype, cache_enabled=cache_enabled
36
+ )
37
+
38
+ def __enter__(self):
39
+ if torch._jit_internal.is_scripting():
40
+ return self
41
+ return super().__enter__()
42
+
43
+ # TODO: discuss a unified TorchScript-friendly API for autocast
44
+ def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any): # type: ignore[override]
45
+ if torch._jit_internal.is_scripting():
46
+ return
47
+ return super().__exit__(exc_type, exc_val, exc_tb)
48
+
49
+ def __call__(self, func):
50
+ if torch._jit_internal.is_scripting():
51
+ return func
52
+ return super().__call__(func)
53
+
54
+
55
+ # Preserved only for BC reasons
56
+ @deprecated(
57
+ "`torch.cuda.amp.autocast_mode._cast(value, dtype)` is deprecated. "
58
+ "Please use `torch.amp.autocast_mode._cast(value, 'cuda', dtype)` instead.",
59
+ category=FutureWarning,
60
+ )
61
+ def _cast(value, dtype):
62
+ return torch.amp.autocast_mode._cast(value, "cuda", dtype)
63
+
64
+
65
+ @deprecated(
66
+ "`torch.cuda.amp.custom_fwd(args...)` is deprecated. "
67
+ "Please use `torch.amp.custom_fwd(args..., device_type='cuda')` instead.",
68
+ category=FutureWarning,
69
+ )
70
+ def custom_fwd(fwd=None, *, cast_inputs=None):
71
+ """
72
+ ``torch.cuda.amp.custom_fwd(args...)`` is deprecated. Please use
73
+ ``torch.amp.custom_fwd(args..., device_type='cuda')`` instead.
74
+ """
75
+ return functools.partial(torch.amp.custom_fwd, device_type="cuda")(
76
+ fwd=fwd, cast_inputs=cast_inputs
77
+ )
78
+
79
+
80
+ @deprecated(
81
+ "`torch.cuda.amp.custom_bwd(args...)` is deprecated. "
82
+ "Please use `torch.amp.custom_bwd(args..., device_type='cuda')` instead.",
83
+ category=FutureWarning,
84
+ )
85
+ def custom_bwd(bwd):
86
+ """
87
+ ``torch.cuda.amp.custom_bwd(args...)`` is deprecated. Please use
88
+ ``torch.amp.custom_bwd(args..., device_type='cuda')`` instead.
89
+ """
90
+ return functools.partial(torch.amp.custom_bwd, device_type="cuda")(bwd)
.venv/lib/python3.11/site-packages/torch/cuda/amp/common.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: allow-untyped-defs
2
+ from importlib.util import find_spec
3
+
4
+ import torch
5
+
6
+
7
+ __all__ = ["amp_definitely_not_available"]
8
+
9
+
10
+ def amp_definitely_not_available():
11
+ return not (torch.cuda.is_available() or find_spec("torch_xla"))
.venv/lib/python3.11/site-packages/torch/cuda/amp/grad_scaler.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing_extensions import deprecated
2
+
3
+ import torch
4
+
5
+ # We need to keep this unused import for BC reasons
6
+ from torch.amp.grad_scaler import OptState # noqa: F401
7
+
8
+
9
+ __all__ = ["GradScaler"]
10
+
11
+
12
+ class GradScaler(torch.amp.GradScaler):
13
+ r"""
14
+ See :class:`torch.amp.GradScaler`.
15
+ ``torch.cuda.amp.GradScaler(args...)`` is deprecated. Please use ``torch.amp.GradScaler("cuda", args...)`` instead.
16
+ """
17
+
18
+ @deprecated(
19
+ "`torch.cuda.amp.GradScaler(args...)` is deprecated. "
20
+ "Please use `torch.amp.GradScaler('cuda', args...)` instead.",
21
+ category=FutureWarning,
22
+ )
23
+ def __init__(
24
+ self,
25
+ init_scale: float = 2.0**16,
26
+ growth_factor: float = 2.0,
27
+ backoff_factor: float = 0.5,
28
+ growth_interval: int = 2000,
29
+ enabled: bool = True,
30
+ ) -> None:
31
+ super().__init__(
32
+ "cuda",
33
+ init_scale=init_scale,
34
+ growth_factor=growth_factor,
35
+ backoff_factor=backoff_factor,
36
+ growth_interval=growth_interval,
37
+ enabled=enabled,
38
+ )
.venv/lib/python3.11/site-packages/torch/nn/quantizable/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ from torch.nn.quantizable.modules import * # noqa: F403
.venv/lib/python3.11/site-packages/torch/nn/quantizable/modules/activation.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""Quantizable Modules.
3
+
4
+ This file is in the process of migration to `torch/ao/nn/quantizable`, and
5
+ is kept here for compatibility while the migration process is ongoing.
6
+ If you are adding a new entry/functionality, please, add it to the
7
+ appropriate file under the `torch/ao/nn/quantizable/modules`,
8
+ while adding an import statement here.
9
+ """
10
+ from torch.ao.nn.quantizable.modules.activation import MultiheadAttention
.venv/lib/python3.11/site-packages/torch/nn/quantizable/modules/rnn.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""Quantizable Modules.
3
+
4
+ This file is in the process of migration to `torch/ao/nn/quantizable`, and
5
+ is kept here for compatibility while the migration process is ongoing.
6
+ If you are adding a new entry/functionality, please, add it to the
7
+ appropriate file under the `torch/ao/nn/quantizable/modules`,
8
+ while adding an import statement here.
9
+ """
10
+
11
+ from torch.ao.nn.quantizable.modules.rnn import LSTM, LSTMCell
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (834 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/conv_expanded_weights.cpython-311.pyc ADDED
Binary file (3.53 kB). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/conv_utils.cpython-311.pyc ADDED
Binary file (14.1 kB). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/expanded_weights_utils.cpython-311.pyc ADDED
Binary file (9.36 kB). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/group_norm_expanded_weights.cpython-311.pyc ADDED
Binary file (5.03 kB). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/instance_norm_expanded_weights.cpython-311.pyc ADDED
Binary file (5.34 kB). View file
 
.venv/lib/python3.11/site-packages/torch/nn/utils/_expanded_weights/__pycache__/layer_norm_expanded_weights.cpython-311.pyc ADDED
Binary file (4.63 kB). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/__init__.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: allow-untyped-defs
2
+ from .fake_quantize import * # noqa: F403
3
+ from .fuse_modules import fuse_modules
4
+ from .fuser_method_mappings import * # noqa: F403
5
+ from .observer import * # noqa: F403
6
+ from .qconfig import * # noqa: F403
7
+ from .quant_type import * # noqa: F403
8
+ from .quantization_mappings import * # noqa: F403
9
+ from .quantize import * # noqa: F403
10
+ from .quantize_jit import * # noqa: F403
11
+ from .stubs import * # noqa: F403
12
+
13
+
14
+ def default_eval_fn(model, calib_data):
15
+ r"""
16
+ Default evaluation function takes a torch.utils.data.Dataset or a list of
17
+ input Tensors and run the model on the dataset
18
+ """
19
+ for data, target in calib_data:
20
+ model(data)
21
+
22
+
23
+ __all__ = [
24
+ "QuantWrapper",
25
+ "QuantStub",
26
+ "DeQuantStub",
27
+ # Top level API for eager mode quantization
28
+ "quantize",
29
+ "quantize_dynamic",
30
+ "quantize_qat",
31
+ "prepare",
32
+ "convert",
33
+ "prepare_qat",
34
+ # Top level API for graph mode quantization on TorchScript
35
+ "quantize_jit",
36
+ "quantize_dynamic_jit",
37
+ "_prepare_ondevice_dynamic_jit",
38
+ "_convert_ondevice_dynamic_jit",
39
+ "_quantize_ondevice_dynamic_jit",
40
+ # Top level API for graph mode quantization on GraphModule(torch.fx)
41
+ # 'fuse_fx', 'quantize_fx', # TODO: add quantize_dynamic_fx
42
+ # 'prepare_fx', 'prepare_dynamic_fx', 'convert_fx',
43
+ "QuantType", # quantization type
44
+ # custom module APIs
45
+ "get_default_static_quant_module_mappings",
46
+ "get_static_quant_module_class",
47
+ "get_default_dynamic_quant_module_mappings",
48
+ "get_default_qat_module_mappings",
49
+ "get_default_qconfig_propagation_list",
50
+ "get_default_compare_output_module_list",
51
+ "get_quantized_operator",
52
+ "get_fuser_method",
53
+ # Sub functions for `prepare` and `swap_module`
54
+ "propagate_qconfig_",
55
+ "add_quant_dequant",
56
+ "swap_module",
57
+ "default_eval_fn",
58
+ # Observers
59
+ "ObserverBase",
60
+ "WeightObserver",
61
+ "HistogramObserver",
62
+ "observer",
63
+ "default_observer",
64
+ "default_weight_observer",
65
+ "default_placeholder_observer",
66
+ "default_per_channel_weight_observer",
67
+ # FakeQuantize (for qat)
68
+ "default_fake_quant",
69
+ "default_weight_fake_quant",
70
+ "default_fixed_qparams_range_neg1to1_fake_quant",
71
+ "default_fixed_qparams_range_0to1_fake_quant",
72
+ "default_per_channel_weight_fake_quant",
73
+ "default_histogram_fake_quant",
74
+ # QConfig
75
+ "QConfig",
76
+ "default_qconfig",
77
+ "default_dynamic_qconfig",
78
+ "float16_dynamic_qconfig",
79
+ "float_qparams_weight_only_qconfig",
80
+ # QAT utilities
81
+ "default_qat_qconfig",
82
+ "prepare_qat",
83
+ "quantize_qat",
84
+ # module transformations
85
+ "fuse_modules",
86
+ ]
.venv/lib/python3.11/site-packages/torch/quantization/_numeric_suite.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ `torch/ao/ns/_numeric_suite.py`, while adding an import statement
7
+ here.
8
+ """
9
+
10
+ from torch.ao.ns._numeric_suite import (
11
+ _convert_tuple_to_list,
12
+ _dequantize_tensor_list,
13
+ _find_match,
14
+ _get_logger_dict_helper,
15
+ _is_identical_module_type,
16
+ compare_model_outputs,
17
+ compare_model_stub,
18
+ compare_weights,
19
+ get_logger_dict,
20
+ get_matching_activations,
21
+ Logger,
22
+ NON_LEAF_MODULE_TO_ADD_OBSERVER_ALLOW_LIST,
23
+ OutputLogger,
24
+ prepare_model_outputs,
25
+ prepare_model_with_stubs,
26
+ Shadow,
27
+ ShadowLogger,
28
+ )
.venv/lib/python3.11/site-packages/torch/quantization/_numeric_suite_fx.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ `torch/ao/ns/_numeric_suite_fx.py`, while adding an import statement
7
+ here.
8
+ """
9
+
10
+ from torch.ao.ns._numeric_suite_fx import (
11
+ _add_loggers_impl,
12
+ _add_loggers_one_model,
13
+ _add_shadow_loggers_impl,
14
+ _extract_logger_info_one_model,
15
+ _extract_weights_impl,
16
+ _extract_weights_one_model,
17
+ add_loggers,
18
+ add_shadow_loggers,
19
+ extend_logger_results_with_comparison,
20
+ extract_logger_info,
21
+ extract_shadow_logger_info,
22
+ extract_weights,
23
+ NSTracer,
24
+ OutputLogger,
25
+ RNNReturnType,
26
+ )
.venv/lib/python3.11/site-packages/torch/quantization/_quantized_conversions.py ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mypy: allow-untyped-defs
2
+ import torch
3
+
4
+
5
+ # Pack pairs of int4 values into int8, in row major order; first int4
6
+ # value goes into lower order bits, and second int4 value into higher
7
+ # order bits of resulting int8 value.
8
+ def pack_int4_to_int8(weight):
9
+ assert weight.dim() == 2
10
+ assert weight.shape[1] % 2 == 0
11
+ assert weight.dtype == torch.int8
12
+ return ((weight[:, 1::2] & 0xF) << 4) | (weight[:, 0::2] & 0xF)
13
+
14
+
15
+ # Unpack quandruples of bits in int8 values into int4 values, in row
16
+ # major order; lower 4 bits go into first int4 value goes, and upper 4
17
+ # bits go into second int4 value.
18
+ def unpack_int8_to_int4(weight):
19
+ assert weight.dim() == 2
20
+ assert weight.dtype == torch.int8
21
+ return torch.stack((weight & 0xF, (weight >> 4) & 0xF), dim=2).view(
22
+ weight.shape[0], 2 * weight.shape[1]
23
+ )
24
+
25
+
26
+ # Transpose the weight matrix, and then reorder its elements according
27
+ # to underlying requirements of CUTLASS library, so that it could be
28
+ # used for CUTLASS-based mixed datatypes linear operation.
29
+ def quantized_weight_reorder_for_mixed_dtypes_linear_cutlass(
30
+ weight, dtypeq, transpose=False
31
+ ):
32
+ assert weight.dim() == 2
33
+ assert weight.dtype == torch.int8
34
+ assert dtypeq == torch.int8 or dtypeq == torch.quint4x2
35
+ assert weight.device.type == "cuda"
36
+
37
+ device = weight.device
38
+
39
+ # subbyte_transpose
40
+ if not transpose:
41
+ if dtypeq == torch.int8:
42
+ outp = weight.T
43
+ elif dtypeq == torch.quint4x2:
44
+ outp = pack_int4_to_int8(unpack_int8_to_int4(weight.view(torch.int8)).T)
45
+ else:
46
+ outp = weight
47
+
48
+ ncols, nrows = outp.shape # type: ignore[possibly-undefined]
49
+ assert nrows % (32 if dtypeq == torch.quint4x2 else 64) == 0
50
+ assert ncols % 64 == 0
51
+
52
+ # permute_B_rows_for_mixed_gemm
53
+ # (permute cols actually, as transpose is applied first here)
54
+ if dtypeq == torch.quint4x2:
55
+ cols_permuted = (
56
+ torch.tensor(
57
+ [0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15],
58
+ device=device,
59
+ )
60
+ + (torch.arange(0, nrows // 16, device=device).reshape(-1, 1) * 16).expand(
61
+ nrows // 16, 16
62
+ )
63
+ ).view(-1)
64
+ else:
65
+ cols_permuted = (
66
+ torch.tensor(
67
+ [0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15],
68
+ device=device,
69
+ )
70
+ + (torch.arange(0, nrows // 16, device=device).reshape(-1, 1) * 16).expand(
71
+ nrows // 16, 16
72
+ )
73
+ ).view(-1)
74
+ outp = outp.index_copy(1, cols_permuted, outp)
75
+
76
+ # interleave_column_major_tensor
77
+ magic0 = 4 if dtypeq == torch.quint4x2 else 2
78
+ magic1 = 32 // magic0
79
+
80
+ tmp0 = (
81
+ (torch.arange(0, ncols // magic0, device=device) * (nrows // 4 * magic0))
82
+ .view(-1, 1)
83
+ .repeat(1, nrows // 4 * magic0)
84
+ .view(-1)
85
+ )
86
+ tmp1 = (
87
+ (torch.arange(0, nrows // 4 // magic1, device=device) * (magic0 * magic1))
88
+ .view(-1, 1)
89
+ .repeat(1, magic1)
90
+ .view(-1)
91
+ .repeat(ncols)
92
+ )
93
+ tmp2 = (
94
+ (torch.arange(0, magic0, device=device) * magic1)
95
+ .view(-1, 1)
96
+ .repeat(1, nrows // 4)
97
+ .view(-1)
98
+ .repeat(ncols // magic0)
99
+ )
100
+ tmp3 = torch.arange(0, magic1, device=device).repeat(nrows // 4 * ncols // magic1)
101
+
102
+ outp_offsets = tmp0 + tmp1 + tmp2 + tmp3
103
+
104
+ tmp = outp.view(-1).view(torch.int32)
105
+ outp = torch.zeros_like(tmp)
106
+ outp.scatter_(0, outp_offsets, tmp)
107
+ outp = outp.view(weight.dtype)
108
+
109
+ # add_bias_and_interleave_quantized_tensor_inplace
110
+ tmp = outp.view(-1)
111
+
112
+ outp = torch.empty_like(tmp)
113
+ if dtypeq == torch.int8:
114
+ tmp = (tmp.to(torch.int) + 128).to(tmp.dtype)
115
+ outp[0::4] = tmp[0::4]
116
+ outp[1::4] = tmp[2::4]
117
+ outp[2::4] = tmp[1::4]
118
+ outp[3::4] = tmp[3::4]
119
+ elif dtypeq == torch.quint4x2:
120
+ tmp0 = ((tmp & 0xF) + 8) & 0xF
121
+ tmp0 = (tmp0[1::2] << 4) | tmp0[0::2]
122
+ tmp1 = (((tmp >> 4) & 0xF) + 8) & 0xF
123
+ tmp1 = (tmp1[1::2] << 4) | tmp1[0::2]
124
+ outp[0::4] = tmp0[0::2]
125
+ outp[1::4] = tmp0[1::2]
126
+ outp[2::4] = tmp1[0::2]
127
+ outp[3::4] = tmp1[1::2]
128
+
129
+ if dtypeq == torch.quint4x2:
130
+ nrows *= 2
131
+ ncols //= 2
132
+
133
+ return outp.view(nrows, ncols).view(torch.uint8)
.venv/lib/python3.11/site-packages/torch/quantization/fake_quantize.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ `torch/ao/quantization/fake_quantize.py`, while adding an import statement
7
+ here.
8
+ """
9
+
10
+ from torch.ao.quantization.fake_quantize import (
11
+ _is_fake_quant_script_module,
12
+ _is_per_channel,
13
+ _is_per_tensor,
14
+ _is_symmetric_quant,
15
+ default_fake_quant,
16
+ default_fixed_qparams_range_0to1_fake_quant,
17
+ default_fixed_qparams_range_neg1to1_fake_quant,
18
+ default_fused_act_fake_quant,
19
+ default_fused_per_channel_wt_fake_quant,
20
+ default_fused_wt_fake_quant,
21
+ default_histogram_fake_quant,
22
+ default_per_channel_weight_fake_quant,
23
+ default_weight_fake_quant,
24
+ disable_fake_quant,
25
+ disable_observer,
26
+ enable_fake_quant,
27
+ enable_observer,
28
+ FakeQuantize,
29
+ FakeQuantizeBase,
30
+ FixedQParamsFakeQuantize,
31
+ FusedMovingAvgObsFakeQuantize,
32
+ )
.venv/lib/python3.11/site-packages/torch/quantization/fuse_modules.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ `torch/ao/quantization/fuse_modules.py`, while adding an import statement
7
+ here.
8
+ """
9
+
10
+ # TODO: These functions are not used outside the `fuse_modules.py`
11
+ # Keeping here for now, need to remove them later.
12
+ from torch.ao.quantization.fuse_modules import (
13
+ _fuse_modules,
14
+ _get_module,
15
+ _set_module,
16
+ fuse_known_modules,
17
+ fuse_modules,
18
+ get_fuser_method,
19
+ )
20
+
21
+ # for backward compatiblity
22
+ from torch.ao.quantization.fuser_method_mappings import fuse_conv_bn, fuse_conv_bn_relu
.venv/lib/python3.11/site-packages/torch/quantization/fuser_method_mappings.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ `torch/ao/quantization/fuser_method_mappings.py`, while adding an import statement
7
+ here.
8
+ """
9
+ from torch.ao.quantization.fuser_method_mappings import (
10
+ _DEFAULT_OP_LIST_TO_FUSER_METHOD,
11
+ fuse_conv_bn,
12
+ fuse_conv_bn_relu,
13
+ fuse_linear_bn,
14
+ get_fuser_method,
15
+ )
.venv/lib/python3.11/site-packages/torch/quantization/fx/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # flake8: noqa: F401
2
+ r"""
3
+ This file is in the process of migration to `torch/ao/quantization`, and
4
+ is kept here for compatibility while the migration process is ongoing.
5
+ If you are adding a new entry/functionality, please, add it to the
6
+ appropriate files under `torch/ao/quantization/fx/`, while adding an import statement
7
+ here.
8
+ """
9
+
10
+ from torch.ao.quantization.fx.convert import convert
11
+ from torch.ao.quantization.fx.fuse import fuse
12
+
13
+ # omitting files that's unlikely to be used right now, for example
14
+ # the newly added lower_to_fbgemm etc.
15
+ from torch.ao.quantization.fx.prepare import prepare
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (762 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/_equalize.cpython-311.pyc ADDED
Binary file (1.88 kB). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/convert.cpython-311.pyc ADDED
Binary file (605 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/fuse.cpython-311.pyc ADDED
Binary file (596 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/fusion_patterns.cpython-311.pyc ADDED
Binary file (658 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/graph_module.cpython-311.pyc ADDED
Binary file (892 Bytes). View file
 
.venv/lib/python3.11/site-packages/torch/quantization/fx/__pycache__/match_utils.cpython-311.pyc ADDED
Binary file (729 Bytes). View file