Frozen notebook
Hi,
I am trying to run a LightGBM quantile regression on a Toy example but the notebook seems to be stuck and cannot finish.
import pandas as pd
import numpy as np
import os
import pyspark.sql.functions as F
from pyspark.sql import SparkSession, DataFrame
from pyspark import SparkContext
from pyspark.sql.types import DoubleType
spark_context = spark.sparkContext
sql_context = SQLContext(spark_context)
import mmlspark
import pandas as pd
import numpy as np
def xcos(x):
return x * np.cos(x)
def xsin(x):
return x * np.sin(x)
def ad_dataset(samples=4000):
ts = 1501630985
delta_time_seconds = 600
f1 = np.atleast_2d(np.random.uniform(0, 10.0, size=samples)).T
f2 = xcos(f1)
y = xsin(f1)
dy = 1.5 + 1.0 * np.random.random(y.shape)
noise = np.random.normal(0, dy)
y += noise
dates = np.linspace(ts, ts + (samples-1) * delta_time_seconds, num=samples).reshape(-1, 1)
concatenate_array = np.concatenate((dates, f1, f2, y), axis=1)
concatenate_array = concatenate_array.astype(np.float32)
df_pd = pd.DataFrame(concatenate_array, columns=["timestamp", "f1", "f2", "y"])
return df_pd
df = sql_context.createDataFrame(ad_dataset())
features = ["f1", "f2"]
from mmlspark import FastVectorAssembler, SelectColumns
from pyspark.ml import Transformer, Estimator, Pipeline
from pyspark.ml.feature import VectorAssembler
outputFeaturesName = "features"
assembler = FastVectorAssembler(inputCols = features, outputCol=outputFeaturesName)
assembledData = assembler.transform(df)
model = mmlspark.LightGBMRegressor(application='quantile',
alpha = 0.9,
featuresCol=outputFeaturesName,
labelCol="y",
learningRate=0.1,
numIterations=10,
numLeaves=31,
predictionCol='prediction').fit(assembledData)
I already contacted @imatiach-msft, this issue is just for tracking purpose.
@imatiach-msft I am hitting this as well, and can reproduce with the above notebook.
After a bit of debugging, I have observed:
- This only happens for
quantileapplication. Other regression losses work fine. - The call hanging is
Networking::GlobalSumin the serial tree learner when doingRenewTreeOutput: https://github.com/Microsoft/LightGBM/blob/master/src/treelearner/serial_tree_learner.cpp#L800 - The "small" optimization path is taken: (I have ~~8 executors~~ 2 executors with 4 cores each, and Spark generated 8 tasks,
input_sizeless than 100) https://github.com/Microsoft/LightGBM/blob/master/src/network/network.cpp#L71 - Recursive doubling is used:
- The first iterations of the loop work fine, up to the point where we get to
send_need_len = recv_need_len = 224, where it starts to hang onSendRecv - There, the call to
Recvis the one hanging: https://github.com/Microsoft/LightGBM/blob/master/src/network/linkers.h#L247
- The first iterations of the loop work fine, up to the point where we get to
@imatiach-msft @mhamilton723 any ideas on what could be going on? Does this information help?
@peay @ezerhoun I've created a PR to fix this issue here: https://github.com/Microsoft/LightGBM/pull/1593 I will update LightGBM to latest version in MMLSpark as soon as the other PR goes through code review and is merged
Thanks @imatiach-msft!
@peay getting a different error on an assert inside lightgbm in the distributed case but only when running on a cluster, the notebook runs for me locally, I created an issue here to ask whether the check in the code is needed: https://github.com/Microsoft/LightGBM/issues/1604
@peay @ezerhoun there was another fix checked in here: https://github.com/Microsoft/LightGBM/pull/1605 will upload another version of lightgbm to maven central
PR has been merged, closing issue - will be in 0.14