[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6KF8DKHAARNQZWDVTX7TF2N":3,"skill-same:01M6KF8DKHAARNQZWDVTX7TF2N":53},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":26,"linkOnly":27,"markdownContent":28,"markdownBody":29,"frontMatter":30,"refName":31,"commitSha":32,"skillDirectory":33,"forksCount":34,"repositoryHtmlUrl":35,"repositoryHomepageUrl":36,"ownerHtmlUrl":37,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":38,"install":39,"resources":52},"01M6KF8DKHAARNQZWDVTX7TF2N","run2_simpo-testing-and-verification",null,"Testing SimPO loss function with fixed tensors and output verification","cxcscmu\u002FSkillLearnBench","cxcscmu","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F142838272?v=4","01M6KCQDFQWPDSN0MKZY96MSQP","01M6KCQDM7G70TKJ28NTSQC0RZ",93,"MIT","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fnlp-paper-reproduction\u002Frun2_simpo-testing-and-verification\u002FSKILL.md",[],[18,19,20,21,22,23,24,25],"testing","verification","simpo","run2 simpo testing and verification","output","with","simpo loss function","simpo loss","2026-11-10 10:12:30",false,"---\nname: run2_simpo-testing-and-verification\ndescription: Testing SimPO loss function with fixed tensors and output verification\n---\n\n# SimPO Testing and Verification Framework\n\n## Fixed-Input Unit Testing\n\nThe SimPO implementation uses **pre-computed fixed tensors** for deterministic testing:\n\n### Test Structure\n```python\n# Load pre-computed tensors\npolicy_chosen_logps = torch.load(\"unit_test\u002Ftensors\u002Fpolicy_chosen_logps.pt\")\npolicy_rejected_logps = torch.load(\"unit_test\u002Ftensors\u002Fpolicy_rejected_logps.pt\")\n\n# Create trainer instance\nconfig = SimPOConfig(output_dir=\".\u002Fsimpo_output\")\ntrainer = SimPOTrainer(model=\"sshleifer\u002Ftiny-gpt2\", args=config)\n\n# Run loss function\nlosses, chosen_rewards, rejected_rewards = trainer.simpo_loss(\n    policy_chosen_logps,\n    policy_rejected_logps,\n)\n\n# Verify and save\nassert losses.shape == (100,)  # Batch size 100\nnp.savez(\"\u002Froot\u002Floss.npz\", losses=losses.detach().cpu().numpy())\n```\n\n### Why Fixed Tensors?\n1. **Reproducibility**: Same input → Same output every time\n2. **Verification**: Can compare against expected values\n3. **Debugging**: Fixed values make it easy to trace issues\n4. **CI\u002FCD**: Automated testing of implementation correctness\n\n## Expected Output Characteristics\n\n### Tensor Shapes\n- `losses`: (batch_size,) - one loss per sample\n- `chosen_rewards`: (batch_size,) - one reward per chosen response\n- `rejected_rewards`: (batch_size,) - one reward per rejected response\n\n### Value Ranges\nBased on unit test with 100 samples:\n- **Losses**: [0.003, 1.610] with mean ≈ 0.5\n- **Chosen rewards**: Varies with input logps and beta\n- **Rejected rewards**: Varies with input logps and beta\n\n### Numerical Properties\n- All losses should be positive (range: [0, ∞))\n- No NaN or Inf values\n- Gradients should flow properly for backprop\n\n## Verification Steps\n\n### 1. Output File Validation\n```python\nimport numpy as np\n\ndata = np.load('\u002Froot\u002Floss.npz')\nassert 'losses' in data, \"Missing 'losses' key\"\nlosses = data['losses']\n\nassert losses.dtype in [np.float32, np.float64], f\"Wrong dtype: {losses.dtype}\"\nassert losses.shape == (100,), f\"Wrong shape: {losses.shape}\"\nassert np.all(losses > 0), \"Negative losses found!\"\nassert not np.isnan(losses).any(), \"NaN values found!\"\nassert not np.isinf(losses).any(), \"Inf values found!\"\n\nprint(\"✓ All validations passed!\")\n```\n\n### 2. Loss Computation Verification\n```python\n# Manually compute loss for first sample\nbeta = 2.0\ngamma = beta * 0.25  # default gamma_beta_ratio\nchosen_logp = policy_chosen_logps[0].item()\nrejected_logp = policy_rejected_logps[0].item()\n\nchosen_reward = beta * chosen_logp\nrejected_reward = beta * rejected_logp\nreward_diff = chosen_reward - rejected_reward - gamma\n\nexpected_loss = -np.log(1 \u002F (1 + np.exp(-reward_diff)))\ncomputed_loss = losses[0].item()\n\nassert np.isclose(expected_loss, computed_loss, rtol=1e-5), \\\n    f\"Loss mismatch: {expected_loss} vs {computed_loss}\"\n```\n\n### 3. Environment Reproducibility\nSave Python environment information:\n```bash\npython -VV > python_info.txt\npython -m pip freeze >> python_info.txt\n```\n\nThis allows exact reproduction of the test:\n- Python version: 3.12.3\n- PyTorch: 2.2.2+cpu\n- Transformers: 4.44.2\n- NumPy: 1.26.4\n\n## Running the Test\n\n### Using unittest\n```bash\ncd \u002Froot\u002FSimPO\npython3 -m unittest unit_test.unit_test_1.TestModelOutputs.test_random_pairs -v\n```\n\n### Manual Test\n```python\npython3 \u003C\u003C 'EOF'\nfrom unit_test.unit_test_1 import TestModelOutputs\nimport unittest\n\n# Create test suite\nsuite = unittest.TestSuite()\nsuite.addTest(TestModelOutputs('test_random_pairs'))\n\n# Run with verbose output\nrunner = unittest.TextTestRunner(verbosity=2)\nresult = runner.run(suite)\n\n# Check result\nif result.wasSuccessful():\n    print(\"\\n✓ Test passed successfully!\")\nelse:\n    print(\"\\n✗ Test failed!\")\n    for error in result.errors:\n        print(f\"Error: {error[1]}\")\nEOF\n```\n\n## Troubleshooting\n\n### Issue: ImportError for torch\u002Ftransformers\n**Solution**: Install packages\n```bash\npip install torch transformers trl numpy\n```\n\n### Issue: Model loading fails\n**Solution**: Use tiny-gpt2 for testing (small, fast to load)\n```python\nmodel = \"sshleifer\u002Ftiny-gpt2\"  # ~10MB, trains instantly\n```\n\n### Issue: Loss values seem wrong\n**Verification**: Check formula\n```\nloss = -log(sigmoid(chosen_reward - rejected_reward - gamma))\n```\nShould be positive, typically 0.01 to 2.0 range.\n\n### Issue: Numerical instability\n**Cause**: Using `log(sigmoid())` directly\n**Solution**: Already fixed in implementation via `F.logsigmoid()`\n","# SimPO Testing and Verification Framework\n\n## Fixed-Input Unit Testing\n\nThe SimPO implementation uses **pre-computed fixed tensors** for deterministic testing:\n\n### Test Structure\n```python\n# Load pre-computed tensors\npolicy_chosen_logps = torch.load(\"unit_test\u002Ftensors\u002Fpolicy_chosen_logps.pt\")\npolicy_rejected_logps = torch.load(\"unit_test\u002Ftensors\u002Fpolicy_rejected_logps.pt\")\n\n# Create trainer instance\nconfig = SimPOConfig(output_dir=\".\u002Fsimpo_output\")\ntrainer = SimPOTrainer(model=\"sshleifer\u002Ftiny-gpt2\", args=config)\n\n# Run loss function\nlosses, chosen_rewards, rejected_rewards = trainer.simpo_loss(\n    policy_chosen_logps,\n    policy_rejected_logps,\n)\n\n# Verify and save\nassert losses.shape == (100,)  # Batch size 100\nnp.savez(\"\u002Froot\u002Floss.npz\", losses=losses.detach().cpu().numpy())\n```\n\n### Why Fixed Tensors?\n1. **Reproducibility**: Same input → Same output every time\n2. **Verification**: Can compare against expected values\n3. **Debugging**: Fixed values make it easy to trace issues\n4. **CI\u002FCD**: Automated testing of implementation correctness\n\n## Expected Output Characteristics\n\n### Tensor Shapes\n- `losses`: (batch_size,) - one loss per sample\n- `chosen_rewards`: (batch_size,) - one reward per chosen response\n- `rejected_rewards`: (batch_size,) - one reward per rejected response\n\n### Value Ranges\nBased on unit test with 100 samples:\n- **Losses**: [0.003, 1.610] with mean ≈ 0.5\n- **Chosen rewards**: Varies with input logps and beta\n- **Rejected rewards**: Varies with input logps and beta\n\n### Numerical Properties\n- All losses should be positive (range: [0, ∞))\n- No NaN or Inf values\n- Gradients should flow properly for backprop\n\n## Verification Steps\n\n### 1. Output File Validation\n```python\nimport numpy as np\n\ndata = np.load('\u002Froot\u002Floss.npz')\nassert 'losses' in data, \"Missing 'losses' key\"\nlosses = data['losses']\n\nassert losses.dtype in [np.float32, np.float64], f\"Wrong dtype: {losses.dtype}\"\nassert losses.shape == (100,), f\"Wrong shape: {losses.shape}\"\nassert np.all(losses > 0), \"Negative losses found!\"\nassert not np.isnan(losses).any(), \"NaN values found!\"\nassert not np.isinf(losses).any(), \"Inf values found!\"\n\nprint(\"✓ All validations passed!\")\n```\n\n### 2. Loss Computation Verification\n```python\n# Manually compute loss for first sample\nbeta = 2.0\ngamma = beta * 0.25  # default gamma_beta_ratio\nchosen_logp = policy_chosen_logps[0].item()\nrejected_logp = policy_rejected_logps[0].item()\n\nchosen_reward = beta * chosen_logp\nrejected_reward = beta * rejected_logp\nreward_diff = chosen_reward - rejected_reward - gamma\n\nexpected_loss = -np.log(1 \u002F (1 + np.exp(-reward_diff)))\ncomputed_loss = losses[0].item()\n\nassert np.isclose(expected_loss, computed_loss, rtol=1e-5), \\\n    f\"Loss mismatch: {expected_loss} vs {computed_loss}\"\n```\n\n### 3. Environment Reproducibility\nSave Python environment information:\n```bash\npython -VV > python_info.txt\npython -m pip freeze >> python_info.txt\n```\n\nThis allows exact reproduction of the test:\n- Python version: 3.12.3\n- PyTorch: 2.2.2+cpu\n- Transformers: 4.44.2\n- NumPy: 1.26.4\n\n## Running the Test\n\n### Using unittest\n```bash\ncd \u002Froot\u002FSimPO\npython3 -m unittest unit_test.unit_test_1.TestModelOutputs.test_random_pairs -v\n```\n\n### Manual Test\n```python\npython3 \u003C\u003C 'EOF'\nfrom unit_test.unit_test_1 import TestModelOutputs\nimport unittest\n\n# Create test suite\nsuite = unittest.TestSuite()\nsuite.addTest(TestModelOutputs('test_random_pairs'))\n\n# Run with verbose output\nrunner = unittest.TextTestRunner(verbosity=2)\nresult = runner.run(suite)\n\n# Check result\nif result.wasSuccessful():\n    print(\"\\n✓ Test passed successfully!\")\nelse:\n    print(\"\\n✗ Test failed!\")\n    for error in result.errors:\n        print(f\"Error: {error[1]}\")\nEOF\n```\n\n## Troubleshooting\n\n### Issue: ImportError for torch\u002Ftransformers\n**Solution**: Install packages\n```bash\npip install torch transformers trl numpy\n```\n\n### Issue: Model loading fails\n**Solution**: Use tiny-gpt2 for testing (small, fast to load)\n```python\nmodel = \"sshleifer\u002Ftiny-gpt2\"  # ~10MB, trains instantly\n```\n\n### Issue: Loss values seem wrong\n**Verification**: Check formula\n```\nloss = -log(sigmoid(chosen_reward - rejected_reward - gamma))\n```\nShould be positive, typically 0.01 to 2.0 range.\n\n### Issue: Numerical instability\n**Cause**: Using `log(sigmoid())` directly\n**Solution**: Already fixed in implementation via `F.logsigmoid()`\n",{"name":5,"description":7},"main","726e1f79b96b0cb3d729d0e55a1c847e0b5353ae","skills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fnlp-paper-reproduction\u002Frun2_simpo-testing-and-verification",8,"https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench","https:\u002F\u002Fcxcscmu.github.io\u002FSkillLearnBench","https:\u002F\u002Fgithub.com\u002Fcxcscmu","2026-10-02 22:55:36",{"source":8,"skillName":5,"commands":40,"prompt":50,"zipAvailable":51},[41,44,47],{"tool":42,"command":43},"npx","npx skills add cxcscmu\u002FSkillLearnBench --skill run2_simpo-testing-and-verification",{"tool":45,"command":46},"bunx","bunx skills add cxcscmu\u002FSkillLearnBench --skill run2_simpo-testing-and-verification",{"tool":48,"command":49},"pnpm","pnpm dlx skills add cxcscmu\u002FSkillLearnBench --skill run2_simpo-testing-and-verification","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fb2-self-feedback-claude-haiku-4-5\u002Fnlp-paper-reproduction\u002Frun2_simpo-testing-and-verification\u002FSKILL.md",true,[],[54,67,89,107,126,137],{"skillNo":55,"name":56,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":26},"01M6KM5KH175P5ABP5JMX2SBDQ","object_counter","Count occurrences of an object in the image using computer vision algorithm.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Fvideo-object-counting\u002Fobject_counter\u002FSKILL.md",[],[61,62,63,64,65,66],"object counter","object","vision","computer","Computer Vision","image",{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":71,"categories":72,"keywords":73,"publishedAt":26},"01M6KM51TMVXG79MMPCS6Y8G86","travel-planning-workflow","Invoke this skill when performing travel planning. It defines a structured workflow for generating itineraries. Following this workflow is essential to ensure the final plan satisfies user requirements.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Ftravel-planning-workflow\u002FSKILL.md",[],[74,75,76,77,78,79,80,81,82,83,84,85,86,87,88],"workflow","planning","planning workflow","travel","travel planning","travel planning workflow","structured","performing","plan","for","user","it","requirements","essential","itineraries",{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":26},"01M6KM4DY820XHS9YTSK5QP5HD","bundled-dataset-search-tool","invoke this skill when you need to perform database search for travel planning. This skill provides some useful pre-packaged tools to look up accommodations, attractions, cities, driving distance, flights, and restaurants from the bundled dataset.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftravel-planning\u002Fbundled-dataset-search-tool\u002FSKILL.md",[],[96,97,98,99,100,101,102,77,103,104,78,105,83,106,75],"search","tool","dataset","bundled dataset search tool","restaurants","Tools","up","look","flights","you","database",{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":111,"categories":112,"keywords":113,"publishedAt":26},"01M6KM465BB9PQ0B548HQSVAWZ","glm-output","Output-processing guidance for GLM tasks. Especially useful after glm-basics and glm-calibration when you need verifier-matching metrics from output.nc and a final \u002Froot\u002Fmetrics.json.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-output\u002FSKILL.md",[],[114,22,115,83,116,117,118,119,120,121,122,123,105,124,125],"glm output","glm","tasks","metrics","json","basics","guidance","matching","verifier","processing","root","calibration",{"skillNo":127,"name":128,"nameZh":6,"description":129,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":130,"categories":131,"keywords":132,"publishedAt":26},"01M6KM40KY3QWDW5W97S39R2BC","glm-calibration","Calibration guidance for GLM tasks. Often most effective after glm-basics has clarified the setup; glm-output is the companion skill for exact final metric computation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-calibration\u002FSKILL.md",[],[133,125,115,22,120,119,116,134,135,83,136],"glm calibration","setup","companion","metric",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":26},"01M6KM3VHHVSGMGHJQB3PPT6YG","glm-basics","A good starting point for GLM calibration tasks. Use to inspect glm3.nml, confirm how GLM runs, and identify the relevant files before moving on to calibration and output evaluation.","https:\u002F\u002Fgithub.com\u002Fcxcscmu\u002FSkillLearnBench\u002Fblob\u002Fmain\u002Fskills\u002Fhuman_authored\u002Ftemperature-simulation\u002Fglm-basics\u002FSKILL.md",[],[144,115,119,145,133,125,83,22,146,147,148,149,150,151,116],"glm basics","inspect","relevant","files","good","use","how","Evaluation"]