Northy1717/SWE-bench-Live huggingface dataset:
Repository: instructlab/instructlab

Issue:
Nvidia support - Update training profiles to use FSDP as default
Blocked on: 
- [x] https://github.com/instructlab/training/issues/292



Discussion:
I _think_ @jaideepr97 has already done this with https://github.com/instructlab/instructlab/pull/2323? The issue is a little vague tbh so not sure. cc @cdoern 



Patch:
diff --git a/src/instructlab/configuration.py b/src/instructlab/configuration.py
index d2c34124e4..7f3f546111 100644
--- a/src/instructlab/configuration.py
+++ b/src/instructlab/configuration.py
@@ -448,7 +448,7 @@ class _train(BaseModel):
         default=False, description="Allow CPU offload for FSDP optimizer."
     )
     distributed_backend: DistributedBackend = Field(
-        default=DistributedBackend.DEEPSPEED,
+        default=DistributedBackend.FSDP,
         description="Pick a distributed training backend framework for GPU accelerated full fine-tuning.",
         validate_default=True,  # ensures that the 'use_enum_values' flag takes effect on the default value
     )


Test patch:
diff --git a/tests/testdata/default_config.yaml b/tests/testdata/default_config.yaml
index 74909426f5..3dd0bd170c 100644
--- a/tests/testdata/default_config.yaml
+++ b/tests/testdata/default_config.yaml
@@ -281,8 +281,8 @@ train:
   disable_flash_attn: false
   # Pick a distributed training backend framework for GPU accelerated full fine-
   # tuning.
-  # Default: deepspeed
-  distributed_backend: deepspeed
+  # Default: fsdp
+  distributed_backend: fsdp
   # The number of samples in a batch that the model should see before its parameters
   # are updated.
   # Default: 64
Repository: instructlab/instructlab

Issue:
Accelerated train without high fidelity exits without doing anything
**Describe the bug**
If you run training with:

        result = cli_runner.invoke(
            lab.ilab,
            [
                "--config=DEFAULT",
                "model",
                "train",
                "--pipeline",
                "accelerated",
                "--strategy",
                "lab-multiphase",
                "--phased-phase1-data",
                "knowledge_data_path",
                "--phased-phase2-data",
                "skills_data_path",
                "--phased-phase1-num-epochs",
                "1",
                "--phased-phase2-num-epochs",
                "1",
                "--skip-user-confirm",
            ],
        )

it will return a 0 exit code and do nothing with device=cpu.  There needs to be an else in train.py to handle when 0 conditions were hit.

**Expected behavior**
A message should be printed stating the requested configuration can't be executed with a non zero exit code.



Discussion:

Patch:
diff --git a/src/instructlab/cli/model/train.py b/src/instructlab/cli/model/train.py
index c3f32c15fa..3cf0c9762b 100644
--- a/src/instructlab/cli/model/train.py
+++ b/src/instructlab/cli/model/train.py
@@ -493,6 +493,11 @@ def train(
         except Exception as exc:
             click.secho(f"{exc}", fg="red")
             raise click.exceptions.Exit(1)
+    else:
+        click.secho(
+            f"Unable to train with device={device} and pipeline={pipeline}", fg="red"
+        )
+        raise click.exceptions.Exit(1)
 
 
 # chooses which type of training to run depending on the device provided


Test patch:
diff --git a/tests/test_lab_train.py b/tests/test_lab_train.py
index c2ac38c0c5..fb54db2011 100644
--- a/tests/test_lab_train.py
+++ b/tests/test_lab_train.py
@@ -671,3 +671,26 @@ def test_phased_train_failures(
             in result.output
         )
         assert result.exit_code == 1
+
+    def test_invalid_train_request(
+        self,
+        cli_runner: CliRunner,
+    ):
+        result = cli_runner.invoke(
+            lab.ilab,
+            [
+                "--config=DEFAULT",
+                "model",
+                "train",
+                "--pipeline",
+                "accelerated",
+                "--strategy",
+                "lab-multiphase",
+                "--device",
+                "cpu",
+            ],
+        )
+        assert (
+            "Unable to train with device=cpu and pipeline=accelerated" in result.output
+        )
+        assert result.exit_code == 1
Repository: projectmesa/mesa

Issue:
Removing all agents in the model
I am currently updating my teaching materials to MESA 3. One of my assignments is an evolutionary version of Axelrod's emergence of collaboration. However, this requires removing the entire population of agents at each tick, and creating the next generation. (I know it can also be implemented differently...). At the moment, there is no convenience method for removing all agents from the model. Since `model.agents` returns a weakref agentset, doing operations on this won't work. It seems we need a model level method like `model.clear_agents()`, which would call `agent.remove` on each agent. It needs to run through `agent.remove` rather than just rebuild the model._agents datastructures to ensure that agents are also removed from the experimental cell spaces.


Discussion:

Patch:
diff --git a/mesa/agent.py b/mesa/agent.py
index 18454164e5a..200dab6f093 100644
--- a/mesa/agent.py
+++ b/mesa/agent.py
@@ -67,7 +67,13 @@ def __init__(self, model: Model, *args, **kwargs) -> None:
         self.model.register_agent(self)
 
     def remove(self) -> None:
-        """Remove and delete the agent from the model."""
+        """Remove and delete the agent from the model.
+
+        Notes:
+            If you need to do additional cleanup when removing an agent by for example removing
+            it from a space, consider extending this method in your own agent class.
+
+        """
         with contextlib.suppress(KeyError):
             self.model.deregister_agent(self)
 
diff --git a/mesa/model.py b/mesa/model.py
index ac59cc1f1f9..f9c0e2e4869 100644
--- a/mesa/model.py
+++ b/mesa/model.py
@@ -276,3 +276,16 @@ def initialize_data_collector(
         )
         # Collect data for the first time during initialization.
         self.datacollector.collect(self)
+
+    def remove_all_agents(self):
+        """Remove all agents from the model.
+
+        Notes:
+            This method calls agent.remove for all agents in the model. If you need to remove agents from
+            e.g., a SingleGrid, you can either explicitly implement your own agent.remove method or clean this up
+            near where you are calling this method.
+
+        """
+        # we need to wrap keys in a list to avoid a RunTimeError: dictionary changed size during iteration
+        for agent in list(self._agents.keys()):
+            agent.remove()


Test patch:
diff --git a/tests/test_model.py b/tests/test_model.py
index 7c343e46357..ff1fe297b6a 100644
--- a/tests/test_model.py
+++ b/tests/test_model.py
@@ -93,3 +93,18 @@ class Sheep(Agent):
     assert model.agents_by_type[Wolf] == AgentSet([wolf], model)
     assert model.agents_by_type[Sheep] == AgentSet([sheep], model)
     assert len(model.agents_by_type) == 2
+
+
+def test_agent_remove():
+    """Test removing all agents from the model."""
+
+    class TestAgent(Agent):
+        pass
+
+    model = Model()
+    for _ in range(100):
+        TestAgent(model)
+    assert len(model.agents) == 100
+
+    model.remove_all_agents()
+    assert len(model.agents) == 0