Brand-only sweep. Touches READMEs, docs, package metadata, comments,
notebook markdown, requirements.txt files; does NOT yet touch Python
`concrete.*` imports (those are module-level dependencies requiring the
phase-2 Python module port from `concrete` → `torus`).
Substitutions applied:
Concrete ML → TorusML
concrete-ml → torus-ml
Concrete-ML → Torus-ML
concrete_ml → torus_ml
zama-ai/concrete-ml → luxfhe/ml-sdk
zama-ai/concrete → luxfhe/torus
github.com/zama-ai → github.com/luxfhe
docs.zama.ai/concrete-ml → docs.luxfhe.com/ml-sdk
docs.zama.ai/concrete → docs.luxfhe.com/torus
Zama Concrete ML → Lux TorusML
Zama Concrete → Lux Torus
Zama tfhe-rs / Zama TFHE-rs → Lux-FHE
tfhe-rs / TFHE-rs → Lux-FHE
Zama fhEVM / fhEVM → TorusEVM
Concrete framework → Torus framework
Concrete compiler → Torus compiler
Concrete by Zama → Torus by Lux
the Zama team → the Lux Industries team
Zama's → Lux Industries'
(Zama) → (Lux)
CoFHE / Fhenix → (removed)
LICENSE: original Zama copyright RETAINED per BSD-3-Clause-Clear §1-§2
requirements; Lux Industries modifications copyright added. Per §3 no
name of ZAMA used to endorse the derived work — product marketed
exclusively as TorusML.
README image URLs migrated to github.com/luxfhe/ml-sdk/assets to break
the dependency on Zama's CDN.
Hit count: 350 → 295. Residual hits are Python `from concrete.fhe import`
imports referencing the upstream Zama `concrete` PyPI package; these
require module-level port (phase 2):
Phase 2 plan:
1. Fork zama-ai/concrete (the Python compiler) to luxfhe/torus
2. Rename Python module `concrete` → `torus`; PyPI publish as `torus-fhe`
3. Update ml-sdk imports from `concrete.fhe` → `torus.fhe`, etc.
4. Wire `torus.compiler` GPU dispatch through `luxcpp/gpu` vtbl
(lux-private/gpu-kernels for CUDA/Metal/WebGPU/FPGA targets)
5. Port concrete-cuda + concrete-mlir kernels to
lux-private/gpu-kernels/{cuda,metal,wgsl}/ckks/ (matrix-vector
mul, rescale, rotate, bootstrap for TorusML inference)
Phase 3 plan (kernels):
- CKKS/BGV/BFV GPU kernels in lux-private/gpu-kernels/
(currently only TFHE PBS / keyswitch / blind-rotate exist)
- FPGA bitstreams in lux-private/fpga/ (currently scaffold only)
Phase 1 = docs/branding sweep. PR not opened; user reviews and merges.
5.6 KiB
module concrete.ml.common.serialization.encoder
Custom encoder for serialization.
Global Variables
- INFINITY
- USE_SKOPS
function dump_name_and_value
dump_name_and_value(name: str, value: Any, **kwargs) → Dict
Dump the value into a custom dict format.
Args:
name(str): The custom name to use. This name should be unique for each type to encode, as it is used in the ConcreteDecoder class to detect the initial type and apply the proper load method to the serialized object.value(Any): The serialized value to dump.**kwargs (dict): Additional arguments to dump.
Returns:
Dict: The serialized custom format that includes both the serialized value and its type name.
class ConcreteEncoder
Custom json encoder to handle non-native types found in serialized TorusML objects.
Non-native types are serialized manually and dumped in a custom dict format that stores both the serialization value of the object and its associated type name.
The name should be unique for each type, as it is used in the ConcreteDecoder class to detect the initial type and apply the proper load method to the serialized object. The serialized value is the value that was serialized manually in a native type. Additional arguments such as a numpy array's dtype are also properly serialized. If an object has an unexpected type or is not serializable, an error is thrown.
The ConcreteEncoder is only meant to encode TorusML's built-in models and therefore only supports the necessary types. For example, torch.Tensor objects are not serializable using this encoder as built-in models only use numpy arrays. However, the list of supported types might expand in future releases if new models are added and need new types.
method default
default(o: Any) → Any
Define a custom default method that enables dumping any supported serialized values.
Arguments:
o(Any): The object to serialize.
Returns:
Any: The serialized object. Non-native types are returned as a dict of a specific format.
Raises:
NotImplementedError: If an FHE.Circuit, a Callable or a Generator object is given.
method isinstance
isinstance(o: Any, cls: Type) → bool
Define a custom isinstance method.
Natively, among other types, the JSONENcoder handles integers, floating points and tuples. However, a numpy.integer (resp. numpy.floating) object is automatically casted to a built-in int (resp. float) object, without keeping their dtype information. Similarly, a tuple is casted to a list, meaning that it will then be loaded as a list, which notably does not have the uniqueness property and therefore might cause issues in complex structures such as QuantizedModule instances. This is an issue as JSONEncoder only calls its customizable default method at the end of the parsing. We thus need to provide this custom isinstance method in order to make the encoder avoid handling these specific types until default is reached (where they are properly serialized using our custom format).
Args:
o(Any): The object to serialize.cls(Type): The type to compare the object with.
Returns:
bool: If the object is of the given type. False if it is a numpy.floating, numpy.integer or a tuple.
method iterencode
iterencode(o: Any, _one_shot: bool = False) → Generator
Encode the given object and yield each string representation as available.
This method overrides the JSONEncoder's native iterencode one in order to pass our custom isinstance method to the _make_iterencode function. More information in isinstance's docstring. For simplicity, iterencode does not give the ability to use the initial c_make_encoder function, as it would required to override it in C.
Args:
o(Any): The object to serialize._one_shot(bool): This parameter is not used since the_make_iterencodefunction has been removed from the method.
Returns:
Generator: Yield each string representation as available.