Spaces:
Sleeping
Sleeping
MaduRox commited on
Commit ·
9ab7159
1
Parent(s): ef5ecdb
fix: enable KalpanaHybridCacheLayer in KalpanaDynamicCache for fluent generation
Browse files
kalpana_embed_to_kv/kv_cache.py
CHANGED
|
@@ -249,16 +249,18 @@ class KalpanaDynamicCache:
|
|
| 249 |
def __init__(
|
| 250 |
self,
|
| 251 |
num_layers: Optional[int] = None,
|
| 252 |
-
bands: int =
|
| 253 |
kappa: float = 1.0,
|
|
|
|
| 254 |
**kwargs,
|
| 255 |
):
|
| 256 |
self.bands = bands
|
| 257 |
self.kappa = kappa
|
|
|
|
| 258 |
self.num_layers = num_layers or 32
|
| 259 |
-
# Per-layer RIF cache instances
|
| 260 |
-
self.layers: List[
|
| 261 |
-
|
| 262 |
]
|
| 263 |
# key_cache / value_cache mirrors for transformers internals
|
| 264 |
self.key_cache: List[torch.Tensor] = []
|
|
|
|
| 249 |
def __init__(
|
| 250 |
self,
|
| 251 |
num_layers: Optional[int] = None,
|
| 252 |
+
bands: int = 2048,
|
| 253 |
kappa: float = 1.0,
|
| 254 |
+
sliding_window: int = 128,
|
| 255 |
**kwargs,
|
| 256 |
):
|
| 257 |
self.bands = bands
|
| 258 |
self.kappa = kappa
|
| 259 |
+
self.sliding_window = sliding_window
|
| 260 |
self.num_layers = num_layers or 32
|
| 261 |
+
# Per-layer RIF cache instances with hybrid local window + long-range RIF field
|
| 262 |
+
self.layers: List[KalpanaHybridCacheLayer] = [
|
| 263 |
+
KalpanaHybridCacheLayer(sliding_window=sliding_window, bands=bands, kappa=kappa) for _ in range(self.num_layers)
|
| 264 |
]
|
| 265 |
# key_cache / value_cache mirrors for transformers internals
|
| 266 |
self.key_cache: List[torch.Tensor] = []
|