vllm.utils.hashing ¶
get_hash_fn_by_name ¶
Get a hash function by name, or raise an error if the function is not found.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hash_fn_name | str | Name of the hash function. | required |
Returns:
Type | Description |
---|---|
Callable[[Any], bytes] | A hash function. |
Source code in vllm/utils/hashing.py
sha256 ¶
Hash any picklable Python object using SHA-256.
The input is serialized using pickle before hashing, which allows arbitrary Python objects to be used. Note that this function does not use a hash seed—if you need one, prepend it explicitly to the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input | Any | Any picklable Python object. | required |
Returns:
Type | Description |
---|---|
bytes | Bytes representing the SHA-256 hash of the serialized input. |
Source code in vllm/utils/hashing.py
sha256_cbor ¶
Hash objects using CBOR serialization and SHA-256.
This option is useful for non-Python-dependent serialization and hashing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input | Any | Object to be serialized and hashed. Supported types include basic Python types and complex structures like lists, tuples, and dictionaries. Custom classes must implement CBOR serialization methods. | required |
Returns:
Type | Description |
---|---|
bytes | Bytes representing the SHA-256 hash of the CBOR serialized input. |