Merge branch 'feat/qlora-training'
This commit is contained in:
commit
7dfcaace50
|
|
@ -34,7 +34,6 @@ Python → C++ stdin:
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import math
|
import math
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
@ -99,6 +98,7 @@ def read_ipc(proc: subprocess.Popen, timeout: float = 120.0) -> Optional[Tuple[s
|
||||||
Returns None on EOF.
|
Returns None on EOF.
|
||||||
Raises TimeoutError if nothing arrives within `timeout` seconds.
|
Raises TimeoutError if nothing arrives within `timeout` seconds.
|
||||||
"""
|
"""
|
||||||
|
assert proc.stdout is not None
|
||||||
deadline = time.monotonic() + timeout
|
deadline = time.monotonic() + timeout
|
||||||
while True:
|
while True:
|
||||||
remaining = deadline - time.monotonic()
|
remaining = deadline - time.monotonic()
|
||||||
|
|
@ -120,6 +120,7 @@ def read_ipc(proc: subprocess.Popen, timeout: float = 120.0) -> Optional[Tuple[s
|
||||||
|
|
||||||
def write_cmd(proc: subprocess.Popen, cmd: str):
|
def write_cmd(proc: subprocess.Popen, cmd: str):
|
||||||
"""Write one command line to the subprocess stdin."""
|
"""Write one command line to the subprocess stdin."""
|
||||||
|
assert proc.stdin is not None
|
||||||
try:
|
try:
|
||||||
proc.stdin.write(cmd + "\n")
|
proc.stdin.write(cmd + "\n")
|
||||||
proc.stdin.flush()
|
proc.stdin.flush()
|
||||||
|
|
@ -268,7 +269,8 @@ def run_grpo(args: argparse.Namespace):
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
try:
|
try:
|
||||||
proc.stdin.close()
|
if proc.stdin is not None:
|
||||||
|
proc.stdin.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
rc = proc.wait(timeout=30)
|
rc = proc.wait(timeout=30)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue