rxnn 0.2.47__tar.gz → 0.2.48__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {rxnn-0.2.47 → rxnn-0.2.48}/PKG-INFO +1 -1
  2. {rxnn-0.2.47 → rxnn-0.2.48}/pyproject.toml +1 -1
  3. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/memory/norm.py +3 -1
  4. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/mrl.py +21 -3
  5. {rxnn-0.2.47 → rxnn-0.2.48}/LICENSE +0 -0
  6. {rxnn-0.2.47 → rxnn-0.2.48}/README.md +0 -0
  7. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/.DS_Store +0 -0
  8. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/__init__.py +0 -0
  9. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/experimental/__init__.py +0 -0
  10. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/experimental/attention.py +0 -0
  11. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/experimental/models.py +0 -0
  12. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/experimental/moe.py +0 -0
  13. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/memory/__init__.py +0 -0
  14. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/memory/attention.py +0 -0
  15. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/memory/stm.py +0 -0
  16. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/rxt/__init__.py +0 -0
  17. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/rxt/models.py +0 -0
  18. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/__init__.py +0 -0
  19. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/base.py +0 -0
  20. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/bml.py +0 -0
  21. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/callbacks.py +0 -0
  22. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/dataset.py +0 -0
  23. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/ddp.py +0 -0
  24. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/models.py +0 -0
  25. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/reward.py +0 -0
  26. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/rl.py +0 -0
  27. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/scheduler.py +0 -0
  28. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/tokenizer.py +0 -0
  29. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/training/utils.py +0 -0
  30. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/__init__.py +0 -0
  31. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/attention.py +0 -0
  32. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/ff.py +0 -0
  33. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/layers.py +0 -0
  34. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/mask.py +0 -0
  35. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/models.py +0 -0
  36. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/moe.py +0 -0
  37. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/positional.py +0 -0
  38. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/transformers/sampler.py +0 -0
  39. {rxnn-0.2.47 → rxnn-0.2.48}/src/rxnn/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: rxnn
3
- Version: 0.2.47
3
+ Version: 0.2.48
4
4
  Summary: RxNN: Reactive Neural Networks Platform
5
5
  License: Apache-2.0
6
6
  Keywords: deep-learning,ai,machine-learning
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "rxnn"
7
- version = "0.2.47"
7
+ version = "0.2.48"
8
8
  description = "RxNN: Reactive Neural Networks Platform"
9
9
 
10
10
  license = "Apache-2.0"
@@ -163,7 +163,7 @@ def init_memory_norm(
163
163
  init_scale: float = 1.0,
164
164
  per_dim_scale: bool = False,
165
165
  ) -> nn.Module:
166
- assert norm_type in ['layer', 'rms', 'adaptive', 'positional']
166
+ assert norm_type in ['layer', 'rms', 'adaptive', 'positional', 'classic-rms']
167
167
  if norm_type == 'layer':
168
168
  return MemoryLayerNorm(dim, use_gate, init_scale, init_gate)
169
169
  elif norm_type == 'rms':
@@ -172,4 +172,6 @@ def init_memory_norm(
172
172
  return AdaptiveRMSMemoryNorm(dim, use_gate, decay, init_scale, init_gate)
173
173
  elif norm_type == 'positional':
174
174
  return AdaptivePositionalMemoryNorm(num_slots, dim, decay, use_scale, use_gate, init_gate, per_dim_scale)
175
+ elif norm_type == 'classic-rms':
176
+ return nn.RMSNorm(dim)
175
177
  return MemoryLayerNorm(dim, use_gate, init_scale, init_gate)
@@ -35,6 +35,7 @@ class MrlConfig(TypedDict):
35
35
  moe_aux_loss_scale: Optional[float]
36
36
  freeze_embeddings: Optional[bool]
37
37
  embedding_lr: Optional[float]
38
+ use_memory_warmup: Optional[bool]
38
39
 
39
40
 
40
41
  class MrlStrategy(Enum):
@@ -136,6 +137,7 @@ class MRLTrainer:
136
137
  self.moe_aux_loss_scale = config.get('moe_aux_loss_scale', 0.01)
137
138
  self.shared_freeze_embeddings = config.get('freeze_embeddings', False)
138
139
  self.freeze_embeddings = self.shared_freeze_embeddings
140
+ self.use_memory_warmup = config.get('use_memory_warmup', False)
139
141
  # Internal update epochs config
140
142
  self.shared_update_epochs = config.get('update_epochs', 10)
141
143
  self.update_epochs = self.shared_update_epochs
@@ -381,6 +383,11 @@ class MRLTrainer:
381
383
  self.writer.add_scalar(f'Collect/episode reward (steps: {self.curriculum_steps})', avg_reward,
382
384
  self.stage_step['collect'])
383
385
 
386
+ def memory_warmup(self, query: TokenizedDict, answer: TokenizedDict):
387
+ if self.use_memory_warmup:
388
+ with torch.no_grad():
389
+ self.encode_and_update_stm(query, answer)
390
+
384
391
  def collect_trajectories(self, dataloader: DataLoader, epoch: int, batch_size: int) -> list[MrlTrajectoryEpisode]:
385
392
  """Collect trajectories for PPO for current curriculum step."""
386
393
  # 1. Init trajectories list
@@ -402,8 +409,13 @@ class MRLTrainer:
402
409
  first_query, first_answer, interactions = batch['query'], batch['answer'], batch['interactions']
403
410
  interactions = interactions[:self.curriculum_steps]
404
411
  interactions_len = len(interactions)
412
+
413
+ first_interaction = self._move_multiple_batches(first_query, first_answer)
414
+
415
+ if reset_done:
416
+ self.memory_warmup(*first_interaction)
405
417
  # 6. Encode and update STM with data to save from first interaction
406
- self.encode_and_update_stm(*self._move_multiple_batches(first_query, first_answer))
418
+ self.encode_and_update_stm(*first_interaction)
407
419
 
408
420
  # 7. Save first interaction as data to save (for trajectory state)
409
421
  query, answer = first_query, first_answer
@@ -649,6 +661,9 @@ class MRLTrainer:
649
661
 
650
662
  self.actor.clone_reset_memory()
651
663
 
664
+ if should_reset_stm and step_idx == 0:
665
+ self.memory_warmup(query, answer)
666
+
652
667
  # 7. In memory aware critic version, encode and update STM before critic update, to include its gradients in critic loss too
653
668
  if self.memory_aware_critic:
654
669
  self.encode_and_update_stm(query, answer)
@@ -798,13 +813,16 @@ class MRLTrainer:
798
813
  if batch['query']['input_ids'].size(0) == batch_size:
799
814
  self._increment_steps('eval')
800
815
  # 3. Reset STM with random resets ratio and reward model running mean
801
- self.reset_stm()
816
+ reset_stm = self.reset_stm()
802
817
  self.reward.reset_running_mean()
803
818
 
804
819
  # 4. Get batches for first queries, answers and all follow-up interactions
805
820
  first_query, first_answer, interactions = batch['query'], batch['answer'], batch['interactions']
806
821
  # 5. Encode and update STM with initial interactions (batch)
807
- self.encode_and_update_stm(*self._move_multiple_batches(first_query, first_answer))
822
+ first_interaction = self._move_multiple_batches(first_query, first_answer)
823
+ if reset_stm:
824
+ self.memory_warmup(*first_interaction)
825
+ self.encode_and_update_stm(*first_interaction)
808
826
 
809
827
  # 6. Save follow-up interactions len and first query and answer as previous one for iteration
810
828
  interactions_len = len(interactions)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes