{
  "id": 571289,
  "title": "21st Place Solution",
  "content": "<p>Thanks to all participants, especially those who created awesome notebooks, models and engaging discussions. I learned a lot. Thanks to Kaggle and the Host for their continued support throughout this long, challenging but exciting competition.</p>\n<p>I developed many approaches some of which drew inspiration from discussions and public notebooks. Below I mainly share my successful approach so far with <strong>public score 28</strong>.</p>\n<h2>Final Approach: Logits Distillation from Qwen-QWQ 32B into DeepSeekR1-Distill-Qwen14B</h2>\n<p>Since the idea is to learn how  Qwen-QWQ 32B solves problems, I needed problems that are relevant for the AIMO2 competition. Hence, I included the reference set as well, see below</p>\n<h3>Datasets</h3>\n<ul>\n<li>Random 6% (random seed 42) of Problems from <a href=\"https://huggingface.co/datasets/open-r1/OpenR1-Math-220k\" target=\"_blank\">OpenR1 Dataset</a> where DeepSeek-R1 found the right answer + AIMO2 Reference Set + <a href=\"https://huggingface.co/datasets/Maxwell-Jia/AIME_2024\" target=\"_blank\">AIME2024</a> + <a href=\"https://huggingface.co/datasets/opencompass/AIME2025\" target=\"_blank\">AIME2025</a>.</li>\n<li>Total Dataset Size: 5274</li>\n</ul>\n<h3>Main Methodology</h3>\n<p><strong>1. Initialize three models on shared GPUs as follows</strong></p>\n<ul>\n<li>Qwen-QWQ 32B-AWQ loaded via vLLM (teacher model for text generation)</li>\n<li>Qwen-QWQ 32B-AWQ loaded with AutoModelForCausalLM (teacher for logits computation)</li>\n<li>DeepSeekR1-Distill-Qwen14B (student model)</li>\n</ul>\n<p><strong>2. Generate text, form inputs, forward and compute loss</strong></p>\n<ul>\n<li>For each input problem, create a prompt, including system message and ask Teacher Model to solve the problem (using vLLM for faster inference)</li>\n<li>Use Teacher Model (AutoModelForCausalLM instance) to get logits of tokens present in the generated text + prompt</li>\n<li>Call Student Model to compute logits for the same input text (again, the prompt and solution are included as inputs for logits computation)</li>\n<li>Compute KL divergence between student logits and teacher logits</li>\n</ul>\n<h3>Training Details</h3>\n<pre><code>SYSTEM_PROMPT = \n\nMAX_SEQ_LEN =  \n\nsampling_params = SamplingParams(max_tokens=MAX_SEQ_LEN, temperature=, skip_special_tokens=)\n\ngenerated_text = teacher_model.generate(\n            prompts=teacher_prompt,\n            sampling_params=sampling_params\n        )\n\n\n\nteacher_logits = teacher_logits_model(input_ids=teacher_input_ids, attention_mask=teacher_attention_mask).logits\n\nstudent_logits = model(input_ids=student_input_ids, attention_mask=student_attention_mask).logits\n\nstudent_log_logits = torch.nn.functional.log_softmax(student_logits, dim=-).to()\nteacher_log_logits = torch.nn.functional.log_softmax(teacher_logits, dim=-).to()\n\nloss = torch.nn.functional.kl_div(student_log_logits, teacher_log_logits, log_target=, reduction=)\n\ntraining_args = TrainingArguments(\n    output_dir=,\n    per_device_train_batch_size=,\n    num_train_epochs=,\n    logging_dir=,\n    logging_steps=,\n    learning_rate=,\n    weight_decay=,\n    save_strategy=,\n    save_steps=,\n    remove_unused_columns=,\n    report_to=,\n)\n</code></pre>\n<h3>Linear Weight Ensembling: <strong>This is what really stood out</strong></h3>\n<ul>\n<li>I kept checkpoints at different training steps and averaged model weights from those</li>\n<li>Averaged checkpoints are: 0.1*ckpt-20 + 0.1*ckpt-180 + 0.1*ckpt-260 + 0.1*ckpt-280 + 0.1*ckpt-360 + 0.1*ckpt-640 + 0.1*ckpt-1840 + 0.1*ckpt-2300 + 0.2*last-ckpt</li>\n</ul>\n<h3>Evaluation with Quantized Distilled Qwen14B Model</h3>\n<ul>\n<li><p>AIME2024/2025: 43/60</p></li>\n<li><p>Reference Set: 7/10</p></li>\n<li><p>Public LB: 28 (with max_seq_len=8192*3//2 + 1024, top_p=0.9, min_p=0.05, temperature=1.0). I also used vLLM Engine class (not LLM) and could cancel requests when a given answer reaches 33% (frequency) w.r.t. <code>max_num_seqs=12</code></p></li>\n</ul>\n<h2>Final Thoughts</h2>\n<ul>\n<li>I could have trained longer. Unfortunately, I got the idea during the last week of the competition</li>\n<li>Training longer could improve performance</li>\n<li>Larger learning rate (1e-5) resulted in a poor-performing 7B model. Did not try it with the 14B model</li>\n</ul>\n<h2>What Did Not Work:</h2>\n<ul>\n<li>Supervised Finetuning with DeepSeek-R1-Distill-Qwen7B</li>\n<li>GRPO with DeepSeek-R1-Distill-Qwen7B</li>\n<li>Mergekit (slerp, sce) with my 14B model checkpoints, score dropped to 20</li>\n</ul>",
  "comments": [
    {
      "id": 3168534,
      "author_name": "白夜",
      "author_url": "",
      "post_date": "2025-04-02T14:33:11.467000",
      "content": "<p>Did distillation and linear weighting improve stability? We can also achieve 27 points using the early stopping strategy of vLLM Engine.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 3168542,
          "author_name": "白夜",
          "author_url": "",
          "post_date": "2025-04-02T14:41:32.160000",
          "content": "<p>Based on my understanding, the distillation here seems to be a method for controlling the generation length in low-resource scenarios. What inspired you to use distillation in this competition?</p>",
          "votes": 0,
          "replies": [
            {
              "id": 3168595,
              "author_name": "JK-Piece",
              "author_url": "",
              "post_date": "2025-04-02T15:29:46.023000",
              "content": "<p>Not only generation length in my settings. Also the \"approach to problem solving\"</p>",
              "votes": 0,
              "replies": []
            }
          ]
        },
        {
          "id": 3168599,
          "author_name": "JK-Piece",
          "author_url": "",
          "post_date": "2025-04-02T15:30:54.900000",
          "content": "<p>Unfortunately I only had 2 trials with my model. Training completed in the last days of the competition. So stability has not been fully tested </p>",
          "votes": 0,
          "replies": [
            {
              "id": 3168600,
              "author_name": "JK-Piece",
              "author_url": "",
              "post_date": "2025-04-02T15:33:20.793000",
              "content": "<p>First trial scored 28. Then in second trial I used top_k=20 and got a score of 25. I believe distillation worked. This is why:<br>\n1- I was not able to achieve 28 before training, with my evaluation settings.<br>\n2- The loss decreased during training. Loss started around 40k and decreased to 20k-25k depending on running batch </p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 3273944,
      "author_name": "CaspianZero",
      "author_url": "",
      "post_date": "2025-08-23T16:47:39.683000",
      "content": "<p>Very good idea, would like to learn from you, may I ask how the Linear Weight Ensembling part code is implemented.</p>",
      "votes": 0,
      "replies": []
    },
    {
      "id": 3168585,
      "author_name": "ducnh279",
      "author_url": "",
      "post_date": "2025-04-02T15:19:20.573000",
      "content": "<blockquote>\n  <p>Averaged checkpoints are: 0.1<em>ckpt-20 + 0.1</em>ckpt-180 + 0.1<em>ckpt-260 + 0.1</em>ckpt-280 + 0.1<em>ckpt-360 + 0.1</em>ckpt-640 + 0.1<em>ckpt-1840 + 0.1</em>ckpt-2300 + 0.2*last-ckpt</p>\n</blockquote>\n<p>Simple and beautiful solution using knowledge distillation!</p>\n<p>Do you compare the performance between <code>Averaged checkpoints</code> vs only  <code>last-ckpt</code> on the public leaderboard?</p>",
      "votes": 0,
      "replies": [
        {
          "id": 3169973,
          "author_name": "JK-Piece",
          "author_url": "",
          "post_date": "2025-04-04T05:58:23.947000",
          "content": "<p>Yes. I did that. Last epoch scored 22 though I didn't have time to evaluate further </p>",
          "votes": 1,
          "replies": [
            {
              "id": 3169996,
              "author_name": "ducnh279",
              "author_url": "",
              "post_date": "2025-04-04T06:49:14.727000",
              "content": "<p>Wow, weighted averaging of checkpoints seems to be quite effective! Thanks for sharing this technique!</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 3168562,
      "author_name": "jyf",
      "author_url": "",
      "post_date": "2025-04-02T15:04:09.030000",
      "content": "<p>How did you implement early stopping based on consensus? I tried the asynchronous engine and it was not faster.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 3168610,
          "author_name": "JK-Piece",
          "author_url": "",
          "post_date": "2025-04-02T15:47:32.417000",
          "content": "<p>So this is how I implemented early stopping:</p>\n<pre><code> ():\n    \n    request_id = \n    outputs = []\n    output_lengths = []\n    inner_start_time = time.time()\n    killed_req_id = MAX_NUM_SEQS - \n     prompts  engine.has_unfinished_requests():\n         prompts:\n            prompt, sampling_params = prompts.pop()\n            engine.add_request((request_id),\n                               tokenizer.apply_chat_template(conversation=prompt, tokenize=, add_generation_prompt=),\n                               sampling_params)\n            request_id += \n\n         time.time()-inner_start_time &gt;= :\n            (++++)\n             killed_req_id &gt;= :\n                :\n                    engine.abort_request((killed_req_id))\n                 Exception  e:\n                    (+(e))\n                    \n                killed_req_id -= \n                time.sleep()\n            (++++)\n\n        request_outputs = engine.step()\n         i, request_output  (request_outputs):\n             request_output.finished:\n                outputs.append(request_output.outputs[].text)\n                output_lengths.append((request_output.outputs[].token_ids))\n\n         (outputs) &gt; request_id/:\n            \n            list_of_idx = (((outputs)))\n            _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n\n            answer_stats = Counter(extracted_answers)\n            answer_stats = ([(k,v)  k,v  answer_stats.items()], key= x: -x[])\n\n             answer_stats  answer_stats[][] &gt; request_id/:\n                (++++)\n                trials = \n                 engine.has_unfinished_requests():\n                    ()\n                     req_id  (request_id):\n                        :\n                            engine.abort_request((req_id))\n                         Exception  e:\n                            (+(e))\n                            \n                        time.sleep()\n                    trials += \n                     trials &gt; :\n                        ()\n                        \n                (++++)\n                (, output_lengths)\n                 extracted_answers\n\n\n    list_of_idx = (((outputs)))\n    _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n    (, output_lengths)\n     extracted_answers\n</code></pre>\n<p>Will share the complete code soon!</p>",
          "votes": 2,
          "replies": [
            {
              "id": 3169244,
              "author_name": "AI-Cat",
              "author_url": "",
              "post_date": "2025-04-03T08:59:44.360000",
              "content": "<p>Great code!</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 3169348,
              "author_name": "JK-Piece",
              "author_url": "",
              "post_date": "2025-04-03T11:47:35.060000",
              "content": "<p>Thanks. Looking forward to your code too</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "comment_count": 13,
  "messages": [
    {
      "id": 3168410,
      "postDate": "2025-04-02T12:00:01.207Z",
      "content": "<p>Thanks to all participants, especially those who created awesome notebooks, models and engaging discussions. I learned a lot. Thanks to Kaggle and the Host for their continued support throughout this long, challenging but exciting competition.</p>\n<p>I developed many approaches some of which drew inspiration from discussions and public notebooks. Below I mainly share my successful approach so far with <strong>public score 28</strong>.</p>\n<h2>Final Approach: Logits Distillation from Qwen-QWQ 32B into DeepSeekR1-Distill-Qwen14B</h2>\n<p>Since the idea is to learn how  Qwen-QWQ 32B solves problems, I needed problems that are relevant for the AIMO2 competition. Hence, I included the reference set as well, see below</p>\n<h3>Datasets</h3>\n<ul>\n<li>Random 6% (random seed 42) of Problems from <a href=\"https://huggingface.co/datasets/open-r1/OpenR1-Math-220k\" target=\"_blank\">OpenR1 Dataset</a> where DeepSeek-R1 found the right answer + AIMO2 Reference Set + <a href=\"https://huggingface.co/datasets/Maxwell-Jia/AIME_2024\" target=\"_blank\">AIME2024</a> + <a href=\"https://huggingface.co/datasets/opencompass/AIME2025\" target=\"_blank\">AIME2025</a>.</li>\n<li>Total Dataset Size: 5274</li>\n</ul>\n<h3>Main Methodology</h3>\n<p><strong>1. Initialize three models on shared GPUs as follows</strong></p>\n<ul>\n<li>Qwen-QWQ 32B-AWQ loaded via vLLM (teacher model for text generation)</li>\n<li>Qwen-QWQ 32B-AWQ loaded with AutoModelForCausalLM (teacher for logits computation)</li>\n<li>DeepSeekR1-Distill-Qwen14B (student model)</li>\n</ul>\n<p><strong>2. Generate text, form inputs, forward and compute loss</strong></p>\n<ul>\n<li>For each input problem, create a prompt, including system message and ask Teacher Model to solve the problem (using vLLM for faster inference)</li>\n<li>Use Teacher Model (AutoModelForCausalLM instance) to get logits of tokens present in the generated text + prompt</li>\n<li>Call Student Model to compute logits for the same input text (again, the prompt and solution are included as inputs for logits computation)</li>\n<li>Compute KL divergence between student logits and teacher logits</li>\n</ul>\n<h3>Training Details</h3>\n<pre><code>SYSTEM_PROMPT = \n\nMAX_SEQ_LEN =  \n\nsampling_params = SamplingParams(max_tokens=MAX_SEQ_LEN, temperature=, skip_special_tokens=)\n\ngenerated_text = teacher_model.generate(\n            prompts=teacher_prompt,\n            sampling_params=sampling_params\n        )\n\n\n\nteacher_logits = teacher_logits_model(input_ids=teacher_input_ids, attention_mask=teacher_attention_mask).logits\n\nstudent_logits = model(input_ids=student_input_ids, attention_mask=student_attention_mask).logits\n\nstudent_log_logits = torch.nn.functional.log_softmax(student_logits, dim=-).to()\nteacher_log_logits = torch.nn.functional.log_softmax(teacher_logits, dim=-).to()\n\nloss = torch.nn.functional.kl_div(student_log_logits, teacher_log_logits, log_target=, reduction=)\n\ntraining_args = TrainingArguments(\n    output_dir=,\n    per_device_train_batch_size=,\n    num_train_epochs=,\n    logging_dir=,\n    logging_steps=,\n    learning_rate=,\n    weight_decay=,\n    save_strategy=,\n    save_steps=,\n    remove_unused_columns=,\n    report_to=,\n)\n</code></pre>\n<h3>Linear Weight Ensembling: <strong>This is what really stood out</strong></h3>\n<ul>\n<li>I kept checkpoints at different training steps and averaged model weights from those</li>\n<li>Averaged checkpoints are: 0.1*ckpt-20 + 0.1*ckpt-180 + 0.1*ckpt-260 + 0.1*ckpt-280 + 0.1*ckpt-360 + 0.1*ckpt-640 + 0.1*ckpt-1840 + 0.1*ckpt-2300 + 0.2*last-ckpt</li>\n</ul>\n<h3>Evaluation with Quantized Distilled Qwen14B Model</h3>\n<ul>\n<li><p>AIME2024/2025: 43/60</p></li>\n<li><p>Reference Set: 7/10</p></li>\n<li><p>Public LB: 28 (with max_seq_len=8192*3//2 + 1024, top_p=0.9, min_p=0.05, temperature=1.0). I also used vLLM Engine class (not LLM) and could cancel requests when a given answer reaches 33% (frequency) w.r.t. <code>max_num_seqs=12</code></p></li>\n</ul>\n<h2>Final Thoughts</h2>\n<ul>\n<li>I could have trained longer. Unfortunately, I got the idea during the last week of the competition</li>\n<li>Training longer could improve performance</li>\n<li>Larger learning rate (1e-5) resulted in a poor-performing 7B model. Did not try it with the 14B model</li>\n</ul>\n<h2>What Did Not Work:</h2>\n<ul>\n<li>Supervised Finetuning with DeepSeek-R1-Distill-Qwen7B</li>\n<li>GRPO with DeepSeek-R1-Distill-Qwen7B</li>\n<li>Mergekit (slerp, sce) with my 14B model checkpoints, score dropped to 20</li>\n</ul>",
      "rawMarkdown": "Thanks to all participants, especially those who created awesome notebooks, models and engaging discussions. I learned a lot. Thanks to Kaggle and the Host for their continued support throughout this long, challenging but exciting competition.\n\nI developed many approaches some of which drew inspiration from discussions and public notebooks. Below I mainly share my successful approach so far with **public score 28**.\n\n## Final Approach: Logits Distillation from Qwen-QWQ 32B into DeepSeekR1-Distill-Qwen14B\n\nSince the idea is to learn how  Qwen-QWQ 32B solves problems, I needed problems that are relevant for the AIMO2 competition. Hence, I included the reference set as well, see below\n\n### Datasets\n- Random 6% (random seed 42) of Problems from [OpenR1 Dataset] (https://huggingface.co/datasets/open-r1/OpenR1-Math-220k) where DeepSeek-R1 found the right answer + AIMO2 Reference Set + [AIME2024](https://huggingface.co/datasets/Maxwell-Jia/AIME_2024) + [AIME2025](https://huggingface.co/datasets/opencompass/AIME2025).\n- Total Dataset Size: 5274\n\n### Main Methodology\n**1. Initialize three models on shared GPUs as follows**\n\n- Qwen-QWQ 32B-AWQ loaded via vLLM (teacher model for text generation)\n- Qwen-QWQ 32B-AWQ loaded with AutoModelForCausalLM (teacher for logits computation)\n- DeepSeekR1-Distill-Qwen14B (student model)\n\n**2. Generate text, form inputs, forward and compute loss**\n\n- For each input problem, create a prompt, including system message and ask Teacher Model to solve the problem (using vLLM for faster inference)\n- Use Teacher Model (AutoModelForCausalLM instance) to get logits of tokens present in the generated text + prompt\n- Call Student Model to compute logits for the same input text (again, the prompt and solution are included as inputs for logits computation)\n- Compute KL divergence between student logits and teacher logits\n\n### Training Details\n```python\nSYSTEM_PROMPT = \"\"\"You are the most powerful math expert. Please solve the problems with deep reasoning. You are careful and always recheck your conduction. You will never give answer directly until you have enough confidence. You should think step-by-step. Return final answer within \\\\boxed{} after taking modulo 1000.\"\"\"\n\nMAX_SEQ_LEN = 4096 # maximum sequence length in teacher text generation\n\nsampling_params = SamplingParams(max_tokens=MAX_SEQ_LEN, temperature=0.7, skip_special_tokens=False)\n\ngenerated_text = teacher_model.generate(\n            prompts=teacher_prompt,\n            sampling_params=sampling_params\n        )\n\n# Now use tokenizers from teacher model and student model to get input_ids and attention_mask\n\nteacher_logits = teacher_logits_model(input_ids=teacher_input_ids, attention_mask=teacher_attention_mask).logits\n\nstudent_logits = model(input_ids=student_input_ids, attention_mask=student_attention_mask).logits\n\nstudent_log_logits = torch.nn.functional.log_softmax(student_logits, dim=-1).to('cuda')\nteacher_log_logits = torch.nn.functional.log_softmax(teacher_logits, dim=-1).to('cuda')\n\nloss = torch.nn.functional.kl_div(student_log_logits, teacher_log_logits, log_target=True, reduction='batchmean')\n\ntraining_args = TrainingArguments(\n    output_dir=\"./qwen14b_distilled\",\n    per_device_train_batch_size=2,\n    num_train_epochs=1,\n    logging_dir=\"./logs\",\n    logging_steps=1,\n    learning_rate=1e-6,\n    weight_decay=0.01,\n    save_strategy=\"steps\",\n    save_steps=20,\n    remove_unused_columns=False,\n    report_to=\"none\",\n)\n```\n### Linear Weight Ensembling: **This is what really stood out**\n- I kept checkpoints at different training steps and averaged model weights from those\n- Averaged checkpoints are: 0.1\\*ckpt-20 + 0.1\\*ckpt-180 + 0.1\\*ckpt-260 + 0.1\\*ckpt-280 + 0.1\\*ckpt-360 + 0.1\\*ckpt-640 + 0.1\\*ckpt-1840 + 0.1\\*ckpt-2300 + 0.2\\*last-ckpt\n\n### Evaluation with Quantized Distilled Qwen14B Model\n\n- AIME2024/2025: 43/60\n\n- Reference Set: 7/10\n\n- Public LB: 28 (with max_seq_len=8192*3//2 + 1024, top_p=0.9, min_p=0.05, temperature=1.0). I also used vLLM Engine class (not LLM) and could cancel requests when a given answer reaches 33% (frequency) w.r.t. ```max_num_seqs=12```\n\n## Final Thoughts\n- I could have trained longer. Unfortunately, I got the idea during the last week of the competition\n- Training longer could improve performance\n- Larger learning rate (1e-5) resulted in a poor-performing 7B model. Did not try it with the 14B model\n\n## What Did Not Work:\n- Supervised Finetuning with DeepSeek-R1-Distill-Qwen7B\n- GRPO with DeepSeek-R1-Distill-Qwen7B\n- Mergekit (slerp, sce) with my 14B model checkpoints, score dropped to 20",
      "votes": 24
    },
    {
      "id": 3168534,
      "postDate": "2025-04-02T14:33:11.467Z",
      "content": "<p>Did distillation and linear weighting improve stability? We can also achieve 27 points using the early stopping strategy of vLLM Engine.</p>",
      "rawMarkdown": "Did distillation and linear weighting improve stability? We can also achieve 27 points using the early stopping strategy of vLLM Engine.",
      "votes": 1,
      "replies": [
        {
          "id": 3168542,
          "postDate": "2025-04-02T14:41:32.160Z",
          "content": "<p>Based on my understanding, the distillation here seems to be a method for controlling the generation length in low-resource scenarios. What inspired you to use distillation in this competition?</p>",
          "rawMarkdown": "Based on my understanding, the distillation here seems to be a method for controlling the generation length in low-resource scenarios. What inspired you to use distillation in this competition?",
          "replies": [
            {
              "id": 3168595,
              "postDate": "2025-04-02T15:29:46.023Z",
              "content": "<p>Not only generation length in my settings. Also the \"approach to problem solving\"</p>",
              "rawMarkdown": "Not only generation length in my settings. Also the \"approach to problem solving\""
            }
          ]
        },
        {
          "id": 3168599,
          "postDate": "2025-04-02T15:30:54.900Z",
          "content": "<p>Unfortunately I only had 2 trials with my model. Training completed in the last days of the competition. So stability has not been fully tested </p>",
          "rawMarkdown": "Unfortunately I only had 2 trials with my model. Training completed in the last days of the competition. So stability has not been fully tested ",
          "replies": [
            {
              "id": 3168600,
              "postDate": "2025-04-02T15:33:20.793Z",
              "content": "<p>First trial scored 28. Then in second trial I used top_k=20 and got a score of 25. I believe distillation worked. This is why:<br>\n1- I was not able to achieve 28 before training, with my evaluation settings.<br>\n2- The loss decreased during training. Loss started around 40k and decreased to 20k-25k depending on running batch </p>",
              "rawMarkdown": "First trial scored 28. Then in second trial I used top_k=20 and got a score of 25. I believe distillation worked. This is why:\n1- I was not able to achieve 28 before training, with my evaluation settings.\n2- The loss decreased during training. Loss started around 40k and decreased to 20k-25k depending on running batch "
            }
          ]
        }
      ]
    },
    {
      "id": 3273944,
      "postDate": "2025-08-23T16:47:39.683Z",
      "content": "<p>Very good idea, would like to learn from you, may I ask how the Linear Weight Ensembling part code is implemented.</p>",
      "rawMarkdown": "Very good idea, would like to learn from you, may I ask how the Linear Weight Ensembling part code is implemented."
    },
    {
      "id": 3168585,
      "postDate": "2025-04-02T15:19:20.573Z",
      "content": "<blockquote>\n  <p>Averaged checkpoints are: 0.1<em>ckpt-20 + 0.1</em>ckpt-180 + 0.1<em>ckpt-260 + 0.1</em>ckpt-280 + 0.1<em>ckpt-360 + 0.1</em>ckpt-640 + 0.1<em>ckpt-1840 + 0.1</em>ckpt-2300 + 0.2*last-ckpt</p>\n</blockquote>\n<p>Simple and beautiful solution using knowledge distillation!</p>\n<p>Do you compare the performance between <code>Averaged checkpoints</code> vs only  <code>last-ckpt</code> on the public leaderboard?</p>",
      "rawMarkdown": "> Averaged checkpoints are: 0.1*ckpt-20 + 0.1*ckpt-180 + 0.1*ckpt-260 + 0.1*ckpt-280 + 0.1*ckpt-360 + 0.1*ckpt-640 + 0.1*ckpt-1840 + 0.1*ckpt-2300 + 0.2*last-ckpt\n\nSimple and beautiful solution using knowledge distillation!\n\nDo you compare the performance between `Averaged checkpoints` vs only  `last-ckpt` on the public leaderboard?",
      "replies": [
        {
          "id": 3169973,
          "postDate": "2025-04-04T05:58:23.947Z",
          "content": "<p>Yes. I did that. Last epoch scored 22 though I didn't have time to evaluate further </p>",
          "rawMarkdown": "Yes. I did that. Last epoch scored 22 though I didn't have time to evaluate further ",
          "votes": 1,
          "replies": [
            {
              "id": 3169996,
              "postDate": "2025-04-04T06:49:14.727Z",
              "content": "<p>Wow, weighted averaging of checkpoints seems to be quite effective! Thanks for sharing this technique!</p>",
              "rawMarkdown": "Wow, weighted averaging of checkpoints seems to be quite effective! Thanks for sharing this technique!\n\n\n\n\n\n\n\n"
            }
          ]
        }
      ]
    },
    {
      "id": 3168562,
      "postDate": "2025-04-02T15:04:09.030Z",
      "content": "<p>How did you implement early stopping based on consensus? I tried the asynchronous engine and it was not faster.</p>",
      "rawMarkdown": "How did you implement early stopping based on consensus? I tried the asynchronous engine and it was not faster.",
      "replies": [
        {
          "id": 3168610,
          "postDate": "2025-04-02T15:47:32.417Z",
          "content": "<p>So this is how I implemented early stopping:</p>\n<pre><code> ():\n    \n    request_id = \n    outputs = []\n    output_lengths = []\n    inner_start_time = time.time()\n    killed_req_id = MAX_NUM_SEQS - \n     prompts  engine.has_unfinished_requests():\n         prompts:\n            prompt, sampling_params = prompts.pop()\n            engine.add_request((request_id),\n                               tokenizer.apply_chat_template(conversation=prompt, tokenize=, add_generation_prompt=),\n                               sampling_params)\n            request_id += \n\n         time.time()-inner_start_time &gt;= :\n            (++++)\n             killed_req_id &gt;= :\n                :\n                    engine.abort_request((killed_req_id))\n                 Exception  e:\n                    (+(e))\n                    \n                killed_req_id -= \n                time.sleep()\n            (++++)\n\n        request_outputs = engine.step()\n         i, request_output  (request_outputs):\n             request_output.finished:\n                outputs.append(request_output.outputs[].text)\n                output_lengths.append((request_output.outputs[].token_ids))\n\n         (outputs) &gt; request_id/:\n            \n            list_of_idx = (((outputs)))\n            _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n\n            answer_stats = Counter(extracted_answers)\n            answer_stats = ([(k,v)  k,v  answer_stats.items()], key= x: -x[])\n\n             answer_stats  answer_stats[][] &gt; request_id/:\n                (++++)\n                trials = \n                 engine.has_unfinished_requests():\n                    ()\n                     req_id  (request_id):\n                        :\n                            engine.abort_request((req_id))\n                         Exception  e:\n                            (+(e))\n                            \n                        time.sleep()\n                    trials += \n                     trials &gt; :\n                        ()\n                        \n                (++++)\n                (, output_lengths)\n                 extracted_answers\n\n\n    list_of_idx = (((outputs)))\n    _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n    (, output_lengths)\n     extracted_answers\n</code></pre>\n<p>Will share the complete code soon!</p>",
          "rawMarkdown": "So this is how I implemented early stopping:\n\n```python\ndef process_requests(prompts):\n    \"\"\"Continuously process a list of prompts and handle the outputs.\"\"\"\n    request_id = 0\n    outputs = []\n    output_lengths = []\n    inner_start_time = time.time()\n    killed_req_id = MAX_NUM_SEQS - 1\n    while prompts or engine.has_unfinished_requests():\n        if prompts:\n            prompt, sampling_params = prompts.pop(0)\n            engine.add_request(str(request_id),\n                               tokenizer.apply_chat_template(conversation=prompt, tokenize=False, add_generation_prompt=True),\n                               sampling_params)\n            request_id += 1\n\n        if time.time()-inner_start_time >= 550:\n            print(\"\\n\"+\"\\x1b[0;30;43m\"+\"Aborting all vLLM engine requests!\"+\"\\x1b[0m\"+\"\\n\")\n            while killed_req_id >= 0:\n                try:\n                    engine.abort_request(str(killed_req_id))\n                except Exception as e:\n                    print(\"\\n\"+str(e))\n                    pass\n                killed_req_id -= 1\n                time.sleep(0.05)\n            print(\"\\n\"+\"\\x1b[0;30;43m\"+\"Done.\"+\"\\x1b[0m\"+\"\\n\")\n\n        request_outputs = engine.step()\n        for i, request_output in enumerate(request_outputs):\n            if request_output.finished:\n                outputs.append(request_output.outputs[0].text)\n                output_lengths.append(len(request_output.outputs[0].token_ids))\n\n        if len(outputs) > request_id/3:\n            # Get temporary answers\n            list_of_idx = list(range(len(outputs)))\n            _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n\n            answer_stats = Counter(extracted_answers)\n            answer_stats = sorted([(k,v) for k,v in answer_stats.items()], key=lambda x: -x[1])\n\n            if answer_stats and answer_stats[0][1] > request_id/3:\n                print(\"\\n\\n\"+\"\\x1b[0;30;43m\"+\"Starting Early Stopping!\"+\"\\x1b[0m\"+\"\\n\")\n                trials = 0\n                while engine.has_unfinished_requests():\n                    print(\"...\")\n                    for req_id in range(request_id):\n                        try:\n                            engine.abort_request(str(req_id))\n                        except Exception as e:\n                            print(\"\\n\"+str(e))\n                            pass\n                        time.sleep(0.05)\n                    trials += 1\n                    if trials > 3:\n                        print(\"Did not abort successfully, stopping.\\n\")\n                        break\n                print(\"\\n\"+\"\\x1b[0;30;43m\"+\"Early Stopping Complete.\"+\"\\x1b[0m\"+\"\\n\")\n                print(\"\\nOutputs lengths: \", output_lengths)\n                return extracted_answers\n                \n                \n    list_of_idx = list(range(len(outputs)))\n    _, extracted_answers, _ = batch_message_filter(outputs, list_of_idx)\n    print(\"\\nOutputs lengths: \", output_lengths)\n    return extracted_answers\n```\nWill share the complete code soon!",
          "votes": 2,
          "replies": [
            {
              "id": 3169244,
              "postDate": "2025-04-03T08:59:44.360Z",
              "content": "<p>Great code!</p>",
              "rawMarkdown": "Great code!"
            },
            {
              "id": 3169348,
              "postDate": "2025-04-03T11:47:35.060Z",
              "content": "<p>Thanks. Looking forward to your code too</p>",
              "rawMarkdown": "Thanks. Looking forward to your code too"
            }
          ]
        }
      ]
    }
  ],
  "complete": true,
  "source": "live",
  "fetched_at": "2026-10-20T06:41:41Z",
  "competition_id": 86023,
  "competition_slug": "ai-mathematical-olympiad-progress-prize-2",
  "team_id": 12818513,
  "solution_url": "/competitions/ai-mathematical-olympiad-progress-prize-2/writeups/jk-piece-21st-place-solution"
}