Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

#578 Feature/sg 516 support head replacement for local pretrained weights unknown dataset

Merged
Ghost merged 1 commits into Deci-AI:master from deci-ai:feature/SG-516_support_head_replacement_for_local_pretrained_weights_unknown_dataset
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
  1. import sys
  2. import unittest
  3. import dataclasses
  4. from typing import Type
  5. from super_gradients.common.crash_handler.crash_tips import (
  6. get_relevant_crash_tip_message,
  7. CrashTip,
  8. TorchCudaMissingTip,
  9. RecipeFactoryFormatTip,
  10. DDPNotInitializedTip,
  11. WrongHydraVersionTip,
  12. )
  13. @dataclasses.dataclass
  14. class DocumentedException:
  15. exc_value: Exception
  16. expected_crash_tip: Type[CrashTip]
  17. # author/person who faced this exception?
  18. class CrashTipTest(unittest.TestCase):
  19. def setUp(self) -> None:
  20. # Add any exception that we want to support here to make sure that it will be handled by our crash tip handler
  21. self.documented_exceptions = [
  22. DocumentedException(
  23. exc_value=OSError(
  24. "/home/tomer.keren/.conda/envs/tomer-dev-sg3/lib/python3.10/site-packages/torch/lib/../../nvidia/cublas/lib/libcublas.so.11: symbol "
  25. "cublasLtHSHMatmulAlgoInit version libcublasLt.so.11 not defined in file libcublasLt.so.11 with link time reference"
  26. ),
  27. expected_crash_tip=TorchCudaMissingTip,
  28. ),
  29. DocumentedException(
  30. exc_value=RuntimeError(
  31. "Malformed object definition in configuration. Expecting either a string of object type or a single entry dictionary{type_name(str): "
  32. "{parameters...}}.received: {'my_callback': None, 'lr_step': 2.4}"
  33. ),
  34. expected_crash_tip=RecipeFactoryFormatTip,
  35. ),
  36. DocumentedException(
  37. exc_value=RuntimeError("Default process group has not been initialized, please make sure to call init_process_group."),
  38. expected_crash_tip=DDPNotInitializedTip,
  39. ),
  40. DocumentedException(
  41. exc_value=TypeError("__init__() got an unexpected keyword argument 'version_base'"),
  42. expected_crash_tip=WrongHydraVersionTip,
  43. ),
  44. ]
  45. def test_found_exceptions(self):
  46. """Test all the exceptions that were documented, and make sure that they have an associated tip."""
  47. for documented_exception in self.documented_exceptions:
  48. exc_value, expected_crash_tip = documented_exception.exc_value, documented_exception.expected_crash_tip
  49. try:
  50. raise exc_value
  51. except type(exc_value):
  52. exc_type, exc_value, exc_traceback = sys.exc_info()
  53. with self.subTest(
  54. msg="Making sure that the CrashTip is considered relevant for the exception...",
  55. expected_tip=expected_crash_tip.__name__,
  56. exception=exc_value,
  57. ):
  58. is_relevant = expected_crash_tip.is_relevant(exc_type, exc_value, exc_traceback)
  59. self.assertTrue(
  60. is_relevant,
  61. msg=f"Crash tip '{expected_crash_tip.__name__}' should be relevant for exception '{exc_type.__name__}' but failed.",
  62. )
  63. with self.subTest(
  64. msg="Making sure that the CrashTip generates a message (None is returned if an error is raised internally, to avoid crashing atexit)...",
  65. crash_tip=expected_crash_tip.__name__,
  66. ):
  67. crash_tip_msg = expected_crash_tip.get_message(exc_type, exc_value, exc_traceback)
  68. self.assertIsNotNone(
  69. crash_tip_msg,
  70. msg=f"The crash tip '{expected_crash_tip.__name__}' returned None, "
  71. f"an exception was probably raised in '{expected_crash_tip.__name__}.get_message(...)'",
  72. )
  73. with self.subTest(
  74. msg="Making sure that we can find the relevant CrashTip and get it's summary for the exception...",
  75. expected_tip=expected_crash_tip.__name__,
  76. exception=exc_value,
  77. ):
  78. crash_tip_message = get_relevant_crash_tip_message(exc_type, exc_value, exc_traceback)
  79. expected_crash_tip_message = expected_crash_tip.get_message(exc_type, exc_value, exc_traceback)
  80. self.assertEqual(
  81. crash_tip_message,
  82. expected_crash_tip_message,
  83. msg=f"Crash tip message should be '{expected_crash_tip_message}' but got '{crash_tip_message}' instead.",
  84. )
Discard
Tip!

Press p or to see the previous file or, n or to see the next file