MCPcopy Create free account
hub / github.com/Cornell-RelaxML/qtip / validate

Method validate

model/cache_utils.py:247–297  ·  view source on GitHub ↗

Validates if the arguments passed are correct

(self)

Source from the content-addressed store, hash-verified

245 self.device = device
246
247 def validate(self):
248 """Validates if the arguments passed are correct"""
249
250 incorrect_arg_msg = (
251 "Some of the keys in `cache_config` are defined incorrectly. `{key}` should be {correct_value}` "
252 "but found {found_value}"
253 )
254 # Check that the values are reasonable in general (nbits, axis)
255 # Later in QuantizedCache init we check if they are supported for that particular backend
256 if self.nbits not in [1, 2, 3, 4, 8]:
257 raise ValueError(
258 incorrect_arg_msg.format(
259 key="nbits",
260 correct_value="2 or 4 or 8",
261 found_value=self.nbits,
262 ),
263 )
264 if self.q_group_size <= 0:
265 raise ValueError(
266 incorrect_arg_msg.format(
267 key="q_group_size",
268 correct_value="a positive integer",
269 found_value=self.q_group_size,
270 ),
271 )
272 if self.residual_length < 0:
273 raise ValueError(
274 incorrect_arg_msg.format(
275 key="residual_length",
276 correct_value="a positive integer",
277 found_value=self.residual_length,
278 ),
279 )
280
281 if self.axis_key not in [0, 1, -1]:
282 raise ValueError(
283 incorrect_arg_msg.format(
284 key="axis_key",
285 correct_value="`1` or `0`, `-1`",
286 found_value=self.axis_key,
287 ),
288 )
289
290 if self.axis_value not in [0, 1, -1]:
291 raise ValueError(
292 incorrect_arg_msg.format(
293 key="axis_value",
294 correct_value="`1` or `0` or `-1`",
295 found_value=self.axis_value,
296 ),
297 )
298
299
300@dataclass

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected