Forked from upstream concrete (BSD-3-Clause-Clear, © 2024 ZAMA) at HEAD
ecb729bb. Modifications copyright © 2026 Lux Industries Inc.
Rebranding scope:
- Python module concrete → torus (across frontends/torus-python)
- Rust module concrete-* → torus-* (across frontends/torus-rust)
- MLIR dialect concretelang → toruslang (across compilers/torus-compiler)
- Compiler optimizer concrete-optimizer → torus-optimizer
- Backend concrete-cpu / concrete-cuda → torus-cpu / torus-cuda
- Wire protocol concrete-protocol → torus-protocol
- Parameter-curves concrete-security-curves-* → torus-security-curves-*
- Public symbols concretelib → toruslib, ConcreteLang → TorusLang
- URLs github.com/zama-ai/concrete → github.com/luxfhe/torus
- URLs docs.zama.ai/concrete → docs.luxfhe.com/torus
Legal compliance:
- LICENSE.txt retains original Copyright © 2024 ZAMA verbatim (§1-§2)
- LICENSE.txt adds modifications copyright © 2026 Lux Industries Inc.
- §3 endorsement clause: Torus is marketed exclusively as a Lux product;
no Zama name used in README, docs, or marketing
- NOTICE file provides factual attribution per legal best practice
(not endorsement; required by upstream BSD-3-Clause-Clear)
README + NOTICE rewritten from scratch with Lux brand:
- Quick-start in Python (torus.fhe)
- Architecture diagram showing the gen-1 vtbl integration path
(luxcpp/gpu → lux-private/gpu-kernels for CUDA/Metal/WebGPU)
- Scheme coverage table: TFHE (luxfi/fhe), CKKS/BGV/BFV (luxfi/lattice)
- Lux FHE family table: Torus / TorusVM / TorusEVM / TorusML / TorusNet
Known limitations (phase-2A scope):
- PyPI package torus-fhe not yet published; the torus Python module
is renamed structurally but pip-installable distribution is a
follow-up (Phase 2A.1)
- MLIR dialect rename is text-level; the compiler-internal LLVM
rebuild (concrete-compiler-internal-llvm-project submodule) is
structural and works; tablegen files renamed concrete→torus but the
generated .inc files in the source tree will regenerate at build
time
- backends/torus-cuda/implementation/ is an upstream submodule
pointer to the tfhe-rs source (not fetched in the staging clone);
the CUDA backend body is delivered out-of-tree
- ~100 test-fixture variable names like concrete_encoded_sample
retain "concrete" as a math term (vs symbolic); these are inside
tests/, not the public API; cleanup is a follow-up commit
- 295 Python `from concrete import ...` residuals in luxfhe/ml-sdk
consumer remain; that repo's import update is Phase 2B
This commit is the seed for the luxfhe/torus repo. Push as the first
commit to a fresh GitHub repo; do not re-import upstream Zama git
history.
4.0 KiB
Changing the implementation strategy of complex operations
This guide teaches how to improve the execution time of Torus circuits by using different conversion strategies for complex operations.
Torus provides multiple implementation strategies for these complex operations:
- comparisons (<,<=,==,!=,>=,>)
- bitwise operations (<<,&,|,^,>>)
- minimum and maximum operations
- multivariate extension
{% hint style="info" %} The default strategy is the one that doesn't increase the input bit width, even if it's less optimal than the others. If you don't care about the input bit widths (e.g., if the inputs are only used in this operation), you should definitely change the default strategy. {% endhint %}
Choosing the correct strategy can lead to big speedups. So if you are not sure which one to use, you can compile with different strategies and compare the complexity.
For example, the following code:
import numpy as np
from torus import fhe
def f(x, y):
return x & y
inputset = fhe.inputset(fhe.uint3, fhe.uint4)
strategies = [
fhe.BitwiseStrategy.ONE_TLU_PROMOTED,
fhe.BitwiseStrategy.THREE_TLU_CASTED,
fhe.BitwiseStrategy.TWO_TLU_BIGGER_PROMOTED_SMALLER_CASTED,
fhe.BitwiseStrategy.TWO_TLU_BIGGER_CASTED_SMALLER_PROMOTED,
fhe.BitwiseStrategy.CHUNKED,
]
for strategy in strategies:
compiler = fhe.Compiler(f, {"x": "encrypted", "y": "encrypted"})
circuit = compiler.compile(inputset, bitwise_strategy_preference=strategy)
print(
f"{strategy:>55} "
f"-> {circuit.programmable_bootstrap_count:>2} TLUs "
f"-> {int(circuit.complexity):>12_} complexity"
)
prints:
BitwiseStrategy.ONE_TLU_PROMOTED -> 1 TLUs -> 535_706_740 complexity
BitwiseStrategy.THREE_TLU_CASTED -> 3 TLUs -> 599_489_229 complexity
BitwiseStrategy.TWO_TLU_BIGGER_PROMOTED_SMALLER_CASTED -> 2 TLUs -> 522_239_955 complexity
BitwiseStrategy.TWO_TLU_BIGGER_CASTED_SMALLER_PROMOTED -> 2 TLUs -> 519_246_216 complexity
BitwiseStrategy.CHUNKED -> 6 TLUs -> 358_905_521 complexity
or:
import numpy as np
from torus import fhe
def f(x, y):
return x == y
inputset = fhe.inputset(fhe.uint4, fhe.uint7)
strategies = [
fhe.ComparisonStrategy.ONE_TLU_PROMOTED,
fhe.ComparisonStrategy.THREE_TLU_CASTED,
fhe.ComparisonStrategy.TWO_TLU_BIGGER_PROMOTED_SMALLER_CASTED,
fhe.ComparisonStrategy.TWO_TLU_BIGGER_CASTED_SMALLER_PROMOTED,
fhe.ComparisonStrategy.THREE_TLU_BIGGER_CLIPPED_SMALLER_CASTED,
fhe.ComparisonStrategy.TWO_TLU_BIGGER_CLIPPED_SMALLER_PROMOTED,
fhe.ComparisonStrategy.CHUNKED,
]
for strategy in strategies:
compiler = fhe.Compiler(f, {"x": "encrypted", "y": "encrypted"})
circuit = compiler.compile(inputset, comparison_strategy_preference=strategy)
print(
f"{strategy:>58} "
f"-> {circuit.programmable_bootstrap_count:>2} TLUs "
f"-> {int(circuit.complexity):>13_} complexity"
)
prints:
ComparisonStrategy.ONE_TLU_PROMOTED -> 1 TLUs -> 1_217_510_420 complexity
ComparisonStrategy.THREE_TLU_CASTED -> 3 TLUs -> 751_172_128 complexity
ComparisonStrategy.TWO_TLU_BIGGER_PROMOTED_SMALLER_CASTED -> 2 TLUs -> 1_043_702_103 complexity
ComparisonStrategy.TWO_TLU_BIGGER_CASTED_SMALLER_PROMOTED -> 2 TLUs -> 1_898_305_707 complexity
ComparisonStrategy.THREE_TLU_BIGGER_CLIPPED_SMALLER_CASTED -> 3 TLUs -> 751_172_128 complexity
ComparisonStrategy.TWO_TLU_BIGGER_CLIPPED_SMALLER_PROMOTED -> 2 TLUs -> 682_694_770 complexity
ComparisonStrategy.CHUNKED -> 3 TLUs -> 751_172_128 complexity
As you can see, strategies can affect the performance a lot! So make sure to select the appropriate one for your use case if you want to optimize performance.